No Application Encryption Key Has Been Specified

前端 未结 20 1646
爱一瞬间的悲伤
爱一瞬间的悲伤 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:25

    simply run

    php artisan key:generate
    

    its worked for me

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

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

    php artisan key:generate
    

    Then

    php artisan config:cache
    

    and Then

    If you're getting the same error after having key-value, then just copy the APP_KEY value from .env file and paste it to config/app.php with 'key' => 'YOUR KEY',

    and then again run

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

    Simply run this command:

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

    From Encryption - Laravel - The PHP Framework For Web Artisans:

    "Before using Laravel's encrypter, you must set a key option in your config/app.php configuration file. You should use the php artisan key:generate command to generate this key"

    I found that using this complex internet query in google.com:

    "laravel add encrption key" (Yes, it worked even with the typo!)

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

    Okay, I'll write another instruction, because didn't find the clear answer here. So if you faced such problems, follow this:

    1. Rename or copy/rename .env.example file in the root of your project to .env.

    You should not just create empty .env file, but fill it with content of .env.example.

    1. In the terminal go to the project root directory(not public folder) and run

    php artisan key:generate

    1. If everything is okay, the response in the terminal should look like this

    Application key [base64:wbvPP9pBOwifnwu84BeKAVzmwM4TLvcVFowLcPAi6nA=] set successfully.

    1. Now just copy key itself and paste it in your .env file as the value to APP_KEY. Result line should look like this:

    APP_KEY=base64:wbvPP9pBOwifnwu84BeKAVzmwM4TLvcVFowLcPAi6nA=

    1. In terminal run

    php artisan config:cache

    That's it.

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

    I found that most answers are incomplete here. In case anyone else is still looking for this:

    1. Check if you have APP_KEY= in your .env, if not just add it without a value.
    2. Run this command: php artisan key:generate. This will fill in the value to the APP_KEY in your .env file.
    3. Finally, run php artisan config:cache in order to clear your config cache and recache your config with the new APP_KEY value.
    0 讨论(0)
提交回复
热议问题