-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: FrankenPHP Worker Mode #9889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
michalsn
wants to merge
17
commits into
codeigniter4:4.7
Choose a base branch
from
michalsn:worker-mode
base: 4.7
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,885
−107
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a47b7de
wip
michalsn afe79f7
wip
michalsn 21d8397
wip
michalsn 5fb59eb
wip
michalsn a106259
wip
michalsn cff3785
wip
michalsn 245d03f
wip
michalsn 5387ff8
wip
michalsn 6a719c6
wip
michalsn d970cfd
wip
michalsn 71760f6
wip
michalsn c97febd
wip
michalsn 52af1ba
wip
michalsn d30bb21
wip
michalsn 3513359
wip
michalsn 5af8efd
wip
michalsn aef426e
apply code suggestions
michalsn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <?php | ||
|
|
||
| namespace Config; | ||
|
|
||
| /** | ||
| * This configuration controls how CodeIgniter behaves when running | ||
| * in worker mode (with FrankenPHP). | ||
| */ | ||
| class WorkerMode | ||
| { | ||
| /** | ||
| * Persistent Services | ||
| * | ||
| * List of service names that should persist across requests. | ||
| * These services will NOT be reset between requests. | ||
| * | ||
| * Services not in this list will be reset for each request to prevent | ||
| * state leakage. | ||
| * | ||
| * Recommended persistent services: | ||
| * - `autoloader`: PSR-4 autoloading configuration | ||
| * - `locator`: File locator | ||
| * - `exceptions`: Exception handler | ||
| * - `commands`: CLI commands registry | ||
| * - `codeigniter`: Main application instance | ||
| * - `superglobals`: Superglobals wrapper | ||
| * - `routes`: Router configuration | ||
| * - `cache`: Cache instance | ||
| * | ||
| * @var list<string> | ||
| */ | ||
| public array $persistentServices = [ | ||
| 'autoloader', | ||
| 'locator', | ||
| 'exceptions', | ||
| 'commands', | ||
| 'codeigniter', | ||
| 'superglobals', | ||
| 'routes', | ||
| 'cache', | ||
| ]; | ||
|
|
||
| /** | ||
| * Force Garbage Collection | ||
| * | ||
| * Whether to force garbage collection after each request. | ||
| * Helps prevent memory leaks at a small performance cost. | ||
| */ | ||
| public bool $forceGarbageCollection = true; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # CodeIgniter 4 - FrankenPHP Worker Mode Configuration | ||
| # | ||
| # This Caddyfile configures FrankenPHP to run CodeIgniter in worker mode. | ||
| # Adjust settings based on your server resources and application needs. | ||
| # | ||
| # Start with: frankenphp run | ||
|
|
||
| { | ||
| # FrankenPHP worker configuration | ||
| frankenphp { | ||
| # Worker configuration | ||
| worker { | ||
| # Path to the worker file | ||
| file public/frankenphp-worker.php | ||
|
|
||
| # Number of workers (default: 2x CPU cores) | ||
| # Adjust based on your server capacity | ||
| # num 16 | ||
| } | ||
| } | ||
|
|
||
| # Disable admin API (recommended for production) | ||
| admin off | ||
| } | ||
|
|
||
| # HTTP server configuration | ||
| :8080 { | ||
| # Document root | ||
| root * public | ||
|
|
||
| # Enable compression | ||
| encode zstd br gzip | ||
|
|
||
| # Route all PHP requests through the worker | ||
| php_server { | ||
| # Route all requests through the worker | ||
| try_files {path} frankenphp-worker.php | ||
| } | ||
|
|
||
| # Serve static files | ||
| file_server | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this config need to extend
BaseConfig?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind that these values will change in Registrars and env.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't think so. Although overrides from the
.envfile might be acceptable in theory, allowingRegistrarswould be misleading, as the values are only used once and not on a per-request basis. I would rather leave it as it is.