Welcome Guest, Not a member yet? Register   Sign In
Can't access to config->item from routes.php
#1

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.
Reply
#2

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB