Skip to content

Commit

Permalink
feat(platform): added integrations for PHP 8.1 + added support for Sy…
Browse files Browse the repository at this point in the history
…mfony 6
  • Loading branch information
Rastusik committed Jul 27, 2022
1 parent 12a24d6 commit 368f99e
Show file tree
Hide file tree
Showing 25 changed files with 414 additions and 155 deletions.
62 changes: 60 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ orbs:
executors:
pixelfederation-docker-client:
docker:
- image: pixelfederation/docker-client:20.10.5-compose
- image: pixelfederation/docker-client:20.10.17-compose
working_directory: ~/workdir

pixelfederation-release-version:
Expand All @@ -17,7 +17,7 @@ aliases:
- &docker-remote-version
setup_remote_docker:
# https://circleci.com/docs/2.0/building-docker-images/#docker-version
version: 20.10.2
version: 20.10.14

- &docker-bake
executor: pixelfederation-docker-client
Expand All @@ -41,6 +41,9 @@ aliases:
- run:
name: Print docker info
command: docker info
- run:
name: Docker pass initialization
command: docker-use-pass
- run:
name: Login to Docker Hub
command: >-
Expand Down Expand Up @@ -146,6 +149,11 @@ jobs:
docker:
- image: docker.io/pixelfederation/swoole-bundle-composer:8.0-latest-$CIRCLE_SHA1

swoole-bundle-composer-81-latest-unit-tests:
<<: *job-composer-unit-tests
docker:
- image: docker.io/pixelfederation/swoole-bundle-composer:8.1-latest-$CIRCLE_SHA1

swoole-bundle-composer-74-lowest-feature-tests:
<<: *job-composer-feature-tests
docker:
Expand All @@ -156,6 +164,11 @@ jobs:
docker:
- image: docker.io/pixelfederation/swoole-bundle-composer:8.0-latest-$CIRCLE_SHA1

swoole-bundle-composer-81-latest-feature-tests:
<<: *job-composer-feature-tests
docker:
- image: docker.io/pixelfederation/swoole-bundle-composer:8.1-latest-$CIRCLE_SHA1

swoole-bundle-74-code-coverage:
executor: pixelfederation-docker-client
environment:
Expand Down Expand Up @@ -285,6 +298,19 @@ jobs:
SERVICES: composer
BUILD_TYPE: latest

docker-buildx-bake-81-latest:
<<: *docker-bake
environment:
PHP_VERSION: "8.1"
PHP_API_VERSION: "20210902"
COMPOSER_ARGS: update
SWOOLE_VERSION: latest
REGISTRY: docker.io
NAMESPACE: pixelfederation
IMAGE: swoole-bundle
SERVICES: composer
BUILD_TYPE: latest

check-composer-config:
docker:
- image: composer:2
Expand Down Expand Up @@ -376,6 +402,16 @@ workflows:
- swoole-bundle-composer-80-latest-feature-tests:
requires:
- docker-buildx-bake-80-latest
- docker-buildx-bake-81-latest:
context: swoole-bundle-dockerhub
requires:
- docker-buildx-bake-74
- swoole-bundle-composer-81-latest-unit-tests:
requires:
- docker-buildx-bake-81-latest
- swoole-bundle-composer-81-latest-feature-tests:
requires:
- docker-buildx-bake-81-latest

pull-request-checks-untrusted:
when:
Expand Down Expand Up @@ -432,6 +468,16 @@ workflows:
- swoole-bundle-composer-80-latest-feature-tests:
requires:
- docker-buildx-bake-80-latest
- docker-buildx-bake-81-latest:
context: swoole-bundle-dockerhub
requires:
- docker-buildx-bake-74
- swoole-bundle-composer-81-latest-unit-tests:
requires:
- docker-buildx-bake-81-latest
- swoole-bundle-composer-81-latest-feature-tests:
requires:
- docker-buildx-bake-81-latest

release:
when:
Expand Down Expand Up @@ -479,6 +525,16 @@ workflows:
- swoole-bundle-composer-80-latest-feature-tests:
requires:
- docker-buildx-bake-80-latest
- docker-buildx-bake-81-latest:
context: swoole-bundle-dockerhub
requires:
- docker-buildx-bake-74
- swoole-bundle-composer-81-latest-unit-tests:
requires:
- docker-buildx-bake-81-latest
- swoole-bundle-composer-81-latest-feature-tests:
requires:
- docker-buildx-bake-81-latest
- approve-release:
type: approval
requires:
Expand All @@ -491,6 +547,8 @@ workflows:
- swoole-bundle-composer-74-code-style
- swoole-bundle-composer-80-latest-unit-tests
- swoole-bundle-composer-80-latest-feature-tests
- swoole-bundle-composer-81-latest-unit-tests
- swoole-bundle-composer-81-latest-feature-tests
- releaser:
context: swoole-bundle-github
requires:
Expand Down
24 changes: 21 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,28 @@ matrix:
- php: "8.0"
env:
- OPENSWOOLE_LATEST=1
- COMPOSER_ARGS='update --ignore-platform-reqs'
- COMPOSER_ARGS='update'
- NO_ANALYSE=1
- php: "8.1"
env:
- PHP_CS_FIXER_IGNORE_ENV=1
- php: "8.1"
env:
- OPENSWOOLE_LATEST=1
- COMPOSER_ARGS='update'
- NO_ANALYSE=1
fast_finish: true
allow_failures:
- php: "8.0"
env:
- OPENSWOOLE_LATEST=1
- COMPOSER_ARGS='update --ignore-platform-reqs'
- COMPOSER_ARGS='update'
- NO_ANALYSE=1
- php: "8.1"
env:
- OPENSWOOLE_LATEST=1
- COMPOSER_ARGS='update'
- NO_ANALYSE=1

