I am rather new to laravel. I have a basic question, What is the best way to add constants in laravel. I know the .env method that we use to add the constants. Also I have mad
First you make Constants
folder inside your app directory.
And then you make Constants.php
. Define your constants in this file
For Example :
define('ONE', '1');
define('TWO', '2');
And you modify the composer.json
Alternatively, you can use composer.json to load the bootstrap/constants.php file by adding the following code to the “autoload” section, like so:
"autoload": {
"files": [
"bootstrap/constants.php"
]
}
And update your composer !