Forráskód Böngészése

Add Hyperf v1.0 (#4993)

* Add Hyperf

* Revert

* Update composer.json

* Translate Readme.md

* Removed useless files

* Optimized

* Optimized

* Add gitignore

* Update the timezone to America/Los_Angeles

* Remove apk update

* Add missing files

* Removed all useless files
黄朝晖 6 éve
szülő
commit
9725161287

+ 1 - 1
.travis.yml

@@ -101,7 +101,7 @@ env:
     - "TESTLANG=Perl"
     - 'TESTDIR="PHP/php"'
     - 'TESTDIR="PHP/cakephp PHP/codeigniter PHP/fat-free PHP/fuel PHP/kumbiaphp PHP/phpixie PHP/slim PHP/symfony PHP/yii2 PHP/zend"'
-    - 'TESTDIR="PHP/amp PHP/hamlet PHP/laravel PHP/lumen PHP/hhvm PHP/peachpie PHP/swoole PHP/workerman PHP/phalcon PHP/ubiquity"'
+    - 'TESTDIR="PHP/amp PHP/hamlet PHP/laravel PHP/lumen PHP/hhvm PHP/peachpie PHP/swoole PHP/workerman PHP/phalcon PHP/ubiquity PHP/hyperf"'
     - 'TESTDIR="Python/aiohttp Python/api_hour Python/blacksheep Python/bottle Python/cherrypy Python/django Python/eve Python/falcon Python/fastapi Python/flask"'
     - 'TESTDIR="Python/hug Python/japronto Python/klein Python/morepath Python/pyramid Python/quart Python/responder Python/sanic Python/spyne Python/starlette"'
     - 'TESTDIR="Python/tornado Python/turbogears Python/uvicorn Python/uwsgi Python/vibora Python/web2py Python/webware Python/weppy Python/wsgi"'

+ 16 - 0
frameworks/PHP/hyperf/.env

@@ -0,0 +1,16 @@
+APP_NAME=skeleton
+
+DB_DRIVER=mysql
+DB_HOST=tfb-database
+DB_PORT=3306
+DB_DATABASE=hello_world
+DB_USERNAME=benchmarkdbuser
+DB_PASSWORD=benchmarkdbpass
+DB_CHARSET=utf8mb4
+DB_COLLATION=utf8mb4_unicode_ci
+DB_PREFIX=
+
+REDIS_HOST=localhost
+REDIS_AUTH=
+REDIS_PORT=6379
+REDIS_DB=0

+ 12 - 0
frameworks/PHP/hyperf/.gitignore

@@ -0,0 +1,12 @@
+.buildpath
+.settings/
+.project
+*.patch
+.idea/
+.git/
+runtime/
+vendor/
+.phpintel/
+.DS_Store
+*.lock
+.phpunit*

+ 30 - 0
frameworks/PHP/hyperf/README.md

@@ -0,0 +1,30 @@
+English | [中文](./README-CN.md)
+
+[![Build Status](https://travis-ci.org/hyperf-cloud/hyperf.svg?branch=master)](https://travis-ci.org/hyperf-cloud/hyperf)
+[![Php Version](https://img.shields.io/badge/php-%3E=7.2-brightgreen.svg?maxAge=2592000)](https://secure.php.net/)
+[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.3.3-brightgreen.svg?maxAge=2592000)](https://github.com/swoole/swoole-src)
+[![Hyperf License](https://img.shields.io/github/license/hyperf-cloud/hyperf.svg?maxAge=2592000)](https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE.md)
+
+# Introduction
+
+Hyperf is a high-performance, highly flexible PHP CLI framework based on `Swoole 4.3+`. It has a built-in coroutine server with a large number of commonly used components. It provides ultra-high and better performance than the traditional PHP-FPM-based framework and also maintains extremely flexible scalability at the same time. Standard components are implemented in the latest PSR standards, and a powerful dependency injection design ensures that most components or classes within the framework are replaceable.
+
+In addition to providing `MySQL coroutine client` and `Redis coroutine client`, common coroutine clients, the Hyperf component libraries are also prepared for the coroutine version of `Eloquent ORM`, `GRPC server and client`, `Zipkin (OpenTracing) client`, `Guzzle HTTP client`, `Elasticsearch client`, `Consul client`, `ETCD client`, `AMQP component`, `Apollo configuration center`, `Token bucket algorithm-based limiter`, and `Universal connection pool`, etc. Therefore, the trouble of implementing the corresponding coroutine version client by yourself can be avoided. Hyperf also provides convenient functions such as `Dependency injection`, `Annotation`, `AOP (aspect-oriented programming)`, `Middleware`, `Custom Processes`, `Event Manager`, `Simply Redis message queue`, and `Full-featured RabbitMQ message queue` to meet a wide range of technical and business scenarios.
+
+# Original intention
+
+Although there are many new PHP frameworks have been appeared, but we still has not seen a perfect framework which has the coexistence of elegant design and ultra-high performance, nor would we find a framework that really paves the way for PHP microservices. For the original intention of Hyperf and its team members, we will continue to invest to it, and you are welcome to join us to participate in open source construction.
+
+# Design concept
+
+`Hyperspeed + Flexibility = Hyperf`, from the framework name we have been used `hyperfspeed (ultra-high performance)` and `flexibility` as the gene of Hyperf.
+
+For ultra-high performance, Hyperf based on the Swoole coroutine, it providered an amazing performance, Hyperf team also makes a lots of code optimizations on the framework design to ensure ultra-high performance.   
+
+For flexibility, based on the powerful dependency injection component  of Hyperf, all components are based on [PSR](https://www.php-fig.org/psr) and the contracts that defined by Hyperf, so that most of the components or classes within the framework are replaceable and re-useable.   
+
+Based on the above characteristics, Hyperf has a lots of possibilities, such as implementing Web servers, gateway servers, distributed middleware software, microservices architecture, game servers, and Internet of Things (IoT).
+
+# Documentation
+
+[https://doc.hyperf.io/](https://doc.hyperf.io/)

+ 113 - 0
frameworks/PHP/hyperf/app/Controller/IndexController.php

@@ -0,0 +1,113 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+namespace App\Controller;
+
+use App\Model\Fortune;
+use App\Model\World;
+use App\Render;
+use Hyperf\HttpServer\Annotation\Controller;
+use Hyperf\HttpServer\Annotation\GetMapping;
+use Hyperf\HttpServer\Contract\ResponseInterface;
+
+/**
+ * @Controller
+ */
+class IndexController
+{
+    /**
+     * @GetMapping(path="/json")
+     */
+    public function json()
+    {
+        return ['message' => 'Hello, World!'];
+    }
+
+    /**
+     * @GetMapping(path="/db")
+     */
+    public function db()
+    {
+        return World::find(random_int(1, 10000));
+    }
+
+    /**
+     * @GetMapping(path="/queries/[{queries}]")
+     */
+    public function queries($queries = 1, ResponseInterface $response)
+    {
+        $queries = $this->clamp($queries);
+
+        $rows = [];
+        while ($queries--) {
+            $rows[] = World::find(random_int(1, 10000));
+        }
+
+        return $response->json($rows);
+    }
+
+    /**
+     * @GetMapping(path="/fortunes")
+     */
+    public function fortunes(Render $render)
+    {
+        $rows = Fortune::all();
+
+        $insert = new Fortune();
+        $insert->id = 0;
+        $insert->message = 'Additional fortune added at request time.';
+
+        $rows->add($insert);
+        $rows = $rows->sortBy('message');
+
+        return $render->render('fortunes', ['rows' => $rows]);
+    }
+
+    /**
+     * @GetMapping(path="/updates/[{queries}]")
+     */
+    public function updates($queries = 1, ResponseInterface $response)
+    {
+        $queries = $this->clamp($queries);
+
+        $rows = [];
+
+        while ($queries--) {
+            $row = World::find(random_int(1, 10000));
+            $row->randomNumber = random_int(1, 10000);
+            $row->save();
+
+            $rows[] = $row;
+        }
+
+        return $response->json($rows);
+    }
+
+    /**
+     * @GetMapping(path="/plaintext")
+     */
+    public function plaintext()
+    {
+        return 'Hello, World!';
+    }
+
+    private function clamp($value): int
+    {
+        if (! is_numeric($value) || $value < 1) {
+            return 1;
+        }
+        if ($value > 500) {
+            return 500;
+        }
+        return (int)$value;
+    }
+}

+ 20 - 0
frameworks/PHP/hyperf/app/Model/Fortune.php

@@ -0,0 +1,20 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+namespace App\Model;
+
+class Fortune extends Model
+{
+    public $timestamps = false;
+
+    protected $table = 'Fortune';
+}

+ 19 - 0
frameworks/PHP/hyperf/app/Model/Model.php

@@ -0,0 +1,19 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model as BaseModel;
+
+abstract class Model extends BaseModel
+{
+}

+ 20 - 0
frameworks/PHP/hyperf/app/Model/World.php

@@ -0,0 +1,20 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+namespace App\Model;
+
+class World extends Model
+{
+    public $timestamps = false;
+
+    protected $table = 'World';
+}

+ 30 - 0
frameworks/PHP/hyperf/app/Render.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App;
+
+
+use Hyperf\HttpMessage\Stream\SwooleStream;
+use Hyperf\View\Engine\EngineInterface;
+use Hyperf\View\Mode;
+
+class Render extends \Hyperf\View\Render
+{
+    public function render(string $template, array $data)
+    {
+        switch ($this->mode) {
+            case Mode::SYNC:
+                /** @var EngineInterface $engine */
+                $engine = $this->container->get($this->engine);
+                $result = $engine->render($template, $data, $this->config);
+                break;
+            case Mode::TASK:
+            default:
+                $executor = $this->container->get(TaskExecutor::class);
+                $result = $executor->execute(new Task([$this->engine, 'render'], [$template, $data, $this->config]));
+        }
+
+        return $this->response()->withAddedHeader('content-type', 'text/html; charset=utf-8')->withBody(new SwooleStream($result));
+    }
+
+
+}

+ 30 - 0
frameworks/PHP/hyperf/benchmark_config.json

@@ -0,0 +1,30 @@
+{
+    "framework": "hyperf",
+    "tests": [
+        {
+            "default": {
+                "json_url": "/json",
+                "db_url": "/db",
+                "query_url": "/queries/",
+                "fortune_url": "/fortunes",
+                "update_url": "/updates/",
+                "plaintext_url": "/plaintext",
+                "port": 9501,
+                "approach": "Realistic",
+                "classification": "Fullstack",
+                "database": "MySQL",
+                "framework": "Hyperf",
+                "language": "PHP",
+                "flavor": "None",
+                "orm": "Full",
+                "platform": "swoole",
+                "webserver": "None",
+                "os": "Linux",
+                "database_os": "Linux",
+                "display_name": "Hyperf",
+                "notes": "",
+                "versus": "swoole"
+            }
+        }
+    ]
+}

+ 21 - 0
frameworks/PHP/hyperf/bin/hyperf.php

@@ -0,0 +1,21 @@
+#!/usr/bin/env php
+<?php
+
+ini_set('display_errors', 'on');
+ini_set('display_startup_errors', 'on');
+
+error_reporting(E_ALL);
+date_default_timezone_set('Asia/Shanghai');
+
+! defined('BASE_PATH') && define('BASE_PATH', dirname(__DIR__, 1));
+
+require BASE_PATH . '/vendor/autoload.php';
+
+// Self-called anonymous function that creates its own scope and keep the global namespace clean.
+(function () {
+    /** @var \Psr\Container\ContainerInterface $container */
+    $container = require BASE_PATH . '/config/container.php';
+
+    $application = $container->get(\Hyperf\Contract\ApplicationInterface::class);
+    $application->run();
+})();

+ 80 - 0
frameworks/PHP/hyperf/composer.json

@@ -0,0 +1,80 @@
+{
+    "name": "hyperf/hyperf-skeleton",
+    "type": "project",
+    "keywords": [
+        "php",
+        "swoole",
+        "framework",
+        "hyperf",
+        "microservice",
+        "middleware"
+    ],
+    "description": "A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.",
+    "license": "Apache-2.0",
+    "require": {
+        "php": ">=7.2",
+        "ext-swoole": ">=4.2",
+        "hyperf/command": "~1.0.0",
+        "hyperf/config": "~1.0.0",
+        "hyperf/contract": "~1.0.0",
+        "hyperf/database": "~1.0.0",
+        "hyperf/db-connection": "~1.0.0",
+        "hyperf/di": "~1.0.0",
+        "hyperf/dispatcher": "~1.0.0",
+        "hyperf/event": "~1.0.0",
+        "hyperf/exception-handler": "~1.0.0",
+        "hyperf/framework": "~1.0.0",
+        "hyperf/http-server": "~1.0.0",
+        "hyperf/logger": "~1.0.0",
+        "hyperf/paginator": "~1.0.0",
+        "hyperf/pool": "~1.0.0",
+        "hyperf/utils": "~1.0.0",
+        "hyperf/view": "~1.0.0",
+        "duncan3dc/blade": "^4.6"
+    },
+    "require-dev": {
+        "swoft/swoole-ide-helper": "^4.2",
+        "phpmd/phpmd": "^2.6",
+        "friendsofphp/php-cs-fixer": "^2.14",
+        "mockery/mockery": "^1.0",
+        "doctrine/common": "^2.9",
+        "phpstan/phpstan": "^0.11.2",
+        "hyperf/testing": "~1.0.0"
+    },
+    "suggest": {
+        "ext-openssl": "Required to use HTTPS.",
+        "ext-json": "Required to use JSON.",
+        "ext-pdo": "Required to use MySQL Client.",
+        "ext-pdo_mysql": "Required to use MySQL Client.",
+        "ext-redis": "Required to use Redis Client."
+    },
+    "autoload": {
+        "psr-4": {
+            "App\\": "app/"
+        },
+        "files": []
+    },
+    "autoload-dev": {
+        "psr-4": {
+            "HyperfTest\\": "./test/"
+        }
+    },
+    "minimum-stability": "dev",
+    "prefer-stable": true,
+    "extra": [],
+    "scripts": {
+        "post-root-package-install": [
+            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
+        ],
+        "test": "co-phpunit -c phpunit.xml --colors=always",
+        "cs-fix": "php-cs-fixer fix $1",
+        "analyze": "phpstan analyse --memory-limit 300M -l 0 -c phpstan.neon ./app ./config",
+        "start": "php ./bin/hyperf.php start"
+    },
+    "repositories": {
+        "packagist": {
+            "type": "composer",
+            "url": "https://mirrors.aliyun.com/composer"
+        }
+    }
+}

+ 22 - 0
frameworks/PHP/hyperf/config/autoload/annotations.php

@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+return [
+    'scan' => [
+        'paths' => [
+            BASE_PATH . '/app',
+        ],
+        'ignore_annotations' => [
+            'mixin',
+        ],
+    ],
+];

+ 40 - 0
frameworks/PHP/hyperf/config/autoload/databases.php

@@ -0,0 +1,40 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+return [
+    'default' => [
+        'driver' => env('DB_DRIVER', 'mysql'),
+        'host' => env('DB_HOST', 'localhost'),
+        'database' => env('DB_DATABASE', 'hyperf'),
+        'port' => env('DB_PORT', 3306),
+        'username' => env('DB_USERNAME', 'root'),
+        'password' => env('DB_PASSWORD', ''),
+        'charset' => env('DB_CHARSET', 'utf8'),
+        'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
+        'prefix' => env('DB_PREFIX', ''),
+        'pool' => [
+            'min_connections' => 1,
+            'max_connections' => 100000,
+            'connect_timeout' => 10.0,
+            'wait_timeout' => 3.0,
+            'heartbeat' => -1,
+            'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
+        ],
+        'commands' => [
+            'db:model' => [
+                'path' => 'app/Model',
+                'force_casts' => true,
+                'inheritance' => 'Model',
+            ],
+        ],
+    ],
+];

+ 45 - 0
frameworks/PHP/hyperf/config/autoload/devtool.php

@@ -0,0 +1,45 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+return [
+    'generator' => [
+        'amqp' => [
+            'consumer' => [
+                'namespace' => 'App\\Amqp\\Consumer',
+            ],
+            'producer' => [
+                'namespace' => 'App\\Amqp\\Producer',
+            ],
+        ],
+        'aspect' => [
+            'namespace' => 'App\\Aspect',
+        ],
+        'command' => [
+            'namespace' => 'App\\Command',
+        ],
+        'controller' => [
+            'namespace' => 'App\\Controller',
+        ],
+        'job' => [
+            'namespace' => 'App\\Job',
+        ],
+        'listener' => [
+            'namespace' => 'App\\Listener',
+        ],
+        'middleware' => [
+            'namespace' => 'App\\Middleware',
+        ],
+        'Process' => [
+            'namespace' => 'App\\Processes',
+        ],
+    ],
+];

+ 31 - 0
frameworks/PHP/hyperf/config/autoload/logger.php

@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+return [
+    'default' => [
+        'handler' => [
+            'class' => Monolog\Handler\StreamHandler::class,
+            'constructor' => [
+                'stream' => BASE_PATH . '/runtime/logs/hyperf.log',
+                'level' => Monolog\Logger::DEBUG,
+            ],
+        ],
+        'formatter' => [
+            'class' => Monolog\Formatter\LineFormatter::class,
+            'constructor' => [
+                'format' => null,
+                'dateFormat' => null,
+                'allowInlineLineBreaks' => true,
+            ],
+        ],
+    ],
+];

+ 45 - 0
frameworks/PHP/hyperf/config/autoload/server.php

@@ -0,0 +1,45 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+use Hyperf\Server\Server;
+use Hyperf\Server\SwooleEvent;
+
+return [
+    'mode' => SWOOLE_BASE,
+    'servers' => [
+        [
+            'name' => 'http',
+            'type' => Server::SERVER_HTTP,
+            'host' => '0.0.0.0',
+            'port' => 9501,
+            'sock_type' => SWOOLE_SOCK_TCP,
+            'callbacks' => [
+                SwooleEvent::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'],
+            ],
+        ],
+    ],
+    'settings' => [
+        'enable_coroutine' => true,
+        'worker_num' => swoole_cpu_num() * 2,
+        'pid_file' => BASE_PATH . '/runtime/hyperf.pid',
+        'open_tcp_nodelay' => true,
+        'max_coroutine' => 1000000,
+        'open_http2_protocol' => false,
+        'max_request' => 1000000,
+        'socket_buffer_size' => 2 * 1024 * 1024,
+    ],
+    'callbacks' => [
+        SwooleEvent::ON_BEFORE_START => [Hyperf\Framework\Bootstrap\ServerStartCallback::class, 'beforeStart'],
+        SwooleEvent::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'],
+        SwooleEvent::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'],
+    ],
+];

+ 17 - 0
frameworks/PHP/hyperf/config/autoload/view.php

@@ -0,0 +1,17 @@
+<?php
+declare(strict_types=1);
+
+use Hyperf\View\Mode;
+use Hyperf\View\Engine\BladeEngine;
+
+return [
+    // 使用的渲染引擎
+    'engine' => BladeEngine::class,
+    // 不填写则默认为 Task 模式,推荐使用 Task 模式
+    'mode' => Mode::SYNC,
+    'config' => [
+        // 若下列文件夹不存在请自行创建
+        'view_path' => BASE_PATH . '/storage/view/',
+        'cache_path' => BASE_PATH . '/runtime/view/',
+    ],
+];

+ 22 - 0
frameworks/PHP/hyperf/config/config.php

@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+use Hyperf\Contract\StdoutLoggerInterface;
+use Psr\Log\LogLevel;
+
+return [
+    'app_name' => env('APP_NAME', 'skeleton'),
+    StdoutLoggerInterface::class => [
+        'log_level' => [
+        ],
+    ],
+];

+ 36 - 0
frameworks/PHP/hyperf/config/container.php

@@ -0,0 +1,36 @@
+<?php
+/**
+ * Initial a dependency injection container that implemented PSR-11 and return the container.
+ */
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+use Hyperf\Config\ProviderConfig;
+use Hyperf\Di\Annotation\Scanner;
+use Hyperf\Di\Container;
+use Hyperf\Di\Definition\DefinitionSource;
+use Hyperf\Utils\ApplicationContext;
+
+$configFromProviders = ProviderConfig::load();
+$definitions = include __DIR__ . '/dependencies.php';
+$serverDependencies = array_replace($configFromProviders['dependencies'] ?? [], $definitions['dependencies'] ?? []);
+
+$annotations = include __DIR__ . '/autoload/annotations.php';
+$scanDirs = $configFromProviders['scan']['paths'];
+$scanDirs = array_merge($scanDirs, $annotations['scan']['paths'] ?? []);
+
+$ignoreAnnotations = $annotations['scan']['ignore_annotations'] ?? ['mixin'];
+$container = new Container(new DefinitionSource($serverDependencies, $scanDirs, new Scanner($ignoreAnnotations)));
+
+if (! $container instanceof \Psr\Container\ContainerInterface) {
+    throw new RuntimeException('The dependency injection container is invalid.');
+}
+return ApplicationContext::setContainer($container);

+ 16 - 0
frameworks/PHP/hyperf/config/dependencies.php

@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+return [
+    'dependencies' => [
+    ],
+];

+ 13 - 0
frameworks/PHP/hyperf/config/routes.php

@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * This file is part of Hyperf.
+ *
+ * @link     https://www.hyperf.io
+ * @document https://doc.hyperf.io
+ * @contact  [email protected]
+ * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+ */
+
+use Hyperf\HttpServer\Router\Router;

+ 57 - 0
frameworks/PHP/hyperf/hyperf.dockerfile

@@ -0,0 +1,57 @@
+# Default Dockerfile
+#
+# @link     https://www.hyperf.io
+# @document https://doc.hyperf.io
+# @contact  [email protected]
+# @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
+
+FROM hyperf/hyperf:7.2-alpine-cli
+LABEL maintainer="Hyperf Developers <[email protected]>" version="1.0" license="MIT"
+
+##
+# ---------- env settings ----------
+##
+# --build-arg timezone=Asia/Shanghai
+ARG timezone
+
+ENV TIMEZONE=${timezone:-"America/Los_Angeles"} \
+    COMPOSER_VERSION=1.8.6 \
+    APP_ENV=prod
+
+# update
+RUN set -ex \
+    # install composer
+    && cd /tmp \
+    && wget https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \
+    && chmod u+x composer.phar \
+    && mv composer.phar /usr/local/bin/composer \
+    # show php version and extensions
+    && php -v \
+    && php -m \
+    #  ---------- some config ----------
+    && cd /etc/php7 \
+    # - config PHP
+    && { \
+        echo "upload_max_filesize=100M"; \
+        echo "post_max_size=108M"; \
+        echo "memory_limit=1024M"; \
+        echo "date.timezone=${TIMEZONE}"; \
+    } | tee conf.d/99-overrides.ini \
+    # - config timezone
+    && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
+    && echo "${TIMEZONE}" > /etc/timezone \
+    # ---------- clear works ----------
+    && rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
+    && echo -e "\033[42;37m Build Completed :).\033[0m\n"
+
+COPY . /opt/www
+
+WORKDIR /opt/www
+
+RUN composer install --no-dev \
+    && composer dump-autoload -o \
+    && php /opt/www/bin/hyperf.php di:init-proxy
+
+EXPOSE 9501
+
+ENTRYPOINT ["php", "/opt/www/bin/hyperf.php", "start"]

+ 21 - 0
frameworks/PHP/hyperf/phpunit.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit backupGlobals="false"
+         backupStaticAttributes="false"
+         bootstrap="./test/bootstrap.php"
+         colors="true"
+         convertErrorsToExceptions="true"
+         convertNoticesToExceptions="true"
+         convertWarningsToExceptions="true"
+         processIsolation="false"
+         stopOnFailure="false">
+    <testsuites>
+        <testsuite name="Tests">
+            <directory suffix="Test.php">./test</directory>
+        </testsuite>
+    </testsuites>
+    <filter>
+        <whitelist processUncoveredFilesFromWhitelist="true">
+            <directory suffix=".php">./app</directory>
+        </whitelist>
+    </filter>
+</phpunit>

+ 13 - 0
frameworks/PHP/hyperf/storage/view/fortunes.blade.php

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head><title>Fortunes</title></head>
+<body>
+<table>
+	<tr><th>id</th><th>message</th></tr>
+
+	@foreach($rows as $row)
+		<tr><td>{{$row->id}}</td><td>{{$row->message}}</td></tr>
+	@endforeach
+</table>
+</body>
+</html>