0

Is there any way (e.g. with php-fpm) to preload a php script? We use Zend Framework and Doctrine and the initialization of the frameworks takes its time (even with opcache and apcu).

So instead of initializing the framework when a HTTP request comes in, php-fpm could start a worker with our php script that halts on a certain point and keeps everything in memory until a request comes in at which point the process will resume with the $_GET, $_POST etc. data injected.

Or alternatively, is there a way of reusing a php script for multiple requests?

Is this at all a thing being done by other companies working with php or do we need to focus even more on caching of php files and other parts of our application?

eisbehr
  • 12,243
  • 7
  • 38
  • 63
  • op_cache maybe? – Unamata Sanatarai Dec 07 '18 at 07:20
  • Do you mean thinks like [OPCache](http://php.net/manual/en/book.opcache.php)? For DB connection you could try persistend connections. But this has some downsides too. – eisbehr Dec 07 '18 at 07:21
  • Ahh sorry, you noted opcache. Maybe you need to tell us more about the problem, because if you project is still slow, there might be other things. – eisbehr Dec 07 '18 at 07:25

1 Answers1

0

Preloading functionality will be part of PHP7.4 which will be out in december 2019 (might change). At the moment the best PHP has out of the box is the opcache which already brings a lot of performance.

Some information on how it will work can be found in the RFC. https://wiki.php.net/rfc/preload

Stephan Muggli
  • 317
  • 4
  • 10