Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception due to closure in config when using artisan config:cache #147

Closed
developerdino opened this issue Jun 10, 2015 · 7 comments
Closed

Comments

@developerdino
Copy link

When caching the laravel config via artisan cache:config command I am getting errors due to laravel not supporting closures in the config cache.

PHP Fatal error:  Call to undefined method Closure::__set_state() in /home/vagrant/Code/my-api/bootstrap/cache/config.php on line 264
PHP Stack trace:
PHP   1. {main}() /home/vagrant/Code/my-api/artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /home/vagrant/Code/my-api/artisan:36
PHP   3. Illuminate\Foundation\Console\Kernel->bootstrap() /home/vagrant/Code/my-api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:92
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /home/vagrant/Code/my-api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:192
PHP   5. Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap() /home/vagrant/Code/my-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:194
PHP   6. require() /home/vagrant/Code/my-api/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php:27

config/jwt.php is the standard one in the documentation and fails on the lines https://github.com/tymondesigns/jwt-auth/blob/laravel-5/src/config/config.php#L149-L151 and https://github.com/tymondesigns/jwt-auth/blob/laravel-5/src/config/config.php#L162-L164

Cached config for jwt section:
241    'jwt' =>
242        array (
243            'secret' => 'SomeRandomString',
244            'ttl' => 60,
245            'refresh_ttl' => 20160,
246            'algo' => 'HS256',
247            'user' => 'App\\User',
248            'identifier' => 'id',
249            'required_claims' =>
250                array (
251                    0 => 'iss',
252                    1 => 'iat',
253                    2 => 'exp',
254                    3 => 'nbf',
255                    4 => 'sub',
256                    5 => 'jti',
257                ),
258            'blacklist_enabled' => true,
259            'providers' =>
260                array (
261                    'user' => 'Tymon\\JWTAuth\\Providers\\User\\EloquentUserAdapter',
262                    'jwt' => 'Tymon\\JWTAuth\\Providers\\JWT\\NamshiAdapter',
263                    'auth' =>
264                        Closure::__set_state(array(
265                        )),
266                    'storage' =>
267                        Closure::__set_state(array(
268                        )),
269                ),
270        ),

Using Laravel 5.1 - not sure if the same issue exists in Laravel 5.0.

It seems that this is an issue with other projects that use this technique for the config - efficiently/authority-controller#27

Is there an updated config that you suggest which doesn't use closures in the config?

Thanks

@tymondesigns
Copy link
Owner

If you are not customizing the providers then you can simply pass a class path as a string and laravel's iOC will build the instance

@tymondesigns
Copy link
Owner

Going to look at adding closure serialization via SuperClosure or similar

@tymondesigns
Copy link
Owner

Switching to using string namespace paths for now. I think this may be resolved on the Laravel side.

@hilnius
Copy link

hilnius commented Jul 21, 2015

I'm having this error. Ways to fix ?

@developerdino
Copy link
Author

@hilnius you just need to replace your config/jwt.php with what is in the develop branch here https://github.com/tymondesigns/jwt-auth/blob/develop/config/config.php#L113-L148 and that fixes the issue.

Edit: you'll need to export the jwt config first if you habvn't done it yet using php artisan vendor:publish

@jadjoubran
Copy link

Graham mentioned that they will not fix it
laravel/framework#9625

@hilnius
Copy link

hilnius commented Aug 10, 2015

@mofodojodino 's answer actually fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants