src/Command/AppCommand.php
public function check(Output $output): void
    {
        // Env check
        [$code, $return,] = Sys::run('php --ri swoole');
        $asyncRdsEnabled = $code === 0 ? \strpos($return, 'redis client => enabled') : false;

        $list = [
            "<bold>Runtime environment check</bold>\n",
            'PHP version is greater than 7.1?'    => self::wrap(\PHP_VERSION_ID > 70100, 'current is ' .
                \PHP_VERSION),
            'Swoole extension is installed?'      => self::wrap(\extension_loaded('swoole')),
            'Swoole version is greater than 4.3?' => self::wrap(\version_compare(\SWOOLE_VERSION, '4.3.0', '>='),
                'current is ' . \SWOOLE_VERSION),
            'Swoole async redis is enabled?'      => self::wrap($asyncRdsEnabled),
            'Swoole coroutine is enabled?'        => self::wrap(\class_exists('Swoole\Coroutine', false)),
            "\n<bold>Extensions that conflict with 'swoole'</bold>\n",
            // ' extensions'                             => 'installed',
            ' - zend'                             => self::wrap(!\extension_loaded('zend'),
                'Please disabled it, otherwise swoole will be affected!', true),
            ' - xdebug'                           => self::wrap(!\extension_loaded('xdebug'),
                'Please disabled it, otherwise swoole will be affected!', true),
            ' - xhprof'                           => self::wrap(!\extension_loaded('xhprof'),
                'Please disabled it, otherwise swoole will be affected!', true),
            ' - blackfire'                        => self::wrap(!\extension_loaded('blackfire'),
                'Please disabled it, otherwise swoole will be affected!', true),
        ];

        $buffer = [];
        $pass   = $total = 0;

        foreach ($list as $question => $value) {
            if (\is_int($question)) {
                $buffer[] = $value;
                continue;
            }

            $total++;

            if ($value[0]) {
                $pass++;
            }

            $question = \str_pad($question, 45);
            $buffer[] = \sprintf('  <comment>%s</comment> %s', $question, $value[1]);
        }

        $buffer[] = "\nCheck total: <bold>$total</bold>, Pass the check: <success>$pass</success>";

        $output->writeln($buffer);
    }
public function check(Output $output): void
    {
        // Env check
        [$code, $return,] = Sys::run('php --ri swoole');
        $asyncRdsEnabled = $code === 0 ? \strpos($return, 'redis client => enabled') : false;

        $list = [
            "<bold>Runtime environment check</bold>\n",
            'PHP version is greater than 7.1?'    => self::wrap(\PHP_VERSION_ID > 70100, 'current is ' .
                \PHP_VERSION),
            'Swoole extension is installed?'      => self::wrap(\extension_loaded('swoole')),
            'Swoole version is greater than 4.3?' => self::wrap(\version_compare(\SWOOLE_VERSION, '4.3.0', '>='),
                'current is ' . \SWOOLE_VERSION),
            'Swoole async redis is enabled?'      => self::wrap($asyncRdsEnabled),
            'Swoole coroutine is enabled?'        => self::wrap(\class_exists('Swoole\Coroutine', false)),
            "\n<bold>Extensions that conflict with 'swoole'</bold>\n",
            // ' extensions'                             => 'installed',
            ' - zend'                             => self::wrap(!\extension_loaded('zend'),
                'Please disabled it, otherwise swoole will be affected!', true),
            ' - xdebug'                           => self::wrap(!\extension_loaded('xdebug'),
                'Please disabled it, otherwise swoole will be affected!', true),
            ' - xhprof'                           => self::wrap(!\extension_loaded('xhprof'),
                'Please disabled it, otherwise swoole will be affected!', true),
            ' - blackfire'                        => self::wrap(!\extension_loaded('blackfire'),
                'Please disabled it, otherwise swoole will be affected!', true),
        ];

        $buffer = [];
        $pass   = $total = 0;

        foreach ($list as $question => $value) {
            if (\is_int($question)) {
                $buffer[] = $value;
                continue;
            }

            $total++;

            if ($value[0]) {
                $pass++;
            }

            $question = \str_pad($question, 45);
            $buffer[] = \sprintf('  <comment>%s</comment> %s', $question, $value[1]);
        }

        $buffer[] = "\nCheck total: <bold>$total</bold>, Pass the check: <success>$pass</success>";

        $output->writeln($buffer);
    }
public function check ( Output $ output ) : void { // Env check [ $ code , $ return , ] = Sys :: run ( 'php --ri swoole' ) ; $ asyncRdsEnabled = $ code === 0 ? \ strpos ( $ return , 'redis client => enabled' ) : false ; $ list = [ "<bold>Runtime environment check</bold>\n" , 'PHP version is greater than 7.1?' => self :: wrap ( \ PHP_VERSION_ID > 70100 , 'current is ' . \ PHP_VERSION ) , 'Swoole extension is installed?' => self :: wrap ( \ extension_loaded ( 'swoole' ) ) , 'Swoole version is greater than 4.3?' => self :: wrap ( \ version_compare ( \ SWOOLE_VERSION , '4.3.0' , '>=' ) , 'current is ' . \ SWOOLE_VERSION ) , 'Swoole async redis is enabled?' => self :: wrap ( $ asyncRdsEnabled ) , 'Swoole coroutine is enabled?' => self :: wrap ( \ class_exists ( 'Swoole\Coroutine' , false ) ) , "\n<bold>Extensions that conflict with 'swoole'</bold>\n" , // ' extensions'                             => 'installed', ' - zend' => self :: wrap ( ! \ extension_loaded ( 'zend' ) , 'Please disabled it, otherwise swoole will be affected!' , true ) , ' - xdebug' => self :: wrap ( ! \ extension_loaded ( 'xdebug' ) , 'Please disabled it, otherwise swoole will be affected!' , true ) , ' - xhprof' => self :: wrap ( ! \ extension_loaded ( 'xhprof' ) , 'Please disabled it, otherwise swoole will be affected!' , true ) , ' - blackfire' => self :: wrap ( ! \ extension_loaded ( 'blackfire' ) , 'Please disabled it, otherwise swoole will be affected!' , true ) , ] ; $ buffer = [ ] ; $ pass = $ total = 0 ; foreach ( $ list as $ question => $ value ) { if ( \ is_int ( $ question ) ) { $ buffer [ ] = $ value ; continue ; } $ total ++ ; if ( $ value [ 0 ] ) { $ pass ++ ; } $ question = \ str_pad ( $ question , 45 ) ; $ buffer [ ] = \ sprintf ( '  <comment>%s</comment> %s' , $ question , $ value [ 1 ] ) ; } $ buffer [ ] = "\nCheck total: <bold>$total</bold>, Pass the check: <success>$pass</success>" ; $ output -> writeln ( $ buffer ) ; }
Check current operating environment information

@CommandMapping()
@param Output $output

@throws \RuntimeException
Check current operating environment information