jeudi 20 juin 2019

How to define constants that can be used across config files in Laravel 5?

As I checked on multiple sources, the Laravel way of defining constant variables is through config files. However, in my case, I want to use constants across my config files which is not possible since, as I read, it's not possible/advisable to call a config from another.

EXAMPLE

Constants:

define('THE_ID_OF_SOMETHING_NICE', 1);
define('THE_ID_OF_SOMETHING_UGLY', 2);
define('THE_ID_OF_SOMETHING_BAD', 12372);

config1.php

return [
   THE_ID_OF_SOMETHING_NICE = ['many', 'nice', 'data'],
]

config2.php

return [
   ['many', 'nice', 'data', THE_ID_OF_SOMETHING_NICE],
]

As you can see, I just can't use the actual value of the defined constants since it'll be too unreadable. Also I don't want to clump up my .env file with these constants since it's not really meant for it.

Any workaround for this? Thanks.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Kw1WQD
via IFTTT

Aucun commentaire:

Enregistrer un commentaire