WorkerMode.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace Config;
  3. /**
  4. * This configuration controls how CodeIgniter behaves when running
  5. * in worker mode (with FrankenPHP).
  6. */
  7. class WorkerMode
  8. {
  9. /**
  10. * Persistent Services
  11. *
  12. * List of service names that should persist across requests.
  13. * These services will NOT be reset between requests.
  14. *
  15. * Services not in this list will be reset for each request to prevent
  16. * state leakage.
  17. *
  18. * Recommended persistent services:
  19. * - `autoloader`: PSR-4 autoloading configuration
  20. * - `locator`: File locator
  21. * - `exceptions`: Exception handler
  22. * - `commands`: CLI commands registry
  23. * - `codeigniter`: Main application instance
  24. * - `superglobals`: Superglobals wrapper
  25. * - `routes`: Router configuration
  26. * - `cache`: Cache instance
  27. *
  28. * @var list<string>
  29. */
  30. public array $persistentServices = [
  31. 'autoloader',
  32. 'locator',
  33. 'exceptions',
  34. 'commands',
  35. 'codeigniter',
  36. 'superglobals',
  37. 'routes',
  38. 'cache',
  39. ];
  40. /**
  41. * Reset Event Listeners
  42. *
  43. * List of event names whose listeners should be removed between requests.
  44. * Use this if you register event listeners inside other event callbacks
  45. * (rather than at the top level of Config/Events.php), which would cause
  46. * them to accumulate across requests in worker mode.
  47. *
  48. * @var list<string>
  49. */
  50. public array $resetEventListeners = [];
  51. /**
  52. * Force Garbage Collection
  53. *
  54. * Whether to force garbage collection after each request.
  55. * Helps prevent memory leaks at a small performance cost.
  56. */
  57. public bool $forceGarbageCollection = true;
  58. }