Bootstrap allows other businesses to be initialized before the framework is initialized

This event was added after version 3.2.5

In the easyswoole startup script file that is generated after installation:

The bootstrap.php file in the application root directory will be automatically determined,If there is,Load。

So we can create this file in the application root directory and execute the initialization business code we want:Such as register command line support, global general functions and other functions。


use EasySwoole\EasySwoole\Command\CommandRunner;

defined('IN_PHAR') or define('IN_PHAR', boolval(\Phar::running(false)));
defined('RUNNING_ROOT') or define('RUNNING_ROOT', realpath(getcwd()));
defined('EASYSWOOLE_ROOT') or define('EASYSWOOLE_ROOT', IN_PHAR ? \Phar::running() : realpath(getcwd()));

$file = EASYSWOOLE_ROOT.'/vendor/autoload.php';
if (file_exists($file)) {
    require $file;
    die("include composer autoload.php fail\n");

    require_once EASYSWOOLE_ROOT.'/bootstrap.php';

$args = $argv;
//trim first command
$ret = CommandRunner::getInstance()->run($args);
    echo $ret."\n";

f you are an old swoole upgrade, you will need to delete the '/easyswoole' file.

Then again PHP/vendor/easyswoole/easyswoole/bin/easyswoole install installation(Report errors or other reasons.Please review the framework installation section to perform the installation steps)

can use the bootstrap event

Call the coroutine API before starting

use Swoole\Coroutine\Scheduler;
$scheduler = new Scheduler();
$scheduler->add(function() {
    /*  Call the coroutine API */
//Clear all timers