laravel No supported encrypter found. The cipher a

2019-01-07 06:33发布

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:

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?

14条回答
祖国的老花朵
2楼-- · 2019-01-07 06:56

In my case, I need to enable mcrypt extension.

But first, check if you already have it:

$ sudo apt-get install -y mcrypt php5-mcrypt

Check if mcrypt module is loaded:

$ 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 ;)

$ php -m | grep mcrypt
mcrypt
查看更多
相关推荐>>
3楼-- · 2019-01-07 06:59

I have same issue before and I fixed it follow this way: Go to config/app.php, change "cipher" => "anything" to

'cipher' => MCRYPT_RIJNDAEL_128,
查看更多
叛逆
4楼-- · 2019-01-07 07:01

I fixed it by running this:

php artisan config:cache
查看更多
叛逆
5楼-- · 2019-01-07 07:03

I just fix error.

  1. Shift+Click right mouse to "open commend window here" from your root project.
  2. In console write: "php artisan key:generate".
  3. Get 32 character 'Mark' to config/app.php like 'key' => env('APP_KEY', 'insert get 32 char key'),//line number 81
查看更多
闹够了就滚
6楼-- · 2019-01-07 07:03

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.

查看更多
我欲成王,谁敢阻挡
7楼-- · 2019-01-07 07:04

I was suffering with this problem for a few too many hours before I discovered that the key was being cached in the bootstrap\cache\config.php. Deleted the file and my site loaded fine (i.e. there was otherwise no problem with my config).

I discovered this by adding some debug output to boostrap\cache\compiled.php to make it spit out the cipher and key (somewhere around line 7010). Then dug around to see how it was picking up the config and found it uses a cache config file.

查看更多
登录 后发表回答