Add loop mode (-L) in the CLI SAPI#2
Open
mnapoli wants to merge 7 commits into
Open
Conversation
This was referenced Dec 7, 2018
|
This is ironically funny that the PHP Internal Server is limited 1 request at a time (no support for parallel request) but AWS Lambda has the exact same limitation, which makes it an aligned match! |
|
how to exit? |
Owner
Author
|
@determin1st you can't. Just like you can't "exit" the whole PHP-FPM process when running inside a PHP-FPM worker. |
i need to exit. https://github.com/determin1st/sm-bot/blob/c162330e92219b5c71373b21b59ddade8aaa5bb2/start.bat#L18 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a pull request that I opened in my own fork to preview the diff and allow code review.
This PR adds a new "Loop" mode that can be used with
-L. For example:php -L script.php.This mode runs the script in a loop.
The big difference with doing a
while(true) {}loop in PHP is that every execution of the script is isolated from the other executions.It's basically a clone of the PHP-FPM (worker) behavior for CLI.
Use cases
php -Leach event/request would be processed in an isolated PHP environment without having the overhead of starting a new process: see Scenario G: custom PHP SAPI bref-bootstrap-benchmarks#14Yes! It's very similar. Here is a comparison:
Example
Before:
With the "loop mode":
Understanding how it works
This is pseudo code of the new
-Lmode: