Some Swoole frameworks are slow to boot, especially when mounted on a network hard drive.

I suspect that because Swoole allows PHP applications to live in memory, there are a lot of files to scan and load at startup, which is probably the culprit.

Imi framework


Using Phar for file enumeration, reading, and including, whether on a local hard disk or a network file sharing mount such as Samba, provides better performance than fragmented files.

Phar is powerful enough to deploy projects directly from a package, but phar isn’t really popular in traditional PHP application development because it doesn’t offer much benefit. In the Swoole environment, more and more frameworks support resident memory, which loads all the files you want at startup.

Phar has built-in support since PHP 5.3.0, so compatibility is not a concern and you don’t need to install additional extensions.

Gitee.com/yurunsoft/P…

Interested friends can pull down, run yourself try.

To enable Phar file packaging, first configure phar.readonly = Off in php.ini

The Phar packaging code is mainly as follows:

<? php $fileName = __DIR__ . '/test/test.phar'; if(is_file($fileName)) { unlink($fileName); } $phar = new Phar($fileName); $phar->stopBuffering(); $phar->buildFromDirectory(__DIR__ . '/src');Copy the code

The actual application situation is complicated, you can refer to the OFFICIAL PHP document and make some modifications according to the actual situation.