CodeIgniter Forums
FTP (and other class) Default Config Files - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: FTP (and other class) Default Config Files (/thread-19035.html)



FTP (and other class) Default Config Files - El Forum - 05-25-2009

[eluser]adamfairholm[/eluser]
Hey everyone,

For a few of the CI classes, there is a variant of this line in the documentation:

Quote:Setting FTP Preferences in a Config File

If you prefer you can store your FTP preferences in a config file. Simply create a new file called the ftp.php, add the $config array in that file. Then save the file at config/ftp.php and it will be used automatically.

I was wondering if anyone knew if there is anywhere in the code where this specifically happens and these variables from the config file are initialized. I can't seem to find anything in the FTP, Loader or Config classes.

I know that there are a few classes that have this (I believe the Email class has one as well). I'm writing a class that would be great to use this feature with, but I'm at a loss of how to make that happen.

Any pointers would be appreciated!


FTP (and other class) Default Config Files - El Forum - 05-26-2009

[eluser]Phil Sturgeon[/eluser]
That actually happens in Loader::_ci_init_class(). Take a look at line 860.


FTP (and other class) Default Config Files - El Forum - 05-26-2009

[eluser]xwero[/eluser]
To let the classes not dependent on the config class the settings are loaded as a class parameter.

The down side is that the settings aren't a part of the config class as the config file content is added to the class directly.


FTP (and other class) Default Config Files - El Forum - 05-26-2009

[eluser]adamfairholm[/eluser]
Thanks! There it is. I missed it in the Loader there.

That's too bad that the settings aren't part of the config class though. I guess it's handy in certain circumstances, though.