我有这样的一个路由
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'值中,就这样!我解决了!