Simple way to add constants in Laravel

 We know the .env method in which we define constants in the .env file but other than that is there any method like storing all constants in a constant file?. Lets see. If you are using a lot of constants and most of them are used globally in the application storing the constants in a constant.php file is a simple and good option. For this method just create a file say constants.php in the config directory. In the file you have to return array of config values.

return [

    'options' => [

        'option_attachment' => '13',

        'option_email' => '14',

        'option_monetery' => '15',

        'option_ratings' => '16',

        'option_textarea' => '17',



Access  these constants as shown below.


// or if you want a specific one