Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter configuration file load

I want to use a new file containing constants in Codeigniter so I created the file /config/labels.php

When I try to load it in my controller using $this->config->load('labels'); and it throws application/config/labels.php file does not appear to contain a valid configuration array.

However when I put the code in the constants.php file everything works well.

labels.php 

<?php
define('CLI_CIVILITE','Civilité');
define('CLI_NOM','Nom');
define('CLI_PRENOM','Prenom');
like image 283
Samson Avatar asked Jun 19 '26 22:06

Samson


1 Answers

The config file should contain an array $config Thats why it throws the error.

When the config class loads the config file, it checks if $config was set. If not it will throw an error.

As far as I know there is no feature to load your own file with custom constants. As of now you will have to add those constants to application/config/constants.php

like image 161
Broncha Avatar answered Jun 21 '26 10:06

Broncha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!