CodeIgniter Forums
problem with CI 2.0 autoloading!!! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: problem with CI 2.0 autoloading!!! (/showthread.php?tid=39430)



problem with CI 2.0 autoloading!!! - El Forum - 03-10-2011

[eluser]neekey[/eluser]
I have a custom config file setting.php in ~/application/config/
then I want CI to autoload it so I add something like this in autoload.php:
Code:
$autoload['config'] = array("setting");

however, in my controller i get false from
Code:
$this->config->item("setting");

and when I looked into the log file, i see "Config file loaded: application/config/setting.php",
and if I print_r $this->config, in the array I can found only "[is_loaded] => Array ( [0] => application/config/setting.php" related to setting.php.

but i can successfully get my config like this:
Code:
$this->config->load("setting", TRUE);
$set = $this->config->item("setting")

what's more, when I try to autoload model :
Code:
$autoload['model'] = array("m_ajax");

I get a 500 error, but when i changed it like this:
Code:
$autoload['model'] = array("m_ajax.php");

I get error:
"Unable to locate the model you have specified: m_ajax.php"
which confused me very much.....

I am in Ubuntu 10.04, and hope somebody can explain this stuff.... I was really frastrated...
by the way , english is not my native language, hope you guys can understand what i want to say...


problem with CI 2.0 autoloading!!! - El Forum - 03-10-2011

[eluser]InsiteFX[/eluser]
Try using all single qoutes for your config values.

It could also be a case problem lowercase file name or uppercase file name not sure if your os is case senitive.

InsiteFX


problem with CI 2.0 autoloading!!! - El Forum - 03-10-2011

[eluser]Phil Sturgeon[/eluser]
InsiteFX single or double quotes have no difference in this instance and never really do.

neekey: Without wanting to sound like a cliche (or like I am being rude) but I think some more manual reading is in order.

Code:
$this->config->item("setting");

"setting" is the name of the settings file (which you've pointed out is loading fine. The setting.php file should contain:

Code:
$config['foo'] = 'bar';

then you use:

Code:
$this->config->item('foo');

You don't call the file, you've already loaded it. Smile

Also, you must have a syntax error in your model. Never put .php on the end, that is not required. turn display_errors = On in your php.ini and see what the error is, but 500 only happens when something goes REALLY wrong.


problem with CI 2.0 autoloading!!! - El Forum - 03-10-2011

[eluser]InsiteFX[/eluser]
Quote:QOUTE
InsiteFX single or double quotes have no difference in this instance and never really do.

Well Phil it does to me because if you look at all the CI config files they are all structured using single qoutes and to me this is a programming style that is what I stick with.

InsiteFX


problem with CI 2.0 autoloading!!! - El Forum - 03-10-2011

[eluser]Phil Sturgeon[/eluser]
There is a massive difference between styling guidelines and suggesting them as a fix to a problem.


problem with CI 2.0 autoloading!!! - El Forum - 03-10-2011

[eluser]neekey[/eluser]
[quote author="InsiteFX" date="1299789346"]Try using all single qoutes for your config values.

It could also be a case problem lowercase file name or uppercase file name not sure if your os is case senitive.

InsiteFX[/quote]


InstiteFX, thanks for your suggestion, but it still doesn't work


problem with CI 2.0 autoloading!!! - El Forum - 03-10-2011

[eluser]neekey[/eluser]
[quote author="Phil Sturgeon" date="1299795297"]InsiteFX single or double quotes have no difference in this instance and never really do.

neekey: Without wanting to sound like a cliche (or like I am being rude) but I think some more manual reading is in order.

Code:
$this->config->item("setting");

"setting" is the name of the settings file (which you've pointed out is loading fine. The setting.php file should contain:

Code:
$config['foo'] = 'bar';

then you use:

Code:
$this->config->item('foo');

You don't call the file, you've already loaded it. :)

Also, you must have a syntax error in your model. Never put .php on the end, that is not required. turn display_errors = On in your php.ini and see what the error is, but 500 only happens when something goes REALLY wrong.[/quote]

Phil Sturgeon: You are right! i followed what you said, and it worked well, thank you very much, following is where I made it wrong:
my setting.php:
Code:
$config = array("my_config" => "my_config");
as you said, i corrected it:
Code:
$this->config->item("my_config")

and my model m_ajax.php is simply copy from my another project which use ci 1.7
so it still extends parent model in the old way:
Quote:class M_ajax extends Model
and I think that's why I get an 500 error!

thank you!


problem with CI 2.0 autoloading!!! - El Forum - 03-10-2011

[eluser]InsiteFX[/eluser]
You need to change it to CI_Model

InsiteFX