before_script:
- phpenv config-rm xdebug.ini
Expand All @@ -50,6 +65,9 @@ install:
- composer $COMPOSER_ARGS

script:
- composer analyse
- >-
if [[ "NO_ANALYSE" != "1" ]]; then
composer analyse
fi
- composer unit-tests
- composer feature-tests
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PHP_TAG="7.4-cli-alpine3.13"
ARG PHP_TAG="7.4-cli-alpine3.16"
ARG COMPOSER_TAG="2.2.9"

FROM php:$PHP_TAG as ext-builder
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Symfony integration with [Open Swoole](https://openswoole.com/) to speed up your
- PHP version `>= 8.0`
- Swoole PHP Extension `>= 4.10.0`
- Symfony `>= 5.4`
- Symfony `>= 6.0`
Additional requirements to enable specific features:
Expand Down
31 changes: 15 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"ext-json": "*",
"ext-openswoole": "^4.10.0",
"beberlei/assert": "^3.3",
"symfony/config": "^5.4",
"symfony/console": "^5.4",
"symfony/dependency-injection": "^5.4",
"symfony/http-foundation": "^5.4",
"symfony/http-kernel": "^5.4",
"symfony/process": "^5.4",
"symfony/proxy-manager-bridge": "^5.4"
"symfony/config": "^5.4|^6.0",
"symfony/console": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/http-foundation": "^5.4|^6.0",
"symfony/http-kernel": "^5.4|^6.0",
"symfony/process": "^5.4|^6.0",
"symfony/proxy-manager-bridge": "^5.4|^6.0"
},
"require-dev": {
"doctrine/annotations": "^1.13",
Expand All @@ -54,16 +54,16 @@
"ramsey/uuid": "^4.1",
"swoole/ide-helper": "^4.8",
"symfony/debug-pack": "^1.0",
"symfony/doctrine-messenger": "^5.4",
"symfony/error-handler": "^5.4",
"symfony/framework-bundle": "^5.4",
"symfony/messenger": "^5.4",
"symfony/monolog-bridge": "^5.4",
"symfony/doctrine-messenger": "^5.4|^6.0",
"symfony/error-handler": "^5.4|^6.0",
"symfony/framework-bundle": "^5.4|^6.0",
"symfony/messenger": "^5.4|^6.0",
"symfony/monolog-bridge": "^5.4|^6.0",
"symfony/monolog-bundle": "^3.3",
"symfony/profiler-pack": "^1.0",
"symfony/twig-bundle": "^5.4",
"symfony/var-dumper": "^5.4",
"symfony/yaml": "^5.4",
"symfony/twig-bundle": "^5.4|^6.0",
"symfony/var-dumper": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0",
"upscale/swoole-blackfire": "^3.1"
},
"suggest": {
Expand Down Expand Up @@ -141,7 +141,6 @@
"process-timeout": 1200,
"sort-packages": true,
"platform": {
"php": "7.4.13",
"ext-swoole": "4.5.10"
},
"allow-plugins": {
Expand Down
5 changes: 2 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: "3.8"
x-env-aliases:
- &DEFAULT_BUILD_ARGS
PHP_TAG: "${PHP_VERSION:-7.4}-cli-alpine${ALPINE_VERSION:-3.13}"
PHP_TAG: "${PHP_VERSION:-7.4}-cli-alpine${ALPINE_VERSION:-3.16}"
PHP_API_VERSION: "${PHP_API_VERSION:-20190902}"
COMPOSER_ARGS: "${COMPOSER_ARGS:-install}"
SWOOLE_VERSION: "${SWOOLE_VERSION:-4.10.0}"
COMPOSER_TAG: "${COMPOSER_TAG:-2.0.11}"
COMPOSER_TAG: "${COMPOSER_TAG:-2.3.10}"

volumes:
coverage: {}
Expand Down Expand Up @@ -90,7 +90,7 @@ services:
- coverage:/usr/src/app/cov

coverage-volume-helper:
image: "alpine:${ALPINE_VERSION:-3.13}"
image: "alpine:${ALPINE_VERSION:-3.16}"
entrypoint: sleep
command: infinity
working_dir: /usr/src/app
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace K911\Swoole\Bridge\Symfony\Bundle\DependencyInjection\CompilerPass;

use K911\Swoole\Bridge\Symfony\HttpFoundation\Session\SessionCookieEventListener;
use K911\Swoole\Server\Session\StorageInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

final class SessionStorageListenerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (!$container->hasAlias('session.storage.factory')) {
return;
}

$factoryAlias = $container->getAlias('session.storage.factory');

if ('swoole_bundle.session.table_storage_factory' !== (string) $factoryAlias) {
return;
}

$cookieListenerDef = new Definition(SessionCookieEventListener::class);
$cookieListenerDef->setPublic(false);
$cookieListenerDef->setArgument('$requestStack', new Reference('request_stack'));
$cookieListenerDef->setArgument('$dispatcher', new Reference('event_dispatcher'));
$cookieListenerDef->setArgument('$swooleStorage', new Reference(StorageInterface::class));
$cookieListenerDef->setArgument('$sessionOptions', $container->getParameter('session.storage.options'));
$cookieListenerDef->addTag('kernel.event_subscriber');
$container->setDefinition(SessionCookieEventListener::class, $cookieListenerDef);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,6 @@ public function getConfigTreeBuilder(): TreeBuilder
->booleanNode('blackfire_profiler')
->defaultNull()
->end()
->booleanNode('session_cookie_event_listener')
->defaultFalse()
->treatNullLike(false)
->end()
->end()
->end() // drivers
->arrayNode('settings')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use K911\Swoole\Bridge\Symfony\ErrorHandler\ThrowableHandlerFactory;
use K911\Swoole\Bridge\Symfony\HttpFoundation\CloudFrontRequestFactory;
use K911\Swoole\Bridge\Symfony\HttpFoundation\RequestFactoryInterface;
use K911\Swoole\Bridge\Symfony\HttpFoundation\Session\SetSessionCookieEventListener;
use K911\Swoole\Bridge\Symfony\HttpFoundation\TrustAllProxiesRequestHandler;
use K911\Swoole\Bridge\Symfony\Messenger\SwooleServerTaskTransportFactory;
use K911\Swoole\Bridge\Symfony\Messenger\SwooleServerTaskTransportHandler;
Expand Down Expand Up @@ -290,14 +289,6 @@ private function registerHttpServerServices(array $config, ContainerBuilder $con
;
}

if ($config['session_cookie_event_listener']) {
$container->register(SetSessionCookieEventListener::class)
->setAutowired(true)
->setAutoconfigured(true)
->setPublic(false)
;
}

if ($config['blackfire_profiler'] || (null === $config['blackfire_profiler'] && \class_exists(Profiler::class))) {
$container->register(Profiler::class)
->setClass(Profiler::class)
Expand Down
5 changes: 5 additions & 0 deletions src/Bridge/Symfony/Bundle/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ services:

K911\Swoole\Bridge\Symfony\HttpKernel\HttpKernelRequestHandler:

K911\Swoole\Bridge\Symfony\HttpFoundation\Session\SwooleSessionStorageFactory:

K911\Swoole\Server\RequestHandler\LimitedRequestHandler:

K911\Swoole\Server\LifecycleHandler\SigIntHandler:
Expand Down Expand Up @@ -155,6 +157,9 @@ services:
swoole_bundle.session.table_storage:
alias: K911\Swoole\Bridge\Symfony\HttpFoundation\Session\SwooleSessionStorage

swoole_bundle.session.table_storage_factory:
alias: K911\Swoole\Bridge\Symfony\HttpFoundation\Session\SwooleSessionStorageFactory

swoole_bundle.server.http_server.configurator.with_request_handler:
class: K911\Swoole\Server\Configurator\WithRequestHandler
autoconfigure: false
Expand Down
2 changes: 2 additions & 0 deletions src/Bridge/Symfony/Bundle/SwooleBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace K911\Swoole\Bridge\Symfony\Bundle;

use K911\Swoole\Bridge\Symfony\Bundle\DependencyInjection\CompilerPass\DebugLogProcessorPass;
use K911\Swoole\Bridge\Symfony\Bundle\DependencyInjection\CompilerPass\SessionStorageListenerPass;
use K911\Swoole\Bridge\Symfony\Bundle\DependencyInjection\CompilerPass\StreamedResponseListenerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
Expand All @@ -15,5 +16,6 @@ public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new DebugLogProcessorPass());
$container->addCompilerPass(new StreamedResponseListenerPass());
$container->addCompilerPass(new SessionStorageListenerPass());
}
}
Loading

0 comments on commit 368f99e

Please sign in to comment.