-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add loop mode (-L
) in the CLI SAPI
#2
base: PHP-7.2
Are you sure you want to change the base?
Conversation
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? |
@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 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 -L
each 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
-L
mode: