What is the best practice for adding constants in laravel? (Long List)

后端 未结 11 758
猫巷女王i
猫巷女王i 2021-01-30 06:21

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

11条回答
  •  余生分开走
    2021-01-30 06:56

    require app_path().'/constants.php';
    
    define('ADMIN',  'administrator');
    

    or -

    You can also move more sensitive info

    return [
       'hash_salt' => env('HASH_SALT'),
     ];
    

    And use it like before:

     echo Config::get('constants.hash_salt');
    

提交回复
热议问题