Laravel 5.2 not reading env file

前端 未结 26 1993
时光说笑
时光说笑 2020-11-28 20:52

After upgrading to Laravel 5.2, none of my .env file values are being read. I followed the upgrade instructions; none of my config files were changed except aut

相关标签:
26条回答
  • 2020-11-28 21:36

    I missed this in the upgrade instructions:

    Add an env configuration option to your app.php configuration file that looks like the following: 'env' => env('APP_ENV', 'production')

    Adding this line got the local .env file to be read in correctly.

    0 讨论(0)
  • 2020-11-28 21:36

    if you did call config:cache during local development, you can undo this by deleting the bootstrap/cache/config.php file. and this is work for me.

    @Payal Pandav has given the comment above.

    I want to tell a simple workaround. Just edit the config.php file in the bootstrap/cache/ folder. And change the credentials. This worked for me. Please don't delete this file since this may contain other crucial data in the production environment.

    0 讨论(0)
  • 2020-11-28 21:39

    Tried almost all of the above. Ended up doing

    chmod 666 .env

    which worked. This problem seems to keep cropping up on the app I inherited however, this most recent time was after adding a .env.testing. Running Laravel 5.8

    0 讨论(0)
  • 2020-11-28 21:42

    If any of your .env variables contains white space, make sure you wrap them in double-quotes. For example:

    SITE_NAME="My website"

    Don't forget to clear your cache before testing:

    php artisan config:cache
    php artisan config:clear
    
    0 讨论(0)
  • 2020-11-28 21:42

    if you did call config:cache during local development, you can undo this by deleting the bootstrap/cache/config.php file. and this is work for me.

    0 讨论(0)
  • 2020-11-28 21:42

    In my case laravel 5.7 env('APP_URL') not work but config('app.url') works. If I add new variable to env and to config - it not works - but after php artisan config:cache it start works.

    0 讨论(0)
提交回复
热议问题