@@ -76,6 +76,39 @@ public static function bootWeb(Paths $paths): int
7676 return EXIT_SUCCESS ;
7777 }
7878
79+ /**
80+ * Bootstrap for FrankenPHP worker mode.
81+ *
82+ * This method performs one-time initialization for worker mode,
83+ * loading everything except the CodeIgniter instance, which should
84+ * be created fresh for each request.
85+ *
86+ * @used-by `public/frankenphp-worker.php`
87+ */
88+ public static function bootWorker (Paths $ paths ): CodeIgniter
89+ {
90+ static ::definePathConstants ($ paths );
91+ if (! defined ('APP_NAMESPACE ' )) {
92+ static ::loadConstants ();
93+ }
94+ static ::checkMissingExtensions ();
95+
96+ static ::loadDotEnv ($ paths );
97+ static ::defineEnvironment ();
98+ static ::loadEnvironmentBootstrap ($ paths );
99+
100+ static ::loadCommonFunctions ();
101+ static ::loadAutoloader ();
102+ static ::setExceptionHandler ();
103+ static ::initializeKint ();
104+
105+ static ::checkOptimizationsForWorker ();
106+
107+ static ::autoloadHelpers ();
108+
109+ return Boot::initializeCodeIgniter ();
110+ }
111+
79112 /**
80113 * Used by command line scripts other than
81114 * * `spark`
@@ -333,6 +366,20 @@ protected static function checkMissingExtensions(): void
333366 exit (EXIT_ERROR );
334367 }
335368
369+ protected static function checkOptimizationsForWorker (): void
370+ {
371+ if (class_exists (Optimize::class)) {
372+ $ optimize = new Optimize ();
373+
374+ if ($ optimize ->configCacheEnabled || $ optimize ->locatorCacheEnabled ) {
375+ echo 'Optimization settings (configCacheEnabled, locatorCacheEnabled) '
376+ . 'must be disabled in Config\Optimize when running in Worker Mode. ' ;
377+
378+ exit (EXIT_ERROR );
379+ }
380+ }
381+ }
382+
336383 protected static function initializeKint (): void
337384 {
338385 service ('autoloader ' )->initializeKint (CI_DEBUG );
0 commit comments