Laravel 5.2 not reading env file

前端 未结 26 1990
时光说笑
时光说笑 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:29

    delete cache using:

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

    From the official Laravel 5.2 Upgrade Notes:

    If you are using the config:cache command during deployment, you must make sure that you are only calling the env function from within your configuration files, and not from anywhere else in your application.

    If you are calling env from within your application, it is strongly recommended you add proper configuration values to your configuration files and call env from that location instead, allowing you to convert your env calls to config calls.

    Reference: https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0

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

    I made the mistake by doing dd/die/dump in the index.php file. This causes the system to not regenerate the configs.

    Just do dump in view files will do. The changes to .env file update instantly.

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

    I ran into this same problem on my local, and I have tried all the answers here but to no avail. Only this worked for me, php artisan config:clear and restart server. Works like a charm!

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

    If you run this php artisan config:cache command on console then it will store all the .env file contents in cache, after this command if you append any contents into .env file the it will not be not be available until you run php artisan config:clear command

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

    For me it has worked this in this order:

    php artisan config:cache
    php artisan config:clear
    php artisan cache:clear
    

    And I've tried all the rests without luck.

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