Skip to content
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

Automatically disable FrankenPHP worker mode locally #931

Conversation

Radiergummi
Copy link

@Radiergummi Radiergummi commented Jul 24, 2024

This PR updates the FrankenPHP configuration to disable worker mode if the application is running in the local environment and the worker count is not specified explicitly (or set to auto).

The problem

FrankenPHP's Worker mode keeps the application in memory, which does wonders for performance when running in production. Locally, however, it causes problems with XDebug, and does not reflect file changes immediately. The solution to the latter is configuring Octane to restart the worker after every request, thereby defeating most of the advantages of an application server in the first place.

The solution

By only enabling worker mode if the application is running in a non-local environment, it will be served in a CGI-like manner, i.e. what the built-in PHP server (used in artisan serve) does—and exactly what you'd expect to happen: XDebug just works, and changes to files are reflected immediately.
In production, worker mode will be enabled and all the benefits that come with it apply. We use the setup as provided in this PR in our production application and don't face any issues with it.

This solves dunglas/frankenphp#931, and probably solves #928 too.

Copy link

Thanks for submitting a PR!

In order to review and merge PRs most efficiently, we require that all PRs grant maintainer edit access before we review them. For information on how to do this, see the relevant GitHub documentation. Additionally, GitHub doesn't allow maintainer permissions from organization accounts. Please resubmit this PR from a personal GitHub account with maintainer permissions enabled.

@github-actions github-actions bot closed this Jul 24, 2024
@Radiergummi Radiergummi deleted the matchory/disable-frankenphp-worker-mode-locally branch July 24, 2024 10:23
@miguno
Copy link

miguno commented Sep 7, 2024

@Radiergummi : I am running into the same issue as dunglas/frankenphp#931. What's the status of this PR? Was the issue fixed elsewhere in the meantime?

Edit: It seems there is an updated PR at #932.

@Radiergummi
Copy link
Author

@miguno that one's on me—it took me some time to implement some required changes—sorry. As soon as the updates have been reviewed, this should be working!

@miguno
Copy link

miguno commented Sep 7, 2024

No worries, thanks a lot for your work on fixing this problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants