Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to store constants in laravel 5.0

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.94k
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: