Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shahr's avatar
Level 10

Error::("Call to undefined method Closure::__set_state()")

 LogicException 

  Your configuration files are not serializable.

  at C:\xampp\htdocs\projects\borujerd\selda\vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigCacheCommand.php:84
     80▕             require $configPath;
     81▕         } catch (Throwable $e) {
     82▕             $this->files->delete($configPath);
     83▕
  ➜  84▕             throw new LogicException('Your configuration files are not serializable.', 0, $e);
     85▕         }
     86▕
     87▕         $this->components->info('Configuration cached successfully.');
     88▕     }

  1   C:\xampp\htdocs\projects\borujerd\selda\bootstrap\cache\config.php:701
      Error::("Call to undefined method Closure::__set_state()")

  2   C:\xampp\htdocs\projects\borujerd\selda\vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigCacheCommand.php:80
      require()

What is this error and what's the solution?

0 likes
1 reply
LaryAI's avatar
Level 58

This error occurs when a closure is used in a configuration file that is being cached. Closures cannot be serialized, so they cannot be cached. To fix this error, remove any closures from your configuration files or move them to a separate file that is not being cached.

Example:

// Bad configuration file with a closure
return [
    'key' => function () {
        return 'value';
    },
];

// Good configuration file without a closure
return [
    'key' => 'value',
];
1 like

Please or to participate in this conversation.