I have created a project in Laravel 5.7 and created the file constants.php in config directory. When I tried to run php artisan config:cache, I am getting the following error. "ErrorException : Constant XXX_XXX already defined"
I have defined all the constants as define('XXXX_XXXX', 'bla bla'); All these are standard constants needed for my package.
I have done the following:
I very much need this constants and the same time cache the configs to run. I am not able guess the problem.
Note : Contents of config/contants.php
all are define('XXX', 'xxx'); Simply echo XYZ; wherever needed. Standard php constants.
try this way
define constant value below
if (!defined('constant')) define('constant', 'value');
I am not sure whether it is correct but the way it worked is as follows:
I modified the composer.json in the "autoload" with
"files": [ "app/constants.php" ]
I ran composer dump-autoload
It had build the new config file in bootstrap and the code is executing normal.