|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Config; |
| 4 | + |
| 5 | +/** |
| 6 | + * This configuration controls how CodeIgniter behaves when running |
| 7 | + * in worker mode (with FrankenPHP). |
| 8 | + */ |
| 9 | +class WorkerMode |
| 10 | +{ |
| 11 | + /** |
| 12 | + * Persistent Services |
| 13 | + * |
| 14 | + * List of service names that should persist across requests. |
| 15 | + * These services will NOT be reset between requests. |
| 16 | + * |
| 17 | + * Services not in this list will be reset for each request to prevent |
| 18 | + * state leakage. |
| 19 | + * |
| 20 | + * Recommended persistent services: |
| 21 | + * - `autoloader`: PSR-4 autoloading configuration |
| 22 | + * - `locator`: File locator |
| 23 | + * - `exceptions`: Exception handler |
| 24 | + * - `logger`: Logger instance |
| 25 | + * - `timer`: Performance timer |
| 26 | + * - `commands`: CLI commands registry |
| 27 | + * - `codeigniter`: Main application instance |
| 28 | + * - `superglobals`: Superglobals wrapper |
| 29 | + * |
| 30 | + * @var list<string> |
| 31 | + */ |
| 32 | + public array $persistentServices = [ |
| 33 | + 'autoloader', |
| 34 | + 'locator', |
| 35 | + 'exceptions', |
| 36 | + 'logger', |
| 37 | + 'timer', |
| 38 | + 'commands', |
| 39 | + 'codeigniter', |
| 40 | + 'superglobals', |
| 41 | + ]; |
| 42 | + |
| 43 | + /** |
| 44 | + * Database connection strategy |
| 45 | + * |
| 46 | + * Determines how database connections are handled between requests: |
| 47 | + * |
| 48 | + * - 'keep-alive' (recommended): |
| 49 | + * Keeps connections alive across requests for best performance |
| 50 | + * - 'disconnect': |
| 51 | + * Closes all connections after each request |
| 52 | + * |
| 53 | + * @var 'keep-alive'|'disconnect' |
| 54 | + */ |
| 55 | + public string $databaseStrategy = 'keep-alive'; |
| 56 | + |
| 57 | + /** |
| 58 | + * Cache handler strategy |
| 59 | + * |
| 60 | + * Determines how cache handlers are managed between requests: |
| 61 | + * |
| 62 | + * - 'keep-alive' (recommended): |
| 63 | + * Keeps cache handler alive across requests for best performance |
| 64 | + * - 'disconnect': |
| 65 | + * Closes the handler after each request |
| 66 | + * |
| 67 | + * @var 'keep-alive'|'disconnect' |
| 68 | + */ |
| 69 | + public string $cacheStrategy = 'keep-alive'; |
| 70 | + |
| 71 | + /** |
| 72 | + * Reset Factories |
| 73 | + * |
| 74 | + * Whether to reset Factories (Models, etc.) between requests. |
| 75 | + * Set to false if you want to cache model instances across requests. |
| 76 | + */ |
| 77 | + public bool $resetFactories = true; |
| 78 | + |
| 79 | + /** |
| 80 | + * Garbage Collection |
| 81 | + * |
| 82 | + * Whether to force garbage collection after each request. |
| 83 | + * Helps prevent memory leaks at a small performance cost. |
| 84 | + */ |
| 85 | + public bool $garbageCollection = true; |
| 86 | +} |
0 commit comments