• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Load custom config file?

I made a custom config file with some general settings I want to access in my controllers.

When I make a new controller and load the config file I can access the variables I set:

$customvalues = new \Config\Custom();
echo $customvalues->myvalue;

How can I load the config file so that I dont have to initiate a new instance in every class of the controller but like in codeigniter 3 one would do in a constructor function?

You can load it in the base controller. It would be available for all your controllers. You can also get a shared instance with the config() function like described on this page of the user guide: https://codeigniter4.github.io/userguide...nfig-files
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com

Or you can load in the Common.php file.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.