PHP 7.3 v2 Specialization (#1110)
* Added support for PHP 7.3 v2 Specialization * Add builder dockerfile for PHP7 * Support mcrypt in PHP 7.3
This commit is contained in:
committed by
Ta-Ching Chen
parent
38b8cfaa0a
commit
f104f0b46b
@@ -1,15 +1,10 @@
|
||||
FROM php:7.1-alpine
|
||||
FROM php:7.3-alpine
|
||||
|
||||
ENV PATH="/root/.composer/vendor/bin:${PATH}" \
|
||||
COMPOSER_ALLOW_SUPERUSER=1
|
||||
|
||||
RUN echo '#!/bin/sh' > /usr/local/bin/apk-install \
|
||||
&& echo 'apk add --update "$@" && rm -rf /var/cache/apk/*' >> /usr/local/bin/apk-install \
|
||||
&& chmod +x /usr/local/bin/apk-install
|
||||
|
||||
RUN echo 'http://dl-4.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
|
||||
&& apk update \
|
||||
&& apk-install \
|
||||
&& apk --no-cache add \
|
||||
git \
|
||||
curl \
|
||||
curl-dev \
|
||||
@@ -26,11 +21,14 @@ RUN echo 'http://dl-4.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositor
|
||||
vim \
|
||||
libxml2-dev \
|
||||
freetype-dev \
|
||||
libzip-dev \
|
||||
unzip \
|
||||
libc6-compat \
|
||||
openssl \
|
||||
gcc \
|
||||
autoconf
|
||||
autoconf \
|
||||
make \
|
||||
libc-dev
|
||||
|
||||
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
|
||||
|
||||
@@ -47,7 +45,6 @@ RUN docker-php-ext-install \
|
||||
gettext \
|
||||
intl \
|
||||
json \
|
||||
mcrypt \
|
||||
mysqli \
|
||||
pgsql \
|
||||
pcntl \
|
||||
@@ -60,6 +57,11 @@ RUN docker-php-ext-install \
|
||||
xmlrpc \
|
||||
zip
|
||||
|
||||
RUN pecl install \
|
||||
mcrypt-1.0.2
|
||||
RUN docker-php-ext-enable \
|
||||
mcrypt
|
||||
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
COPY . /app
|
||||
@@ -70,4 +72,4 @@ RUN composer install
|
||||
EXPOSE 8888
|
||||
|
||||
ENTRYPOINT ["php"]
|
||||
CMD ["-S","0.0.0.0:8888","index.php"]
|
||||
CMD ["server.php"]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
This is the PHP environment for Fission.
|
||||
|
||||
It's a Docker image containing a PHP 7.1 runtime. This image use php:7.1-cli base image with the built-in PHP server
|
||||
It's a Docker image containing a PHP 7.3 runtime. This image use php:7.3-cli base image with the built-in PHP server
|
||||
|
||||
This environment didn't force you to use class or create a main function.
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
ARG BUILDER_IMAGE=fission/builder
|
||||
FROM ${BUILDER_IMAGE}
|
||||
|
||||
FROM php:7.3-alpine
|
||||
|
||||
ENV PATH="/root/.composer/vendor/bin:${PATH}" \
|
||||
COMPOSER_ALLOW_SUPERUSER=1
|
||||
|
||||
RUN echo 'http://dl-4.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
|
||||
&& apk --no-cache add \
|
||||
git \
|
||||
curl \
|
||||
curl-dev \
|
||||
libcurl \
|
||||
zlib-dev \
|
||||
freetype-dev \
|
||||
jpeg-dev \
|
||||
libjpeg-turbo-dev \
|
||||
postgresql-dev \
|
||||
libmcrypt-dev \
|
||||
libpng-dev \
|
||||
icu-dev \
|
||||
gettext-dev \
|
||||
vim \
|
||||
libxml2-dev \
|
||||
freetype-dev \
|
||||
libzip-dev \
|
||||
unzip \
|
||||
libc6-compat \
|
||||
openssl \
|
||||
gcc \
|
||||
autoconf \
|
||||
make \
|
||||
libc-dev
|
||||
|
||||
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
|
||||
|
||||
# Install useful extensions
|
||||
RUN docker-php-ext-install \
|
||||
opcache \
|
||||
bcmath \
|
||||
ctype \
|
||||
curl \
|
||||
dom \
|
||||
iconv \
|
||||
fileinfo \
|
||||
gd \
|
||||
gettext \
|
||||
intl \
|
||||
json \
|
||||
mysqli \
|
||||
pgsql \
|
||||
pcntl \
|
||||
pdo \
|
||||
ftp \
|
||||
pdo_mysql \
|
||||
pdo_pgsql \
|
||||
phar \
|
||||
simplexml \
|
||||
xmlrpc \
|
||||
zip
|
||||
|
||||
RUN pecl install \
|
||||
mcrypt-1.0.2
|
||||
RUN docker-php-ext-enable \
|
||||
mcrypt
|
||||
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
COPY --from=0 /builder /builder
|
||||
COPY defaultBuildCmd /usr/local/bin/build
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
set -euxo pipefail
|
||||
|
||||
if [ -f ${SRC_PKG}/composer.json ]
|
||||
then
|
||||
cd ${SRC_PKG}
|
||||
composer install --no-interaction
|
||||
fi
|
||||
cp -r ${SRC_PKG} ${DEPLOY_PKG}
|
||||
@@ -5,7 +5,8 @@
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"zendframework/zend-diactoros": "^1.3",
|
||||
"monolog/monolog": "^1.22"
|
||||
"monolog/monolog": "^1.22",
|
||||
"react/http": "^0.8.4",
|
||||
"nikic/php-parser": "^4.2"
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+566
-41
@@ -4,21 +4,64 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "26efb7d1cc58e9ecdc8765fac5eca4e1",
|
||||
"content-hash": "c0c5cd003c9c3ca4cf3346b232e86258",
|
||||
"hash": "5a681a6e3133f56dde5a45b087dbfa6f",
|
||||
"content-hash": "d48759c44a5d6d8f97f3f2f26c8a5de5",
|
||||
"packages": [
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "1.22.0",
|
||||
"name": "evenement/evenement",
|
||||
"version": "v3.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Seldaek/monolog.git",
|
||||
"reference": "bad29cb8d18ab0315e6c477751418a82c850d558"
|
||||
"url": "https://github.com/igorw/evenement.git",
|
||||
"reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bad29cb8d18ab0315e6c477751418a82c850d558",
|
||||
"reference": "bad29cb8d18ab0315e6c477751418a82c850d558",
|
||||
"url": "https://api.github.com/repos/igorw/evenement/zipball/531bfb9d15f8aa57454f5f0285b18bec903b8fb7",
|
||||
"reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Evenement": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Igor Wiedler",
|
||||
"email": "igor@wiedler.ch"
|
||||
}
|
||||
],
|
||||
"description": "Événement is a very simple event dispatching library for PHP",
|
||||
"keywords": [
|
||||
"event-dispatcher",
|
||||
"event-emitter"
|
||||
],
|
||||
"time": "2017-07-23 21:35:13"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "1.24.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Seldaek/monolog.git",
|
||||
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
|
||||
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -39,7 +82,7 @@
|
||||
"phpunit/phpunit-mock-objects": "2.3.0",
|
||||
"ruflin/elastica": ">=0.90 <3.0",
|
||||
"sentry/sentry": "^0.13",
|
||||
"swiftmailer/swiftmailer": "~5.3"
|
||||
"swiftmailer/swiftmailer": "^5.3|^6.0"
|
||||
},
|
||||
"suggest": {
|
||||
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
|
||||
@@ -83,7 +126,58 @@
|
||||
"logging",
|
||||
"psr-3"
|
||||
],
|
||||
"time": "2016-11-26 00:15:39"
|
||||
"time": "2018-11-05 09:00:11"
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v4.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||
"reference": "5221f49a608808c1e4d436df32884cbc1b821ac0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/5221f49a608808c1e4d436df32884cbc1b821ac0",
|
||||
"reference": "5221f49a608808c1e4d436df32884cbc1b821ac0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-tokenizer": "*",
|
||||
"php": ">=7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.5 || ^7.0"
|
||||
},
|
||||
"bin": [
|
||||
"bin/php-parse"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpParser\\": "lib/PhpParser"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nikita Popov"
|
||||
}
|
||||
],
|
||||
"description": "A PHP parser written in PHP",
|
||||
"keywords": [
|
||||
"parser",
|
||||
"php"
|
||||
],
|
||||
"time": "2019-02-16 20:54:15"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-message",
|
||||
@@ -137,16 +231,16 @@
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "1.0.2",
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/log.git",
|
||||
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
|
||||
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
|
||||
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
|
||||
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -180,57 +274,488 @@
|
||||
"psr",
|
||||
"psr-3"
|
||||
],
|
||||
"time": "2016-10-10 12:19:37"
|
||||
"time": "2018-11-20 15:27:04"
|
||||
},
|
||||
{
|
||||
"name": "zendframework/zend-diactoros",
|
||||
"version": "1.3.10",
|
||||
"name": "react/cache",
|
||||
"version": "v0.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zendframework/zend-diactoros.git",
|
||||
"reference": "83e8d98b9915de76c659ce27d683c02a0f99fa90"
|
||||
"url": "https://github.com/reactphp/cache.git",
|
||||
"reference": "7d7da7fb7574d471904ba357b39bbf110ccdbf66"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/83e8d98b9915de76c659ce27d683c02a0f99fa90",
|
||||
"reference": "83e8d98b9915de76c659ce27d683c02a0f99fa90",
|
||||
"url": "https://api.github.com/repos/reactphp/cache/zipball/7d7da7fb7574d471904ba357b39bbf110ccdbf66",
|
||||
"reference": "7d7da7fb7574d471904ba357b39bbf110ccdbf66",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.4 || ^7.0",
|
||||
"psr/http-message": "~1.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-message-implementation": "~1.0.0"
|
||||
"php": ">=5.3.0",
|
||||
"react/promise": "~2.0|~1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.6 || ^5.5",
|
||||
"zendframework/zend-coding-standard": "~1.0.0"
|
||||
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev",
|
||||
"dev-develop": "1.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Zend\\Diactoros\\": "src/"
|
||||
"React\\Cache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-2-Clause"
|
||||
"MIT"
|
||||
],
|
||||
"description": "PSR HTTP Message implementations",
|
||||
"homepage": "https://github.com/zendframework/zend-diactoros",
|
||||
"description": "Async, Promise-based cache interface for ReactPHP",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching",
|
||||
"promise",
|
||||
"reactphp"
|
||||
],
|
||||
"time": "2018-06-25 12:52:40"
|
||||
},
|
||||
{
|
||||
"name": "react/dns",
|
||||
"version": "v0.4.16",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactphp/dns.git",
|
||||
"reference": "0a0bedfec72b38406413c6ea01e1c015bd0bf72b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/reactphp/dns/zipball/0a0bedfec72b38406413c6ea01e1c015bd0bf72b",
|
||||
"reference": "0a0bedfec72b38406413c6ea01e1c015bd0bf72b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"react/cache": "^0.5 || ^0.4 || ^0.3",
|
||||
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5",
|
||||
"react/promise": "^2.1 || ^1.2.1",
|
||||
"react/promise-timer": "^1.2",
|
||||
"react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"clue/block-react": "^1.2",
|
||||
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"React\\Dns\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Async DNS resolver for ReactPHP",
|
||||
"keywords": [
|
||||
"async",
|
||||
"dns",
|
||||
"dns-resolver",
|
||||
"reactphp"
|
||||
],
|
||||
"time": "2018-11-11 11:21:13"
|
||||
},
|
||||
{
|
||||
"name": "react/event-loop",
|
||||
"version": "v1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactphp/event-loop.git",
|
||||
"reference": "a0ecac955c67b57c40fe4a1b88a7cca1b58c982d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/reactphp/event-loop/zipball/a0ecac955c67b57c40fe4a1b88a7cca1b58c982d",
|
||||
"reference": "a0ecac955c67b57c40fe4a1b88a7cca1b58c982d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-event": "~1.0 for ExtEventLoop",
|
||||
"ext-pcntl": "For signal handling support when using the StreamSelectLoop",
|
||||
"ext-uv": "* for ExtUvLoop"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"React\\EventLoop\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.",
|
||||
"keywords": [
|
||||
"asynchronous",
|
||||
"event-loop"
|
||||
],
|
||||
"time": "2019-02-07 16:19:49"
|
||||
},
|
||||
{
|
||||
"name": "react/http",
|
||||
"version": "v0.8.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactphp/http.git",
|
||||
"reference": "b29ab96557ac5c53e738fcb26f73f631a3f81f1a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/reactphp/http/zipball/b29ab96557ac5c53e738fcb26f73f631a3f81f1a",
|
||||
"reference": "b29ab96557ac5c53e738fcb26f73f631a3f81f1a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
|
||||
"php": ">=5.3.0",
|
||||
"react/promise": "^2.3 || ^1.2.1",
|
||||
"react/promise-stream": "^1.1",
|
||||
"react/socket": "^1.0 || ^0.8.3",
|
||||
"react/stream": "^1.0 || ^0.7.1",
|
||||
"ringcentral/psr7": "^1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"clue/block-react": "^1.1",
|
||||
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"React\\Http\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Event-driven, streaming plaintext HTTP and secure HTTPS server for ReactPHP",
|
||||
"keywords": [
|
||||
"event-driven",
|
||||
"http",
|
||||
"https",
|
||||
"reactphp",
|
||||
"server",
|
||||
"streaming"
|
||||
],
|
||||
"time": "2019-01-16 07:26:32"
|
||||
},
|
||||
{
|
||||
"name": "react/promise",
|
||||
"version": "v2.7.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactphp/promise.git",
|
||||
"reference": "31ffa96f8d2ed0341a57848cbb84d88b89dd664d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/reactphp/promise/zipball/31ffa96f8d2ed0341a57848cbb84d88b89dd664d",
|
||||
"reference": "31ffa96f8d2ed0341a57848cbb84d88b89dd664d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.8"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"React\\Promise\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jan Sorgalla",
|
||||
"email": "jsorgalla@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "A lightweight implementation of CommonJS Promises/A for PHP",
|
||||
"keywords": [
|
||||
"promise",
|
||||
"promises"
|
||||
],
|
||||
"time": "2019-01-07 21:25:54"
|
||||
},
|
||||
{
|
||||
"name": "react/promise-stream",
|
||||
"version": "v1.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactphp/promise-stream.git",
|
||||
"reference": "00e269d611e9c9a29356aef64c07f7e513e73dc9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/reactphp/promise-stream/zipball/00e269d611e9c9a29356aef64c07f7e513e73dc9",
|
||||
"reference": "00e269d611e9c9a29356aef64c07f7e513e73dc9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"react/promise": "^2.1 || ^1.2",
|
||||
"react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4 || ^0.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"clue/block-react": "^1.0",
|
||||
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35",
|
||||
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
|
||||
"react/promise-timer": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"React\\Promise\\Stream\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Christian Lück",
|
||||
"email": "christian@lueck.tv"
|
||||
}
|
||||
],
|
||||
"description": "The missing link between Promise-land and Stream-land for ReactPHP",
|
||||
"homepage": "https://github.com/reactphp/promise-stream",
|
||||
"keywords": [
|
||||
"Buffer",
|
||||
"async",
|
||||
"promise",
|
||||
"reactphp",
|
||||
"stream",
|
||||
"unwrap"
|
||||
],
|
||||
"time": "2017-12-22 12:02:05"
|
||||
},
|
||||
{
|
||||
"name": "react/promise-timer",
|
||||
"version": "v1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactphp/promise-timer.git",
|
||||
"reference": "a11206938ca2394dc7bb368f5da25cd4533fa603"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/reactphp/promise-timer/zipball/a11206938ca2394dc7bb368f5da25cd4533fa603",
|
||||
"reference": "a11206938ca2394dc7bb368f5da25cd4533fa603",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5",
|
||||
"react/promise": "^2.7.0 || ^1.2.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"React\\Promise\\Timer\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Christian Lück",
|
||||
"email": "christian@lueck.tv"
|
||||
}
|
||||
],
|
||||
"description": "A trivial implementation of timeouts for Promises, built on top of ReactPHP.",
|
||||
"homepage": "https://github.com/reactphp/promise-timer",
|
||||
"keywords": [
|
||||
"async",
|
||||
"event-loop",
|
||||
"promise",
|
||||
"reactphp",
|
||||
"timeout",
|
||||
"timer"
|
||||
],
|
||||
"time": "2018-06-13 16:45:37"
|
||||
},
|
||||
{
|
||||
"name": "react/socket",
|
||||
"version": "v1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactphp/socket.git",
|
||||
"reference": "23b7372bb25cea934f6124f5bdac34e30161959e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/reactphp/socket/zipball/23b7372bb25cea934f6124f5bdac34e30161959e",
|
||||
"reference": "23b7372bb25cea934f6124f5bdac34e30161959e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
|
||||
"php": ">=5.3.0",
|
||||
"react/dns": "^0.4.13",
|
||||
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5",
|
||||
"react/promise": "^2.6.0 || ^1.2.1",
|
||||
"react/promise-timer": "^1.4.0",
|
||||
"react/stream": "^1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"clue/block-react": "^1.2",
|
||||
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"React\\Socket\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP",
|
||||
"keywords": [
|
||||
"Connection",
|
||||
"Socket",
|
||||
"async",
|
||||
"reactphp",
|
||||
"stream"
|
||||
],
|
||||
"time": "2019-01-07 14:10:13"
|
||||
},
|
||||
{
|
||||
"name": "react/stream",
|
||||
"version": "v1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactphp/stream.git",
|
||||
"reference": "50426855f7a77ddf43b9266c22320df5bf6c6ce6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/reactphp/stream/zipball/50426855f7a77ddf43b9266c22320df5bf6c6ce6",
|
||||
"reference": "50426855f7a77ddf43b9266c22320df5bf6c6ce6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
|
||||
"php": ">=5.3.8",
|
||||
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"clue/stream-filter": "~1.2",
|
||||
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"React\\Stream\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP",
|
||||
"keywords": [
|
||||
"event-driven",
|
||||
"io",
|
||||
"non-blocking",
|
||||
"pipe",
|
||||
"reactphp",
|
||||
"readable",
|
||||
"stream",
|
||||
"writable"
|
||||
],
|
||||
"time": "2019-01-01 16:15:09"
|
||||
},
|
||||
{
|
||||
"name": "ringcentral/psr7",
|
||||
"version": "1.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ringcentral/psr7.git",
|
||||
"reference": "dcd84bbb49b96c616d1dcc8bfb9bef3f2cd53d1c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ringcentral/psr7/zipball/dcd84bbb49b96c616d1dcc8bfb9bef3f2cd53d1c",
|
||||
"reference": "dcd84bbb49b96c616d1dcc8bfb9bef3f2cd53d1c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"psr/http-message": "~1.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-message-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RingCentral\\Psr7\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
}
|
||||
],
|
||||
"description": "PSR-7 message implementation",
|
||||
"keywords": [
|
||||
"http",
|
||||
"psr",
|
||||
"psr-7"
|
||||
"message",
|
||||
"stream",
|
||||
"uri"
|
||||
],
|
||||
"time": "2017-01-23 04:53:24"
|
||||
"time": "2018-01-15 21:00:49"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
$server = new PHPEnv\Server();
|
||||
$server->run();
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
use PhpParser\ParserFactory;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use React\Http\Server;
|
||||
use RingCentral\Psr7\Response;
|
||||
|
||||
const V1_CODEPATH = '/userfunc/user';
|
||||
const V1_USER_FUNCTION = 'handler';
|
||||
const HANDLER_DIVIDER = '::';
|
||||
|
||||
$codePath = null;
|
||||
$userFunction = null;
|
||||
$logger = new Logger("Function");
|
||||
$logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
|
||||
|
||||
|
||||
$loop = React\EventLoop\Factory::create();
|
||||
|
||||
$server = new Server(function (ServerRequestInterface $request) use (&$codePath, &$userFunction, $logger) {
|
||||
$path = $request->getUri()->getPath();
|
||||
$method = $request->getMethod();
|
||||
|
||||
if ('/specialize' === $path && 'POST' === $method) {
|
||||
$codePath = V1_CODEPATH;
|
||||
$userFunction = V1_USER_FUNCTION;
|
||||
|
||||
return new Response(201);
|
||||
}
|
||||
|
||||
if ('/v2/specialize' === $path && 'POST' === $method) {
|
||||
$body = json_decode($request->getBody()->getContents(), true);
|
||||
$filepath = $body['filepath'];
|
||||
list ($moduleName, $userFunction) = explode(HANDLER_DIVIDER, $body['functionName']);
|
||||
if (true === is_dir($filepath)) {
|
||||
$codePath = $filepath . DIRECTORY_SEPARATOR . $moduleName;
|
||||
|
||||
} else {
|
||||
$codePath = $filepath;
|
||||
}
|
||||
|
||||
return new Response(201);
|
||||
}
|
||||
if ('/' === $path) {
|
||||
if (null === $codePath) {
|
||||
$logger->error("$codePath not found");
|
||||
return new Response(500, [], 'Generic container: no requests supported');
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
if (!file_exists($codePath)) {
|
||||
$logger->error("$codePath not found");
|
||||
return new Response(500, [], "$codePath not found");
|
||||
}
|
||||
|
||||
$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
|
||||
try {
|
||||
$parser->parse(file_get_contents($codePath));
|
||||
} catch (Throwable $throwable) {
|
||||
$logger->error($codePath . ' - ' . $throwable->getMessage());
|
||||
return new Response(500, [], $codePath . ' - ' . $throwable->getMessage());
|
||||
}
|
||||
|
||||
require_once $codePath;
|
||||
|
||||
//If the function as an handler class it will be called with request, response and logger
|
||||
if (function_exists($userFunction)) {
|
||||
$response = new Response();
|
||||
ob_end_clean();
|
||||
$userFunction(['request' =>$request, 'response' => $response, 'logger' => $logger]);
|
||||
return $response;
|
||||
}
|
||||
//backwards compatibility: php code didn't have userFunction, i will return the content
|
||||
$bodyRowContent = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return new Response(200, [], $bodyRowContent);
|
||||
}
|
||||
|
||||
return new Response(404, ['Content-Type' => 'text/plain'], 'Not found');
|
||||
});
|
||||
|
||||
$socket = new React\Socket\Server('0.0.0.0:8888', $loop);
|
||||
$server->listen($socket);
|
||||
|
||||
$loop->run();
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PHPEnv;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Zend\Diactoros\ServerRequest;
|
||||
use Zend\Diactoros\Response;
|
||||
use Zend\Diactoros\Server as ZendServer;
|
||||
|
||||
class Server {
|
||||
private $server;
|
||||
|
||||
public function __construct(){
|
||||
$codepath = '/userfunc/user';
|
||||
|
||||
//if i have a local function i use it
|
||||
$devcodepath = '/app/userfuncdev.php';
|
||||
if(file_exists($devcodepath))
|
||||
$codepath = $devcodepath;
|
||||
|
||||
$logger = new Logger("Function");
|
||||
$logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
|
||||
|
||||
$this->server = ZendServer::createServer(
|
||||
function (ServerRequest $request, Response $response) use ($logger, $codepath) {
|
||||
$path = parse_url($request->getUri(), PHP_URL_PATH);
|
||||
|
||||
if($path == "/specialize" && $request->getMethod() == "POST"){
|
||||
//Nothing to do
|
||||
return new Response\EmptyResponse(201);
|
||||
}else{
|
||||
if(!file_exists($codepath)){
|
||||
$response = $response->withStatus(500);
|
||||
$response->getBody()->write("Generic container: no requests supported");
|
||||
return $response;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
include($codepath);
|
||||
//If the function as an handler class it will be called with request, response and logger
|
||||
if(function_exists("handler")){
|
||||
ob_end_clean();
|
||||
return handler(array("request"=>$request, "response"=>$response,"logger"=>$logger));
|
||||
}
|
||||
//php code didn't have handler function, i will return the content
|
||||
$bodyRowContent = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $response->getBody()->write($bodyRowContent);
|
||||
}
|
||||
},
|
||||
$_SERVER,
|
||||
$_GET,
|
||||
$_POST,
|
||||
$_COOKIE,
|
||||
$_FILES
|
||||
);
|
||||
}
|
||||
|
||||
public function run(){
|
||||
$this->server->listen();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user