Laravel .env variable always returns null

前端 未结 7 2382
误落风尘
误落风尘 2021-01-05 01:14

I added this variable to .env file

STRIPE_SECRET=a12345

I would like to dump the variable using routes/web.php

&         


        
7条回答
  •  被撕碎了的回忆
    2021-01-05 01:37

    I would not recommend using the env('STRIPE') command to get a variable. In a loop, this command starts returning null after some iteration. Therefore, it is better to create a configuration file and use the command "config('file_name.variable_name)":

     env('STRIPE_SECRET', '')
    ];
    

    Run these commands first

    php artisan config:cache
    php artisan config:clear
    

    And use this command to get the value of the STRIPE_SECRET variable:

    config('config_file.sprite_secret)
    

提交回复
热议问题