CodeIgniter Forums
Can I access Codeigniter's config.php values outside of codeigntier? - 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: Can I access Codeigniter's config.php values outside of codeigntier? (/showthread.php?tid=10746)



Can I access Codeigniter's config.php values outside of codeigntier? - El Forum - 08-11-2008

[eluser]housecor[/eluser]
Title says it all - I'd like to access the values in config.php for a few php scripts we're running outside of codeigniter. Is there a way to access these values?

I hoped to just include the config.php file in my script but I can't since config.php doesn't allow direct script access for security reasons.

BTW - The whole reason I'm not putting my PHP script in Codeigniter is because it's a third party script that relies on $_GET and I don't want to turn on query strings in Codeigniter.

Thanks in advance!


Can I access Codeigniter's config.php values outside of codeigntier? - El Forum - 08-11-2008

[eluser]Hannes Nevalainen[/eluser]
you have two options I think.

1. Delete the first line in the config file: (the one that checks if BASEPATH is defined)
2. In your third party app define a konstant BASEPATH before including the CI config file.

Code:
define('BASEPATH','./');
I suggest alternative 2 since its more secure.


Can I access Codeigniter's config.php values outside of codeigntier? - El Forum - 08-11-2008

[eluser]housecor[/eluser]
Excellent idea! Love the simplicity. Thanks!


Can I access Codeigniter's config.php values outside of codeigntier? - El Forum - 08-11-2008

[eluser]Colin Williams[/eluser]
Quote:The whole reason I’m not putting my PHP script in Codeigniter is because it’s a third party script that relies on $_GET and I don’t want to turn on query strings in Codeigniter.

Why not, exactly? Even with query string enabled, you can still use Clean URLs (using PATH_INFO or REQUEST_URI). I've done this for things like Facebook apps.