No Application Encryption Key Has Been Specified

前端 未结 20 1649
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 17:11

I\'m new to Laravel and I\'m trying to use the Artisan command...

php artisan serve

It displays...

Laravel developme

相关标签:
20条回答
  • 2020-11-30 17:34

    I had to restart my queue worker using php artisan queue:restart after running php artisan key:generate to get jobs working.

    0 讨论(0)
  • 2020-11-30 17:35

    I actually had to add a .env file to my project and then copy the contents of .env.example so that the key:generate would work. Not sure why a .env file was not created when I started the project.

    0 讨论(0)
  • 2020-11-30 17:35

    I ran into this issue when I manually copied the contents of my Laravel project (say sites/oldname) into a new directory on my Mac (say, sites/newname). Since I was manually dragging and droppping, it didn't grab the hidden files, namely, '.env'. When I looked more closely at sites/oldname I saw .editorconfig, .env, .env.example, .gitatrributes, .styleci.yml, etc.

    The error went away once I copied the hidden files to the new directory.

    So, "No Application Encryption Key Has Been Specified" is Laravel speak for "your .env file is missing."

    0 讨论(0)
  • 2020-11-30 17:36
    php artisan key:generate
    php artisan config:cache
    

    worked for me, but it had to be done in a command prompt on Windows.

    Doing it inside the terminal in PHPStorm didn't worked.

    0 讨论(0)
  • 2020-11-30 17:39

    You can generate Application Encryption Key using this command:

    php artisan key:generate
    

    Then, create a cache file for faster configuration loading using this command:

    php artisan config:cache
    

    Or, serve the application on the PHP development server using this command:

    php artisan serve
    

    That's it!

    0 讨论(0)
  • 2020-11-30 17:41

    Open command prompt in the root folder of your project and run below command:

    php artisan key:generate
    

    It will generate Application Key for your application.

    You can find the generated application key(APP_KEY) in .env file.

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