{"record":{"id":"b1c1aab5f54cb9e5","repo":"laravel/framework","slug":"your-configuration-files-are-not-serializable","errorCode":null,"errorMessage":"Your configuration files are not serializable.","messagePattern":"Your configuration files are not serializable\\.","errorType":"console","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Foundation/Console/ConfigCacheCommand.php","lineNumber":81,"sourceCode":"\n        $this->files->put(\n            $configPath, '<?php return '.var_export($config, true).';'.PHP_EOL\n        );\n\n        try {\n            require $configPath;\n        } catch (Throwable $e) {\n            $this->files->delete($configPath);\n\n            foreach (Arr::dot($config) as $key => $value) {\n                try {\n                    eval(var_export($value, true).';');\n                } catch (Throwable $e) {\n                    throw new LogicException(\"Your configuration files could not be serialized because the value at \\\"{$key}\\\" is non-serializable.\", 0, $e);\n                }\n            }\n\n            throw new LogicException('Your configuration files are not serializable.', 0, $e);\n        }\n\n        $this->components->info('Configuration cached successfully.');\n    }\n\n    /**\n     * Boot a fresh copy of the application configuration.\n     *\n     * @return array\n     */\n    protected function getFreshConfiguration()\n    {\n        $app = require $this->laravel->bootstrapPath('app.php');\n\n        $app->useStoragePath($this->laravel->storagePath());\n\n        $app->make(ConsoleKernelContract::class)->bootstrap();\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/laravel/framework/blob/deac04fbdcd7443aff45a7bc6767a6729169bba3/src/Illuminate/Foundation/Console/ConfigCacheCommand.php#L63-L99","documentation":"Thrown by ConfigCacheCommand::handle() during config:cache as a fallback LogicException when the cached config file fails to require() AND no single dotted key could be isolated as the culprit (the per-key eval loop didn't itself throw). It is the generic 'your config isn't serializable' error, raised with the original load exception chained, when the more specific per-key message (error 294) couldn't be produced.","triggerScenarios":"Running config:cache; the var_export()'d config file fails to load on require, but iterating and eval'ing each dotted value individually did not reproduce the failure. This can occur with values that fail only in combination, or due to opcache/autoload state differences between eval and require.","commonSituations":"Complex config with interdependent objects, values that reference classes unavailable at cache-build time, or autoload/ordering issues; rare edge case of the per-key detection in error 294.","solutions":["Examine the chained exception ($e) for the actual load error — it reveals which value/class failed.","Simplify config to plain serializable arrays/scalars and move dynamic logic out.","Ensure all classes referenced by config are autoloadable at cache time.","Clear and rebuild: php artisan config:clear then config:cache after fixing."],"exampleFix":"// before - object in config referencing a class missing at build time\n'driver' => new SomeDriver(),\n\n// after - reference by class name and instantiate in a provider\n'driver' => SomeDriver::class,","handlingStrategy":"validation","validationCode":"// Run a dry require of the var_export'd config to catch load failures\n$config = app('config')->all();\n$tmp = tempnam(sys_get_temp_dir(), 'cfg').'.php';\nfile_put_contents($tmp, '<?php return '.var_export($config, true).';');\ntry {\n    require $tmp;\n} catch (\\Throwable $e) {\n    throw new LogicException('Config not serializable: '.$e->getMessage(), 0, $e);\n} finally {\n    @unlink($tmp);\n}","typeGuard":"function configRoundTrips(): bool {\n    $config = app('config')->all();\n    $tmp = tempnam(sys_get_temp_dir(), 'cfg').'.php';\n    file_put_contents($tmp, '<?php return '.var_export($config, true).';');\n    try { require $tmp; return true; }\n    catch (\\Throwable) { return false; }\n    finally { @unlink($tmp); }\n}","tryCatchPattern":"try {\n    Artisan::call('config:cache');\n} catch (\\LogicException $e) {\n    // inspect chained $e->getPrevious() for the real load failure\n    report($e->getPrevious() ?? $e);\n}","preventionTips":["Ensure all config values are plain serializable scalars/arrays.","Make all classes referenced by config autoloadable at build time.","Run config:cache in CI/staging before production deploy.","Avoid referencing objects/resources in config."],"tags":["console","config-cache","serialization","deployment","config"],"analyzedSha":"deac04fbdcd7443aff45a7bc6767a6729169bba3","analyzedAt":"2026-08-06T23:23:39.652Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}