mani95lisa's avatar

Class cache does not exist error when use redis session, file session is fine

When I use https://github.com/illuminate/html and redis driver, I got below errors:

in Container.php line 736
at ReflectionClass->__construct('cache') in Container.php line 736
at Container->build('cache', array()) in Container.php line 626
at Container->make('cache', array()) in Application.php line 674
at Application->make('cache') in Container.php line 1157
at Container->offsetGet('cache') in SessionManager.php line 155
at SessionManager->createCacheHandler('redis') in SessionManager.php line 128
at SessionManager->createRedisDriver() in Manager.php line 87
at Manager->createDriver('redis') in Manager.php line 63
at Manager->driver() in SessionServiceProvider.php line 48
at SessionServiceProvider->Illuminate\Session\{closure}(object(Application), array()) in Container.php line 733
at Container->build(object(Closure), array()) in Container.php line 626
at Container->make('session.store', array()) in Application.php line 674
at Application->make('session.store') in Container.php line 1157
at Container->offsetGet('session.store') in HtmlServiceProvider.php line 51
at HtmlServiceProvider->Illuminate\Html\{closure}(object(Application)) in Container.php line 274
at Container->Illuminate\Container\{closure}(object(Application), array()) in Container.php line 733
at Container->build(object(Closure), array()) in Container.php line 626
at Container->make('form', array()) in Application.php line 674
at Application->make('form') in Container.php line 1157
at Container->offsetGet('form') in Facade.php line 149
at Facade::resolveFacadeInstance('form') in Facade.php line 118
at Facade::getFacadeRoot() in Facade.php line 203
at Facade::__callStatic('macro', array('single_file_upload', object(Closure))) in QiniuUploadProvider.php line 50
at FormFacade::macro('single_file_upload', object(Closure)) in QiniuUploadProvider.php line 50
at QiniuUploadProvider->singleFileUpload() in QiniuUploadProvider.php line 28
at QiniuUploadProvider->register() in Application.php line 531
at Application->register('Forone\Providers\QiniuUploadProvider') in ForoneServiceProvider.php line 76
at ForoneServiceProvider->registerProvider() in ForoneServiceProvider.php line 49
at ForoneServiceProvider->register() in Application.php line 531
at Application->register(object(ForoneServiceProvider)) in ProviderRepository.php line 74
at ProviderRepository->load(array('Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Routing\ControllerServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Encryption\EncryptionServiceProvider', 'Illuminate\Filesystem\FilesystemServiceProvider', 'Illuminate\Foundation\Providers\FoundationServiceProvider', 'Illuminate\Hashing\HashServiceProvider', 'Illuminate\Mail\MailServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider', 'Illuminate\Pipeline\PipelineServiceProvider', 'Illuminate\Queue\QueueServiceProvider', 'Illuminate\Redis\RedisServiceProvider', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'Illuminate\Session\SessionServiceProvider', 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'App\Providers\AppServiceProvider', 'App\Providers\AuthServiceProvider', 'App\Providers\EventServiceProvider', 'App\Providers\RouteServiceProvider', 'Forone\Providers\ForoneServiceProvider', 'Barryvdh\Debugbar\ServiceProvider', 'Overtrue\LaravelWechat\ServiceProvider')) in Application.php line 507
at Application->registerConfiguredProviders() in RegisterProviders.php line 17
at RegisterProviders->bootstrap(object(Application)) in Application.php line 203
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 222
at Kernel->bootstrap() in Kernel.php line 117
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 53
0 likes
8 replies
mani95lisa's avatar

It's caused by below function:

protected function registerFormBuilder()
    {
        $this->app->singleton('form', function ($app) {
            $form = new FormBuilder($app['html'], $app['url'], $app['session.store']->getToken());

            return $form->setSessionStore($app['session.store']);
        });
    }
bobbybouwmann's avatar

Aah there is a difference in the solution for Laravel 5.1 and 5.2. Make sure you have the same version number of the package as the laravel version you use!

mani95lisa's avatar
mani95lisa
OP
Best Answer
Level 2

I just fixed this bug, because I use it in register method, I should use it in boot method.

Please or to participate in this conversation.