Welcome Guest, Not a member yet? Register   Sign In
Including codeigniter config file from external scripts
#1

[eluser]darkside9[/eluser]
Hi

I have developed web application using CI, I need to write some pure php scripts, those scripts will run throught CLI, I need to get some configuration like DB configuration, or other defined configs from the codeigniter config file and re use them in those scripts.

How I can use the config(s) file(s) from outside CI.
#2

[eluser]Dam1an[/eluser]
Just include them as you would with a normal PHP file
Code:
include 'path/to/ci/config/database.php';

You then have access to the variables defined in that file
#3

[eluser]darkside9[/eluser]
thanks Dam1an

I have did it? But I got error message (No direct script access allowed) which produced by
if (!defined('BASEPATH')) exit('No direct script access allowed');

I have define a constant BASEPATH which point to /path/to/system/ directory
Then I include the config file and it is working fine with me Smile
#4

[eluser]Dam1an[/eluser]
Oh yeah, forgot about the BASEPATH thing (as you can guess, I don't do this myself, just know how lol)




Theme © iAndrew 2016 - Forum software by © MyBB