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:45

Add "illuminate/html": "~5.0" to require section of your composer.json file. Just like this:

...
"require": {
    ...
    "illuminate/html": "~5.0"
    ...
},
...

Then run composer install command. When composer install gets complete. run php artisan key:generate. You will get a message like this:

Application key [get 32 char key] set successfully.
查看更多
▲ chillily
3楼-- · 2019-01-07 06:47

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:

'key' = env('someRandom36CharsString'),

to

'key' = 'someRandom36CharsString',
查看更多
SAY GOODBYE
4楼-- · 2019-01-07 06:51

You only type in console:

php artisan key:generate

And if your app.php not change this Key, change manually.


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

Then make a copy of the .env.example file and try again:

cp .env.example .env
php artisan key:generate
查看更多
5楼-- · 2019-01-07 06:53

write in console php artisan key:generate

you will get message like: 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

查看更多
▲ chillily
6楼-- · 2019-01-07 06:54

solved with:

php artisan key:generate

查看更多
Summer. ? 凉城
7楼-- · 2019-01-07 06:54

Please make sure you have this requirements in your machine.

  1. PHP >= 5.6.4
  2. OpenSSL PHP Extension
  3. PDO PHP Extension
  4. Mbstring PHP Extension
  5. Tokenizer PHP Extension
  6. XML PHP Extension

Then after install or updating your project by

composer update

After this you have--

.env.example

Make a duplicate and rename it to--

.env

and make changes according to your database configuration or any other modifications you need.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your db name
DB_USERNAME=username if any otherwise root
DB_PASSWORD= your password if not set leave blank

Finally generate your application key by--

php artisan key:generate

For Someone may be only last step is enough. But I have this problem every time I clone any laravel project. This whole step makes this with any hazard.

查看更多
登录 后发表回答