php laravel 找不到支持的加密器。密码和/或密钥长度无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31512970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
laravel No supported encrypter found. The cipher and / or key length are invalid
提问by Rahman za
I am building a project using Laravel. It was working fine on localhost, but when I upload it to the server (the server has comodo ssl installed), I receive the following error:
我正在使用 Laravel 构建一个项目。它在本地主机上运行良好,但是当我将它上传到服务器(服务器安装了 comodo ssl)时,我收到以下错误:
RuntimeException in EncryptionServiceProvider.php line 29:
No supported encrypter found. The cipher and / or key length are invalid
in EncryptionServiceProvider.php line 29
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in Container.php line 733
at Container->build(object(Closure), array()) in Container.php line 626
at Container->make('encrypter', array()) in Application.php line 674
at Application->make('Illuminate\Contracts\Encryption\Encrypter') in Container.php line 837
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 800
at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 771
at Container->build('SahraSalon\Http\Middleware\EncryptCookies', array()) in Container.php line 626
at Container->make('SahraSalon\Http\Middleware\EncryptCookies', array()) in Application.php line 674
at Application->make('SahraSalon\Http\Middleware\EncryptCookies') in Pipeline.php line 123
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 118
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 86
at Kernel->handle(object(Request)) in index.php line 54
Can anyone help solve this error?
任何人都可以帮助解决这个错误吗?
采纳答案by Salkz
Do you have all the necessary extensions installed on the server?
您是否在服务器上安装了所有必要的扩展?
- PHP >= 5.5.9
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
- PHP >= 5.5.9
- OpenSSL PHP 扩展
- PDO PHP 扩展
- Mbstring PHP 扩展
- 分词器 PHP 扩展
It could be that you're missing the OpenSSL extension. Also, do you have the key set in .env
file?
可能是您缺少 OpenSSL 扩展。另外,您是否在.env
文件中设置了密钥?
Try running:
尝试运行:
php artisan key:generate
php artisan key:generate
Answer: the 'cipher' => ''
was not set.
答:'cipher' => ''
没有设置。
回答by onavascuez
You only type in console:
您只需在控制台中输入:
php artisan key:generate
And if your app.php not change this Key, change manually.
如果您的 app.php 没有更改此 Key,请手动更改。
Next if you should then happen to get this error message:
接下来,如果您应该碰巧收到此错误消息:
[ErrorException]
file_get_contents(/path/to/my/project/.env): failed to open stream: No such file or directory
[ErrorException]
file_get_contents(/path/to/my/project/.env): 无法打开流:没有这样的文件或目录
Then make a copy of the .env.example
file and try again:
然后复制该.env.example
文件并重试:
cp .env.example .env
php artisan key:generate
回答by Vuong Tran
I have same issue before and I fixed it follow this way:
Go to config/app.php,
change "cipher" => "anything"
to
我之前遇到过同样的问题,我按照这种方式修复了它:转到 config/app.php,更改"cipher" => "anything"
为
'cipher' => MCRYPT_RIJNDAEL_128,
回答by Rowayda Khayri
I fixed it by running this:
我通过运行它来修复它:
php artisan config:cache
回答by dkbn90
I just fix error.
我只是修复错误。
Shift+Click
right mouse to "open commend window here" from your root project.- In console write:
"php artisan key:generate"
. - Get 32 character 'Mark' to
config/app.php
like'key' => env('APP_KEY', 'insert get 32 char key')
,//line number 81
Shift+Click
鼠标右键从您的根项目“在此处打开推荐窗口”。- 在控制台写:
"php artisan key:generate"
. - Get 32 character 'Mark' to
config/app.php
like'key' => env('APP_KEY', 'insert get 32 char key')
,//行号81
回答by Tirth Patel
In root directory, if there is .env.example
file then change it to .env
and then run php artisan key:generate
. This worked for me.
在根目录中,如果有.env.example
文件则将其更改为.env
然后运行php artisan key:generate
. 这对我有用。
回答by Plugue
solved with:
解决了:
php artisan key:generate
php工匠密钥:生成
回答by Lucas Serafim
In my case, I need to enable mcrypt extension.
就我而言,我需要启用 mcrypt 扩展。
But first, check if you already have it:
但首先,检查您是否已经拥有它:
$ sudo apt-get install -y mcrypt php5-mcrypt
Check if mcrypt module is loaded:
检查 mcrypt 模块是否已加载:
$ php -m | grep mcrypt
if nothing shows, is because is not loaded, but you already have installed above right? So do this:
如果什么都不显示,是因为没有加载,但是你上面已经安装了对吗?所以这样做:
$ php5enmod mcrypt
$ sudo service apache2 restart
Check again and you should see mcrypt instead of nothing. Thats a good sign, reload you app and go fix your next error ;)
再次检查,您应该看到 mcrypt 而不是什么都没有。这是一个好兆头,重新加载您的应用程序并修复您的下一个错误;)
$ php -m | grep mcrypt
mcrypt
回答by Md Shahadat Hossain
write in console php artisan key:generate
写在控制台 php artisan key:generate
you will get message like: Application key [get 32 char key] set successfully.
你会收到这样的消息: Application key [get 32 char key] set successfully.
replace app key in config/app.php
like 'key' => env('APP_KEY', 'insert get 32 char key'),//line number 81
替换应用程序键config/app.php
一样'key' => env('APP_KEY', 'insert get 32 char key'),//line number 81
回答by rüff0
if you are using app.php configuration file instead of reading key from .env file, then you can remove the env() function on key variable, ex:
如果您使用 app.php 配置文件而不是从 .env 文件中读取密钥,那么您可以删除密钥变量上的 env() 函数,例如:
'key' = env('someRandom36CharsString'),
to
到
'key' = 'someRandom36CharsString',