Framework: config:cache command crashes on closures

Created on 14 Jul 2015  路  3Comments  路  Source: laravel/framework

I have a third party package that uses a closure in its configuration (dingo/api), unfortunately that prevents me from using the config:cache command as this crashes the whole application with no friendly error message nor way to recover from it besides manually deleting the config cache:

PHP Fatal error:  Call to undefined method Closure::__set_state() in /Users/anahkiasen/config-closures/bootstrap/cache/config.php on line 22
PHP Stack trace:
PHP   1. {main}() /Users/anahkiasen/config-closures/artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /Users/anahkiasen/config-closures/artisan:36
PHP   3. Illuminate\Foundation\Console\Kernel->bootstrap() /Users/anahkiasen/config-closures/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:96
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /Users/anahkiasen/config-closures/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:196
PHP   5. Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap() /Users/anahkiasen/config-closures/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:203
PHP   6. require() /Users/anahkiasen/config-closures/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php:27

Fatal error: Call to undefined method Closure::__set_state() in /Users/anahkiasen/config-closures/bootstrap/cache/config.php on line 22

And the faulty part in the cached configuration file:

    array (
      'oauth' => 
      Closure::__set_state(array(
      )),
    ),

Shouldn't Laravel leverage serializable closures here?

Most helpful comment

Any solution to this ? config:cache is unusable right now

All 3 comments

This has come up before. We don't support closures on purpose because the overhead of unserializing is greater than anything gained otherwise.

Any config system that contain closures is badly designed.

Any solution to this ? config:cache is unusable right now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iivanov2 picture iivanov2  路  3Comments

jackmu95 picture jackmu95  路  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments

felixsanz picture felixsanz  路  3Comments