0

I try to learn laravel and after creating a project with.

i created a new project by typing "laravel new projectname" in cmd, installing composer and node.js, changed in cmd to the project directory and installed composer there and tryed to run "php artisan serve" comand. i got the message "Laravel development server started: http://127.0.0.1:8000"

when i open http://127.0.0.1:8000 i get a 500 Error (not from the browser. the error is from laravel).

I have absolutly no idea what could be wrong. I went by 3 guides for starters and they did not have this problem.

Is there anything i can do ti fix this error?

thank you very much in advance

edit: here is the logfile from storage/logs

[2019-10-12 20:13:12] production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified. at C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Encryption\\EncryptionServiceProvider.php:44) [stacktrace] #0 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\helpers.php(424): Illuminate\\Encryption\\EncryptionServiceProvider->Illuminate\\Encryption\\{closure}(NULL) #1 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Encryption\\EncryptionServiceProvider.php(48): tap(NULL, Object(Closure)) #2 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Encryption\\EncryptionServiceProvider.php(24): Illuminate\\Encryption\\EncryptionServiceProvider->key(Array) #3 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(800): Illuminate\\Encryption\\EncryptionServiceProvider->Illuminate\\Encryption\\{closure}(Object(Illuminate\\Foundation\\Application), Array) #4 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(682): Illuminate\\Container\\Container->build(Object(Closure)) #5 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(630): Illuminate\\Container\\Container->resolve('encrypter', Array) #6 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(768): Illuminate\\Container\\Container->make('encrypter', Array) #7 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(946): Illuminate\\Foundation\\Application->make('encrypter') #8 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(874): Illuminate\\Container\\Container->resolveClass(Object(ReflectionParameter)) #9 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(835): Illuminate\\Container\\Container->resolveDependencies(Array) #10 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(682): Illuminate\\Container\\Container->build('App\\\\Http\\\\Middle...') #11 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(630): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Middle...', Array) #12 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(768): Illuminate\\Container\\Container->make('App\\\\Http\\\\Middle...', Array) #13 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(215): Illuminate\\Foundation\\Application->make('App\\\\Http\\\\Middle...') #14 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(189): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response)) #15 C:\\Users\\Rjinxil\\testproject\\public\\index.php(60): Illuminate\\Foundation\\Http\\Kernel->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response)) #16 C:\\Users\\Rjinxil\\testproject\\server.php(21): require_once('C:\\\\Users\\\\Rjinxi...') #17 {main} "} 
5
  • When you get this line Laravel development server started: http://127.0.0.1:8000 and I assume you don't close the terminal window, and you try to access the page in the browser, what gets printed out in the CMD? Commented Oct 12, 2019 at 20:08
  • [Sat Oct 12 22:11:36 2019] 127.0.0.1:61786 [200]: /favicon.ico Commented Oct 12, 2019 at 20:11
  • 2
    php artisan key:generate Commented Oct 12, 2019 at 20:22
  • None of those three guides was the official docs? laravel.com/docs/6.x#configuration "The next thing you should do after installing Laravel is set your application key to a random string." Commented Oct 12, 2019 at 21:26
  • this fixed it with the steps from Rippon Uddin. thank you Commented Oct 13, 2019 at 7:11

2 Answers 2

1

So close your terminal session and run this command in your CMD:

php artisan key:generate 

in the project folder. Make sure you have .env file created. Then serve your application once again.

Sign up to request clarification or add additional context in comments.

2 Comments

same result. the .env file is empty. Still getting this error in the log: [2019-10-13 07:03:58] production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified. at C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Encryption\\EncryptionServiceProvider.php:44) [stacktrace]
.env should not be empty! You have to have APP_KEY at least with the generated key. Take a look at the .env.example file that comes with the framework.
0

Try Below steps :

php artisan config:cache php artisan cache:clear php artisan key:generate 

2 Comments

this fixed it after renmaing the .env.example file to .env
you should use those command while u created new project or move one local server to another or live. .env must be required too.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.