CodeIgniter Forums

Full Version: Can't access to config->item from routes.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I created a personal config_cars.php file who is autoload from autoload.php
I can access to my datas like this $this->config->item('') from my controllers but I can't from my routes.php file !

Like this config_cars.php was loaded AFTER routes.php

How to access to my personal config file from routes.php ?

Thank you.
You can try to define a variable called CAR_CONFIG and load it in your routes like this:

create file car_config:

PHP Code:
$car_config = array(
'route_car' => 'test'
);
//Add whatever data you want to the array and at the end of the file just add:
define('CAR_CONFIG'$car_config

In your routes.php file:

PHP Code:
#include the file
require_once APPPATH.'config/car_config.php';

//Use the variable
$route[CAR_CONFIG['route_car']] = //path to your controller here... 

That should normally work i think Smile