Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Erro no laravel - RuntimeException in Encrypter.php line 43

Estou no começo do curso do laravel, estou na aula 2 atividade 2.

A instalação não funcionou corretamente, tive que recorrer a doc do laravel para instala-lo, o código que usei para instalar é:

composer create-project --prefer-dist laravel/laravel estoque

Como estou numa versão nova, fiz a alterações no web.php ao invés do routes.php, rodei o dump no banco de dados, que já está funcionando, mas quando tento acessar gera erro:

RuntimeException in Encrypter.php line 43:
The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.

in Encrypter.php line 43
at Encrypter->__construct('', 'AES-256-CBC') in EncryptionServiceProvider.php line 27
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in Container.php line 718
at Container->build(object(Closure)) in Container.php line 600
at Container->resolve('encrypter') in Container.php line 567
at Container->make('encrypter') in Application.php line 708
at Application->make('encrypter') in Container.php line 854
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 782
at Container->resolveDependencies(array(object(ReflectionParameter))) in Container.php line 748
at Container->build('estoque\\Http\\Middleware\\EncryptCookies') in Container.php line 600
at Container->resolve('estoque\\Http\\Middleware\\EncryptCookies') in Container.php line 567
at Container->make('estoque\\Http\\Middleware\\EncryptCookies') in Application.php line 708
at Application->make('estoque\\Http\\Middleware\\EncryptCookies') in Pipeline.php line 138
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 561
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 520
at Router->dispatchToRoute(object(Request)) in Router.php line 498
at Router->dispatch(object(Request)) in Kernel.php line 174
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ValidatePostSize.php line 27
at ValidatePostSize->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53
RuntimeException in Encrypter.php line 43:
The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.

in Encrypter.php line 43
at Encrypter->__construct('', 'AES-256-CBC') in EncryptionServiceProvider.php line 27
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in Container.php line 718
at Container->build(object(Closure)) in Container.php line 600
at Container->resolve('encrypter') in Container.php line 567
at Container->make('encrypter') in Application.php line 708
at Application->make('encrypter') in Container.php line 854
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 782
at Container->resolveDependencies(array(object(ReflectionParameter))) in Container.php line 748
at Container->build('estoque\\Http\\Middleware\\EncryptCookies') in Container.php line 600
at Container->resolve('estoque\\Http\\Middleware\\EncryptCookies') in Container.php line 567
at Container->make('estoque\\Http\\Middleware\\EncryptCookies') in Application.php line 708
at Application->make('estoque\\Http\\Middleware\\EncryptCookies') in Kernel.php line 213
at Kernel->terminateMiddleware(object(Request), object(Response)) in Kernel.php line 187
at Kernel->terminate(object(Request), object(Response)) in index.php line 58

Segue código do web.php:

<?php
Route::get('/', function () {
    return "Lista de produtos";
});

Segue parte do database:

'default' => env('DB_CONNECTION', 'mysql'), // continua igual, não alterei
[...]
'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'estoque_laravel'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

E, como no curso, renomiei o .env.example para .env e deixei assim:

APP_DEBUG=true

Alguém tem alguma ideia do q possa ser?

2 respostas

Oi Taynan, tudo bom?

Verifica no seu arquivo config/app.php, se na configuração de 'cipher' você tem algo como:

'cipher' => 'AES-128-CBC',

Se não, tenta alterar para esse valor =)

Depois limpa suas configurações com o comando:

artisan config:clear

Qualquer problema compartilha aqui com a gente =)

Abraço, aguardo retorno!

solução!

Obrigado André,

Fiz esse comando mas não funcionou infelizmente.

Só funcionou quando eu recriei o projeto e não apaguei o arquivo .env, vi em algum lugar no github que pode ser problena na linha do APP_KEYno .env. Já fiz a configuração do DB por lá mesmo e funcionou.