1

I created a customized config file called config2 and autoload it in autoload.php. In my model, i just use $this->config->item('item_in_config2'), it works well. However, in my paypal library, i tried to use the same thing like this:

$this->PROXY_HOST = $this->config->item['paypal_proxy_host'];

an error occur: undefined property $config. Then i tried to add parent::__construct(); under library constructor, server error shows. Previously, i load the config2 manually and it worked well, but i really want to autoload it now. any ideas? thanks

2
  • I've run into this before. What are you using the second config file for? It's likely being loaded before something inside of it. Commented Mar 19, 2013 at 18:40
  • Hi Devin, i use the second config file for paypal, facebook etc. setup. how did you solve the problem? thx Commented Mar 19, 2013 at 18:49

1 Answer 1

2

I think you have to call the CI instance in the library:

paypal library constructor:

$CI =& get_instance();

$proxy_host = $CI->config->item('paypal_proxy_host');
Sign up to request clarification or add additional context in comments.

1 Comment

Libraries do not share the same application scope as controllers or models. You need to retrieve the CI super object as stormdrain said. See Utilizing CodeIgniter Resources within Your Library. If you want to use the $this syntax, you can do what models do, and use the __get() magic method to fetch the CI object. See /system/core/Model.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.