In laravel 5.0 the way to define constants and use them through out the project. Following are the steps to accomplish it:-
Step 1st :- Creating a separate file under /config folder named as constants.php ( it can be any name) for storing all constants.
<?php
return [
'CONTROLLER_PATH' => "App\Http\Controllers\\"
];
Step 2nd :- Define the file name in composer.json under "autoload" with "files" param for automatically loading the file.
"autoload": {
"files": [
"config/constants.php"
] }
Step 3rd :- Running the following command in command line.
$ composer dumpautoload
Step 4th :- Syntax for using the constants.
Config::get('constants.CONTROLLER_PATH')
0 Comment(s)