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

mcadio's avatar

Files are not serializable

I pulled my changes to the server and ran php artisan config:cache and it cleared but gave me this message. I don't know how to fix it. Can someone please help me understand what this means?

Your configuration files are not serializable.

  at 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▕     }

  1   bootstrap/cache/config.php:965
      Error::("Call to undefined method Closure::__set_state()")

      +14 vendor frames 
  16  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
0 likes
16 replies
tykus's avatar

Are you doing something funky in any of your config files (rather than key/values pairs or reading env variables) - Eloquent queries, Closures etc.?

mcadio's avatar

I don't know. So I need to go through any files in the config folder? This is what I got when I ran --verbose



  1   bootstrap/cache/config.php:965
      Error::("Call to undefined method Closure::__set_state()")

  2   vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php:67
      require()

  3   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
      Illuminate\Foundation\Console\ConfigCacheCommand::handle()

  4   vendor/laravel/framework/src/Illuminate/Container/Util.php:40
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

  5   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
      Illuminate\Container\Util::unwrapIfClosure()

  6   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
      Illuminate\Container\BoundMethod::callBoundMethod()

  7   vendor/laravel/framework/src/Illuminate/Container/Container.php:653
      Illuminate\Container\BoundMethod::call()

  8   vendor/laravel/framework/src/Illuminate/Console/Command.php:136
      Illuminate\Container\Container::call()

  9   vendor/symfony/console/Command/Command.php:298
      Illuminate\Console\Command::execute()

  10  vendor/laravel/framework/src/Illuminate/Console/Command.php:121
      Symfony\Component\Console\Command\Command::run()

  11  vendor/symfony/console/Application.php:1028
      Illuminate\Console\Command::run()

  12  vendor/symfony/console/Application.php:299
      Symfony\Component\Console\Application::doRunCommand()

  13  vendor/symfony/console/Application.php:171
      Symfony\Component\Console\Application::doRun()

  14  vendor/laravel/framework/src/Illuminate/Console/Application.php:94
      Symfony\Component\Console\Application::run()

  15  vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129
      Illuminate\Console\Application::run()

  16  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
tykus's avatar

Try searching the config directory for function word or fn for short-closure syntaax

mcadio's avatar

Like this? I have a well-known.php file and it has this in it:

'static' => [
        'security.txt' => fn () => response('Hello world.'),
    ],
mcadio's avatar
    "thinkverse/well-known": "^1.0",

Do I need this? Or is there a way to change it so it doesn't break things?

mcadio's avatar

I think I needed a well-known file for something, but I'm not sure what or why or if I need that.

tykus's avatar

@mcadio a (almost) year old package with only 89 installs 👀. One that will not allow you to cache your config...

Seriously, if you need /.well-known paths in your application, just add them to a routes file, or better a static directory.

mcadio's avatar

@tykus So I remove it and will get error messages telling me what routes are missing? Sorry, I'm pretty newb here.

tykus's avatar

@mcadio I don't know why you need them at all - it looks like nothing is configured currently. A static security.txt file that returns Hello World is hardly useful.

mcadio's avatar

@tykus Removing that package solved the problem. I just don't know what I broke in the process. Thanks!

tykus's avatar

@mcadio were you intending to validate a domain for a SSL certificate maybe???

mcadio's avatar

@tykus That's a possibility. I do have email through another provider, and I also use google my business and analytics. There was something I needed to verify using well-known and I didn't know how to do it so I used that package. My nginx files are blocking well-known, though, so... ? If I need to later learn how to write a route cause something is failing, I'll be back!

thinkverse's avatar
Level 15

@mcadio your nginx configuration might be configured to hide dotfiles, this is good as it prevents access to files beginning with a dot, like .git, .svn, .htaccess, and so on. You'll want to still do that but allow incoming requests to .well-known.

The following location directive should do just that, add that in your server directive and restart nginx. You might have to hunt down the location directive that blocks dotfiles first and remove it.

location ~ /\.(?!well-known) {
	deny all;
}
1 like
thinkverse's avatar

@tykus I agree that it's not useful, it's an example though showcasing you can return a response via the config. The config is meant to be updated to fit your own needs.

@mcadio Thank you for finding the serialization issue, didn't realize Laravel cannot serialize closures since I don't cache my configs normally. Thought Laravel could serialize closures. I do agree with @tykus though, it's better to add /.well-known in your own routes.

I created that package almost a year ago on a whim and didn't really think too much about it and never really found a good use for it so I've just let it sit, I'll deprecate it since I don't actually see a use for it anymore. 🙂

1 like

Please or to participate in this conversation.