hero

QueryPHP

High Performance PHP Progressive Coroutine Framework Engine.

Guide Of Design Ideas →

QueryPHP is a modern, high performance PHP progressive coroutine framework, we still focus on traditional PHP-FPM scenarios,with engineer user experience as its historical mission, let every PHP application have a good framework.
A hundred percent coverage of the unit tests to facing the bug,with our continuous commitment to creating high quality products for level level leevel,,with Swoole coroutine to improving business performance,now or in the future step by step.Our vision is USE LEEVEL WITH SWOOLE DO BETTER,let your business to support more user services.
Install
composer create-project hunzhiwange/queryphp myapp dev-master
php leevel server <Visite http://127.0.0.1:9527/>
HTTP Server
php leevel http:server # php leevel http:server -d
php leevel http:reload
php leevel http:stop
php leevel http:status
WebSocket Server
php leevel websocket:server # php leevel websocket:server -d
php leevel websocket:reload
php leevel websocket:stop
php leevel websocket:status
Go RoadRunner
/data/server/roadrunner-1.3.5-darwin-amd64/rr serve -d -v # -d = debug
/data/server/roadrunner-1.3.5-darwin-amd64/rr http:reset
/data/server/roadrunner-1.3.5-darwin-amd64/rr http:workers -i
MySQL Coroutine
<?php

declare(strict_types=1);

namespace App\App\Controller\Coroutine;

use App;

class Database
{
    public function handle(): string
    {
        go(function () {
            for ($i = 0; $i < 5; $i++) {
                go(function () {
                    // .env DATABASE_DRIVER = mysql or mysqlPool.
                    $result = App::make('database')->query('SELECT sleep(2)');
                    dump($result);
                });
            }
        });

        return 'Done';
    }
}
Redis Coroutine Channel
<?php

declare(strict_types=1);

namespace App\App\Controller\Coroutine;

use App;
use Swoole\Coroutine\Channel;

class Redis
{
    public function handle(): string
    {
        go(function () {
            $time = time();
            $chan = new Channel();

            for ($i = 0; $i < 5; $i++) {
                go(function () use ($chan, $i) {
                    // .env CACHE_DRIVER = redis or redisPool.
                    App::make('cache')->set('h'.$i, 'w');
                    $result = App::make('cache')->get('h'.$i);
                    $chan->push($result);
                    sleep(1);
                });
            }

            for ($i = 0; $i < 5; $i++) {
                $result = $chan->pop();
                dump($result);
            }

            dump('Time: '.(time() - $time));
        });

        return 'Done';
    }
}
Coroutine WaitGroup
<?php

declare(strict_types=1);

namespace App\App\Controller\Coroutine;

use Swoole\Coroutine\WaitGroup;

class WaitGroup
{
    public function handle(): string
    {
        go(function () {
            $result = [];
            $time = time();
            $wg = new WaitGroup();

            $wg->add();
            go(function () use ($wg, &$result) {
                $result['k1'] = 'coroutine 1';
                sleep(1);
                $wg->done();
            });

            $wg->add();
            go(function () use ($wg, &$result) {
                $result['k2'] = 'coroutine 2';
                sleep(2);
                $wg->done();
            });

            $wg->wait();

            foreach ($result as $k => $v) {
                dump($k);
                dump($v);
            }

            dump('Time: '.(time() - $time));
        });

        return 'Done';
    }
}

Query the endless software world

is complex enough

But yet

This is not what we want

We just want to write code

simply and happily

Framework Ideas

A sense of mission worth entrusting,let every PHP application have a good framework.

Component System

The core of the framework is composed of independent high cohesion and low coupling components, which can easily access existing systems without intrusion.

Router System

The framework provides MVC automatic routing and can intelligently parse Restful requests and swagger-php annotated routing based on OpenApi 3.0 specification,Documentation and routing are done in one step.

Overall Solution

The framework provides a large number of built-in functions from caching, Session, IOC container, template engine, Ddd ORM, and provides a Symfony Console command line toolkit.

Framework Core Resident

Based on Zephir, we developed a C-extended version of the core components of the whole system, which is fully consistent with the functions of PHP and can double the performance without modifying any code.

Business Coroutine

New coroutine programming mode based on Swoole 4 makes business performance better,our vision is a small amount of code modification or no modification,let your business to support more user services.

Warning

QueryPHP requires PHP >= 7.3.2.