Laravel 5.2 not reading env file

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

    I experienced this. Reason was that apache(user www-data) could not read .env due to file permissions. So i changed the file permissions to ensure that the server (apache) had read permissions to the file. Just that and boom, it was all working now!
    Update:
    How to do this varies, depending on who owns the .env file, but assuming it belongs to the Apache www-data group, you can do this:

    sudo chmod g+r .env
    

    Modify it depending on your permission structure.

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

    For me the following worked

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

    Wow. Good grief. It's because I had an env value with a space in it, not surrounded by quotes

    This

    SITE_NAME=My website
    

    Changed to this

    SITE_NAME="My website"
    

    Fixed it. I think this had to do with Laravel 5.2 now upgrading vlucas/phpdotenv from 1.1.1 to 2.1.0

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

    run this:

    php artisan config:clear
    php artisan cache:clear
    

    then
    php artisan config:cache

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

    When you fired command php artisan config:cache then it will wipe out all the env variables and env() will give null values, try running following command and boom there your env() again begin to catch all env variable

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

    I had a similar issue in my config/services.php and I solved using config clear and optimize commands:

    php artisan config:clear
    php artisan optimize
    
    0 讨论(0)
提交回复
热议问题