【发布时间】:2020-02-09 23:19:31
【问题描述】:
我尝试学习 laravel 并在创建项目后使用。
我通过在cmd中输入“laravel new projectname”创建了一个新项目,安装了composer和node.js,在cmd中更改为项目目录并在那里安装了composer并尝试运行“php artisan serve”命令。我收到消息“Laravel 开发服务器已启动:http://127.0.0.1:8000”
当我打开 http://127.0.0.1:8000 时,我收到 500 错误(不是来自浏览器。错误来自 laravel)。
我完全不知道可能出了什么问题。我为初学者参考了 3 个指南,他们没有这个问题。
有什么办法可以解决这个错误吗?
非常感谢您
编辑:这是来自 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}
"}
【问题讨论】:
-
当你得到这行
Laravel development server started: http://127.0.0.1:8000并且我假设你没有关闭终端窗口,并且你尝试在浏览器中访问页面时,CMD 中会打印出什么? -
[2019 年 10 月 12 日星期六 22:11:36] 127.0.0.1:61786 [200]: /favicon.ico
-
php 工匠密钥:生成
-
这三个指南都不是官方文档吗? laravel.com/docs/6.x#configuration "安装 Laravel 后你应该做的下一件事是将你的应用程序密钥设置为随机字符串。"
-
这通过 Rippon Uddin 的步骤修复了它。谢谢
标签: php laravel composer-php laravel-artisan http-status-code-500