哎呀,看起来出了些问题。Laravel 5.1

7

我有这样的一个路由

http://localhost/inspection/show/{id}

当我同时在不同的标签页中加载路由时,有时会出现“糟糕,似乎出了些问题”的错误。

在不同的标签页中快速加载。

http://localhost/inspection/show/8
http://localhost/inspection/show/9
http://localhost/inspection/show/10
http://localhost/inspection/show/11

堆栈跟踪包含以下内容

[2015-08-06 14:57:53] local.ERROR: exception 'RuntimeException' with message 'No supported encrypter found. The cipher and / or key length are invalid.' in C:\wamp\www\iaserver\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:29
Stack trace:
#0 C:\wamp\www\iaserver\vendor\laravel\framework\src\Illuminate\Container\Container.php(733): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)
#1 C:\wamp\www\iaserver\vendor\laravel\framework\src\Illuminate\Container\Container.php(626): Illuminate\Container\Container->build(Object(Closure), Array)
#2 C:\wamp\www\iaserver\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(674): Illuminate\Container\Container->make('encrypter', Array)
#3 C:\wamp\www\iaserver\vendor\laravel\framework\src\Illuminate\Container\Container.php(837): Illuminate\Foundation\Application->make('Illuminate\\Cont...')
#4 C:\wamp\www\iaserver\vendor\laravel\framework\src\Illuminate\Container\Container.php(800): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 C:\wamp\www\iaserver\vendor\laravel\framework\src\Illuminate\Container\Container.php(771): Illuminate\Container\Container->getDependencies(Array, Array)
#6 C:\wamp\www\iaserver\vendor\laravel\framework\src\Illuminate\Container\Container.php(626): Illuminate\Container\Container->build('IAServer\\Http\\M...', Array)
#7 C:\wamp\www\iaserver\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(674): Illuminate\Container\Container->make('IAServer\\Http\\M...', Array)
#8 C:\wamp\www\iaserver\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(143): Illuminate\Foundation\Application->make('IAServer\\Http\\M...')
#9 C:\wamp\www\iaserver\public\index.php(58): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response))
#10 {main} 

.env文件正确,我重新运行了php artisan key:generate命令。

APP_ENV=local
APP_DEBUG=true
APP_KEY=UC5Fsvi8JsGG4U72k04rS3o5csiINDYB

但是只有在路由快速加载不同的id时才会出现错误。

为什么?

我解决了,有时laravel没有读取.env中的APP_KEY。它返回一个值“SomeRandomString”(默认在config / app.php中定义),并且出现“key length is invalid”的错误,所以解决方案是将APP_KEY的值复制到config / app.php中的'key'值中,就这样!我解决了!


我认为你需要发布你的检查控制器和视图代码。 - Maytham Fahmi
1
我解决了一个问题,有时候 Laravel 无法读取 .ENV 文件中的 APP_KEY 值。它会返回一个值 "SomeRandomString"(默认在 config/app.php 中定义),并且会出现 "key length is invalid" 的错误。因此,解决方案是将 APP_KEY 的值复制到 config/app.php 文件中的 'key' 值中,就这样!我解决了! - MaTiUs77
2
如果您仍在使用 .env 文件,则不要替换配置文件的默认值,因为这样会使其失去使用的目的。您正在运行哪个版本的 PHP? - Lance Pioch
我正在使用带有Apache/2.4.9 (Win64) PHP/5.5.12的WAMP。有时,当我尝试使用不同的连接时会出现错误,目前,我已经将我的配置从.env更改为config.php。有什么建议吗? - MaTiUs77
2
请回答并标记为已完成,以便您的问题不会显示在未回答列表中。 - Eduardo Cruz
显示剩余3条评论
1个回答

1
您可以尝试再次运行php artisan key:generate,这应该可以解决问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接