Wednesday, October 17, 2018

Solution To: Laravel Error No application encryption key has been specified.

.
PROBLEM:

RuntimeException
No application encryption key has been specified.

SOLUTION:


1. If .env does not exist in root folder, .env.example file in the root of your project to .env or create a new .env file.

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

.envfile look like this: (Fill up with required database connection)

APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
APP_URL=http://localhost

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
.


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

php artisan key:generate

If everything is okay, response in terminal should look like this
Application key [base64:wbvPP9pBOwifnwu84BeKAVzmwM4TLvcVFowLcPAi6nA=] set successfully.

4. Check that the Application Key is inserted into .env file.

You can just copy key itself and paste it in your .env file as the value to APP_KEY. Result line should looks like this:
APP_KEY=base64:wbvPP9pBOwifnwu84BeKAVzmwM4TLvcVFowLcPAi6nA=

5. In terminal run

php artisan config:cache

.
REFERENCE:
https://stackoverflow.com/questions/44839648/no-application-encryption-key-has-been-specified-new-laravel-app


No comments:

Post a Comment

Labels