#php #laravel #laravel-5
Вопрос:
Я уже сделал ключ $php artisan:сгенерировать и конфигурацию $php artisan:кэш. Ключ действительно генерируется в моем файле .env при выполнении команды artisan generate, что хорошо.
Я заметил, что это началось после того, как я обновил Laravel 5.1 до Laravel 5.2 и изменил «bindshared» на «singleton» на своем EncryptionServiceProvider.php что мне было предложено сделать при обновлении с 5.1 до 5.2.
Я был озадачен этим уже несколько недель и, похоже, не могу найти ничего полезного в Интернете. Заранее спасибо!
Вот ошибка, которую я получаю:
RuntimeException in EncryptionServiceProvider.php line 45:
No supported encrypter found. The cipher and / or key length are invalid.
in EncryptionServiceProvider.php line 45
at EncryptionServiceProvider->getEncrypterForKeyAndCipher(null, null) in EncryptionServiceProvider.php line 25
at EncryptionServiceProvider->IlluminateEncryption{closure}(object(Application), array()) in Container.php line 731
at Container->build(object(Closure), array()) in Container.php line 629
at Container->make('encrypter', array()) in Application.php line 697
at Application->make('encrypter') in Container.php line 849
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 804
at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 774
at Container->build('IlluminateCookieMiddlewareEncryptCookies', array()) in Container.php line 629
at Container->make('IlluminateCookieMiddlewareEncryptCookies', array()) in Application.php line 697
at Application->make('IlluminateCookieMiddlewareEncryptCookies') in Pipeline.php line 126
at Pipeline->IlluminatePipeline{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->IlluminateRouting{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
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 136
at Pipeline->IlluminatePipeline{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->IlluminateRouting{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 52
Вот мой app.php:
<?php
return [
'sign_image_dir' => 'img/signs/',
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG'),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => '/',
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'America/New_York',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => env('AES-256-CBC'),
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => 'daily',
/*
|--------------------------------------------------------------------------
| Environment Value for Laravel 5.2 Update
|--------------------------------------------------------------------------
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
'CollectiveHtmlHtmlServiceProvider',
'IlluminateAuthAuthServiceProvider',
'IlluminateCacheCacheServiceProvider',
'IlluminateFoundationProvidersConsoleSupportServiceProvider',
'IlluminateCookieCookieServiceProvider',
'IlluminateDatabaseDatabaseServiceProvider',
'IlluminateEncryptionEncryptionServiceProvider',
'IlluminateFilesystemFilesystemServiceProvider',
'IlluminateFoundationProvidersFoundationServiceProvider',
'IlluminateHashingHashServiceProvider',
'IlluminateMailMailServiceProvider',
'IlluminatePaginationPaginationServiceProvider',
'IlluminatePipelinePipelineServiceProvider',
'IlluminateQueueQueueServiceProvider',
'IlluminateRedisRedisServiceProvider',
'IlluminateAuthPasswordsPasswordResetServiceProvider',
'IlluminateSessionSessionServiceProvider',
'IlluminateTranslationTranslationServiceProvider',
'IlluminateValidationValidationServiceProvider',
'IlluminateViewViewServiceProvider',
'BarryvdhDomPDFServiceProvider',
'BarryvdhDebugbarServiceProvider',
'InterventionImageImageServiceProvider',
'UxWebSweetAlertSweetAlertServiceProvider',
'IlluminateBroadcastingBroadcastServiceProvider',
CollectiveBusBusServiceProvider::class,
/*
* Application Service Providers...
*/
'AppProvidersAppServiceProvider',
'AppProvidersBusServiceProvider',
'AppProvidersConfigServiceProvider',
'AppProvidersEventServiceProvider',
'AppProvidersRouteServiceProvider',
'LaracastsFlashFlashServiceProvider',
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => 'IlluminateSupportFacadesApp',
'Artisan' => 'IlluminateSupportFacadesArtisan',
'Auth' => 'IlluminateSupportFacadesAuth',
'Blade' => 'IlluminateSupportFacadesBlade',
'Bus' => 'IlluminateSupportFacadesBus',
'Cache' => 'IlluminateSupportFacadesCache',
'Config' => 'IlluminateSupportFacadesConfig',
'Cookie' => 'IlluminateSupportFacadesCookie',
'Crypt' => 'IlluminateSupportFacadesCrypt',
'DB' => 'IlluminateSupportFacadesDB',
'Eloquent' => 'IlluminateDatabaseEloquentModel',
'Event' => 'IlluminateSupportFacadesEvent',
'File' => 'IlluminateSupportFacadesFile',
'Hash' => 'IlluminateSupportFacadesHash',
'Input' => 'IlluminateSupportFacadesInput',
'Inspiring' => 'IlluminateFoundationInspiring',
'Lang' => 'IlluminateSupportFacadesLang',
'Log' => 'IlluminateSupportFacadesLog',
'Mail' => 'IlluminateSupportFacadesMail',
'Password' => 'IlluminateSupportFacadesPassword',
'Queue' => 'IlluminateSupportFacadesQueue',
'Redirect' => 'IlluminateSupportFacadesRedirect',
'Redis' => 'IlluminateSupportFacadesRedis',
'Request' => 'IlluminateSupportFacadesRequest',
'Response' => 'IlluminateSupportFacadesResponse',
'Route' => 'IlluminateSupportFacadesRoute',
'Schema' => 'IlluminateSupportFacadesSchema',
'Session' => 'IlluminateSupportFacadesSession',
'Storage' => 'IlluminateSupportFacadesStorage',
'URL' => 'IlluminateSupportFacadesURL',
'Validator' => 'IlluminateSupportFacadesValidator',
'View' => 'IlluminateSupportFacadesView',
'Flash' => 'LaracastsFlashFlash',
'PDF' => 'BarryvdhDomPDFFacade',
'Image' => 'InterventionImageFacadesImage',
'Alert' => 'UxWebSweetAlertSweetAlert',
'Form' => 'CollectiveHtmlFormFacade',
'Html' => 'CollectiveHtmlHtmlFacade',
'Gate' => IlluminateSupportFacadesGate::class,
],
];
Вот это EncryptionServiceProvider.php файл:
<?php
namespace IlluminateEncryption;
use RuntimeException;
use IlluminateSupportStr;
use IlluminateSupportServiceProvider;
class EncryptionServiceProvider extends ServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('encrypter', function ($app) {
$config = $app->make('config')->get('app');
if (Str::startsWith($key = $config['key'], 'base64:')) {
$key = base64_decode(substr($key, 7));
}
return $this->getEncrypterForKeyAndCipher($key, $config['cipher']);
});
}
/**
* Get the proper encrypter instance for the given key and cipher.
*
* @param string $key
* @param string $cipher
* @return mixed
*
* @throws RuntimeException
*/
protected function getEncrypterForKeyAndCipher($key, $cipher)
{
if (Encrypter::supported($key, $cipher)) {
return new Encrypter($key, $cipher);
} elseif (McryptEncrypter::supported($key, $cipher)) {
return new McryptEncrypter($key, $cipher);
} else {
throw new RuntimeException('No supported encrypter found. The cipher and / or key length are invalid.');
}
}
}
Комментарии:
1. проверьте, удовлетворяет ли это требованиям или нет . Версия PHP между 5.5.9 — 7.1.*, Расширение PHP OpenSSL, Расширение PHP PDO, Расширение PHP Mbstring, Расширение PHP Токенизатора,
Ответ №1:
'cipher' => env('AES-256-CBC'),
должно быть 'cipher' => 'AES-256-CBC',