Welcome Guest, Not a member yet? Register   Sign In
Can I access Codeigniter's config.php values outside of codeigntier?
#1

[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!
#2

[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.
#3

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

[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.




Theme © iAndrew 2016 - Forum software by © MyBB