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

Garet's avatar
Level 3

Cannot cache config, Your configuration files are not serializable

I have one Laravel project and when in production when I do:

php artisan config:cache

I get the following error:

Your configuration files are not serializable

I read that this is often down to callbacks being done in a configuration file, but I have double checked and there are no callbacks in my configuration files!

The full error is below. It makes reference to ConfigCacheCommand.php and Macroable.php, but these appear to be standard framework files.

Your configuration files are not serializable.

  at xxx\vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigCacheCommand.php:71
    67|             require $configPath;
    68|         } catch (Throwable $e) {
    69|             $this->files->delete($configPath);
    70|
 > 71|             throw new LogicException('Your configuration files are not serializable.', 0, $e);
    72|         }
    73|
    74|         $this->info('Configuration cached successfully!');
    75|     }

  Exception trace:

  1   BadMethodCallException::("Method Illuminate\Support\Collection::__set_state does not exist.")
      xxx\vendor\laravel\framework\src\Illuminate\Support\Traits\Macroable.php:77

  2   Illuminate\Support\Collection::__callStatic("__set_state")
      xxx\bootstrap\cache\config.php:832

  Please use the argument -v to see more details.
0 likes
6 replies
Jaytee's avatar

Could also be caused by a third-party package that uses closures in their config. Check your packages.

Garet's avatar
Level 3

Thanks, I've only installed 2 extra things in the vendor directory, and neither of them have config files that use closures :-(

Sinnbeck's avatar

Did you try running it with the -v argument as suggested, to get more information?

Sinnbeck's avatar

Great. What was the error then? A closure somewhere?

Garet's avatar
Level 3

Yes it was, in my own code :-s I fixed it now :-)

Please or to participate in this conversation.