3 ms·
In typical PHP applications, the entire application is bootstraped, executed and teared down for every request. RoadRunner lets you run "workers" (php processe
by kilburn 8y ago
In typical PHP applications, the entire application is bootstraped, executed and teared down for every request.
RoadRunner lets you run "workers" (php processes) that perform all the bootstrapping just once, and then receive-process-reply to requests. The use case is to avoid the (possibly expensive, especially with modern frameworks) bootstrapping for every request.
Check the symfony integration example for instance [1]. Everything that's outside of the
while ($req = $psr7->acceptRequest()) {
...
}
is usually run for every request in traditional PHP, whereas here it is only run once when initializing the worker and then that while block reads/executes/replies to each specific request.
The problem with this approach is that you now need to be careful not to leave unwanted stuff behind (open files / db connections, static $properties, etc.) that may interfere with future requests, whereas this just isn't possible in "normal" PHP. I would argue that this is one of the features that makes PHP so beginner-friendly.
[1] https://github.com/spiral/roadrunner/wiki/Symfony-Framework https://github.com/spiral/roadrunner/wiki/Symfony-Framework
- rajangdavis 8y agoGot it. Thanks for the explanation!