diff --git a/.entry.sh b/.entry.sh new file mode 100644 index 00000000..a9bcb8d3 --- /dev/null +++ b/.entry.sh @@ -0,0 +1,5 @@ +#!/bin/bash +if [ ! -d "/app/zhamao-framework/bin" ]; then + cp -r /app/zhamao-framework-bak/* /app/zhamao-framework/ +fi +php /app/zhamao-framework/bin/start framework --disable-console-input \ No newline at end of file diff --git a/.gitignore b/.gitignore index fa694cc8..deac3474 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /src/webconsole/config/ /vendor/ zm.json -/zm_data/ \ No newline at end of file +/zm_data/ +composer.lock \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4b3aa1d6..caf275a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,13 +4,12 @@ RUN echo "Asia/Shanghai" > /etc/timezone #RUN dpkg-configure -f noninteractive tzdata ENV LANG C.UTF_8 -RUN apt update && apt install wget -y -VOLUME ["/app/"] +VOLUME ["/app/zhamao-framework/"] ADD . /app/zhamao-framework -RUN cd /app/zhamao-framework && composer update && composer clearcache +ADD . /app/zhamao-framework-bak +#RUN cd /app/zhamao-framework && composer update && composer clearcache #RUN mv zhamao-framework-master zhamao-framework WORKDIR /app/zhamao-framework EXPOSE 20001 - -CMD ["php", "/app/zhamao-framework/bin/start", "framework", "--disable-console-input"] \ No newline at end of file +CMD ["bash", "/app/zhamao-framework-bak/.entry.sh"] \ No newline at end of file diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 3e192231..00000000 --- a/composer.lock +++ /dev/null @@ -1,395 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "fb2cdfc2c51cc4f5c2758916f7a3b628", - "packages": [ - { - "name": "doctrine/annotations", - "version": "v1.8.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/904dca4eb10715b92569fbcd79e201d5c349b6bc", - "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc", - "shasum": "" - }, - "require": { - "doctrine/lexer": "1.*", - "php": "^7.1" - }, - "require-dev": { - "doctrine/cache": "1.*", - "phpunit/phpunit": "^7.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.7.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Docblock Annotations Parser", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "docblock", - "parser" - ], - "time": "2019-10-01T18:55:10+00:00" - }, - { - "name": "doctrine/lexer", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/lexer.git", - "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", - "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", - "shasum": "" - }, - "require": { - "php": "^7.2" - }, - "require-dev": { - "doctrine/coding-standard": "^6.0", - "phpstan/phpstan": "^0.11.8", - "phpunit/phpunit": "^8.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "https://www.doctrine-project.org/projects/lexer.html", - "keywords": [ - "annotations", - "docblock", - "lexer", - "parser", - "php" - ], - "time": "2019-10-30T14:39:59+00:00" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06T14:39:51+00:00" - }, - { - "name": "swlib/http", - "version": "v1.0.5", - "source": { - "type": "git", - "url": "https://github.com/swlib/http.git", - "reference": "d8ad0b0aed67ab9d1b18a6ce87c40813c0e00060" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/swlib/http/zipball/d8ad0b0aed67ab9d1b18a6ce87c40813c0e00060", - "reference": "d8ad0b0aed67ab9d1b18a6ce87c40813c0e00060", - "shasum": "" - }, - "require": { - "php": ">=7.0", - "psr/http-message": "~1.0" - }, - "require-dev": { - "eaglewu/swoole-ide-helper": "dev-master", - "phpunit/phpunit": "~7" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "Swlib\\Http\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "twosee", - "email": "twose@qq.com" - } - ], - "description": "Swlib-HTTP base class repository, PSR implementation", - "keywords": [ - "http", - "php", - "psr7", - "swoole" - ], - "time": "2019-09-24T06:38:56+00:00" - }, - { - "name": "swlib/saber", - "version": "1.0.10", - "source": { - "type": "git", - "url": "https://github.com/swlib/saber.git", - "reference": "10b3a1b4e30edce6de583c44cb7d2185f33a8a1f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/swlib/saber/zipball/10b3a1b4e30edce6de583c44cb7d2185f33a8a1f", - "reference": "10b3a1b4e30edce6de583c44cb7d2185f33a8a1f", - "shasum": "" - }, - "require": { - "php": ">=7.1", - "swlib/http": "1.0.5", - "swlib/util": "1.0.0" - }, - "require-dev": { - "eaglewu/swoole-ide-helper": "dev-master", - "phpunit/phpunit": "~7" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/Saber.php", - "src/SaberGM.php" - ], - "psr-4": { - "Swlib\\Saber\\": "src" - }, - "files": [ - "src/include/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "twosee", - "email": "twose@qq.com" - } - ], - "description": "Swoole coroutine HTTP client", - "keywords": [ - "ajax", - "axios", - "client", - "coroutine", - "curl", - "http", - "php", - "psr7", - "requests", - "swoole" - ], - "time": "2019-09-26T08:29:29+00:00" - }, - { - "name": "swlib/util", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/swlib/util.git", - "reference": "f9aaa9028ea16a489a46b9ad09f0e844997cffe7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/swlib/util/zipball/f9aaa9028ea16a489a46b9ad09f0e844997cffe7", - "reference": "f9aaa9028ea16a489a46b9ad09f0e844997cffe7", - "shasum": "" - }, - "require": { - "php": ">=7.0" - }, - "require-dev": { - "eaglewu/swoole-ide-helper": "dev-master", - "phpunit/phpunit": "~7" - }, - "type": "library", - "autoload": { - "psr-4": { - "Swlib\\Util\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "twosee", - "email": "twose@qq.com" - } - ], - "description": "Swlib Toolkit", - "keywords": [ - "php", - "swlib", - "swoole", - "util" - ], - "time": "2018-07-23T04:36:19+00:00" - }, - { - "name": "swoole/ide-helper", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/swoole/ide-helper.git", - "reference": "a7bae643171ff4176ff37868a40276819e5789aa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/swoole/ide-helper/zipball/a7bae643171ff4176ff37868a40276819e5789aa", - "reference": "a7bae643171ff4176ff37868a40276819e5789aa", - "shasum": "" - }, - "require-dev": { - "guzzlehttp/guzzle": "~6.5.0", - "squizlabs/php_codesniffer": "~3.5.0", - "symfony/filesystem": "~4.3.0", - "zendframework/zend-code": "~3.3.0" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Team Swoole", - "email": "team@swoole.com" - } - ], - "description": "IDE help files for Swoole.", - "time": "2020-01-15T08:00:05+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "swoole/ide-helper": 20 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "ext-mbstring": "*", - "ext-json": "*", - "ext-posix": "*" - }, - "platform-dev": [] -} diff --git a/src/ZM/Event/Swoole/RequestEvent.php b/src/ZM/Event/Swoole/RequestEvent.php index dd18b514..f986e972 100644 --- a/src/ZM/Event/Swoole/RequestEvent.php +++ b/src/ZM/Event/Swoole/RequestEvent.php @@ -25,17 +25,12 @@ class RequestEvent implements SwooleEvent */ private $response; - public function __construct(Request $request, Response $response) - { + public function __construct(Request $request, Response $response) { $this->request = $request; $this->response = $response; } - /** - * @inheritDoc - */ - public function onActivate() - { + public function onActivate() { ZMUtil::checkWait(); foreach (ZMBuf::globals("http_header") as $k => $v) { $this->response->setHeader($k, $v); @@ -48,7 +43,7 @@ class RequestEvent implements SwooleEvent while (true) { $r = array_shift($uri); if ($r === null) break; - if (($cnt = count($node["son"])) == 1) { + if (($cnt = count($node["son"] ?? [])) == 1) { if (isset($node["param_route"])) { foreach ($node["son"] as $k => $v) { if ($v["id"] == $node["param_route"]) { @@ -114,8 +109,7 @@ class RequestEvent implements SwooleEvent /** * @inheritDoc */ - public function onAfter() - { + public function onAfter() { foreach (ZMBuf::$events[SwooleEventAfter::class] ?? [] as $v) { if (strtolower($v->type) == "request" && $this->parseSwooleRule($v)) { $c = $v->class; @@ -127,14 +121,12 @@ class RequestEvent implements SwooleEvent return $this; } - private function responseStatus(int $int) - { + private function responseStatus(int $int) { $this->response->status($int); $this->response->end(); } - private function parseSwooleRule($v) - { + private function parseSwooleRule($v) { switch ($v->rule) { case "containsGet": case "containsPost":