From 44b752ec68a6ec26ad27d91f02609fa0dc6cd368 Mon Sep 17 00:00:00 2001 From: Koldo Picaza <1093654+kpicaza@users.noreply.github.com> Date: Mon, 3 Jul 2023 19:33:54 +0200 Subject: [PATCH] Enable 2.0 framework support --- composer.json | 38 +++++------------ config/cli-config.php | 2 +- config/config.php | 5 +-- config/services/dependencies.dev.php | 9 ++++ config/services/dependencies.dev.php.dist | 9 ++++ config/services/dependencies.dev.yaml.dist | 8 ---- config/services/dependencies.prod.php | 42 +++++++++++++++++++ config/services/dependencies.prod.yaml | 26 ------------ router/routes.php | 4 +- .../Command/SomeCommandExample.php | 2 +- src/{Application => }/Event/SomeEvent.php | 2 +- .../EventListener/SomeEventListener.php | 5 +-- .../Http => }/Handler/HomePage.php | 4 +- .../Http => }/Handler/SomeMiddleware.php | 2 +- 14 files changed, 82 insertions(+), 76 deletions(-) create mode 100644 config/services/dependencies.dev.php create mode 100644 config/services/dependencies.dev.php.dist delete mode 100644 config/services/dependencies.dev.yaml.dist create mode 100644 config/services/dependencies.prod.php delete mode 100644 config/services/dependencies.prod.yaml rename src/{Application => }/Command/SomeCommandExample.php (92%) rename src/{Application => }/Event/SomeEvent.php (88%) rename src/{Application => }/EventListener/SomeEventListener.php (81%) rename src/{Application/Http => }/Handler/HomePage.php (92%) rename src/{Application/Http => }/Handler/SomeMiddleware.php (92%) diff --git a/composer.json b/composer.json index d45e14f..2345758 100644 --- a/composer.json +++ b/composer.json @@ -7,39 +7,27 @@ "name": "kpicaza" } ], - "repositories": [ - { - "type": "git", - "url": "https://github.com/antidot-framework/psr11-monolog" - } - ], "require": { - "php": ">=8.1", + "php": "~8.1.0 || ~8.2.0", "ext-json": "*", - "antidot-fw/cli": "^1.1.0", - "antidot-fw/container": "^0.1.5", + "antidot-fw/cli": "^2.0", + "antidot-fw/container": "^2.0", "antidot-fw/event-dispatcher": "^2.1", - "antidot-fw/framework": "2.0.0BETA1", - "antidot-fw/logger": "^1.1.0", - "antidot-fw/monolog-react-handler": "^0.1", - "antidot-fw/runtime": "^0.2", - "antidot-fw/symfony-config-translator": "^1.1.0", - "antidot-fw/yaml-config-provider": "^0.1.0", - "react/async": "@dev", - "symfony/runtime": "^5.3", - "wshafer/psr11-monolog": "@dev" + "antidot-fw/framework": "^2.0", + "antidot-fw/logger": "^2.0", + "antidot-fw/runtime": "^2.0", + "laminas/laminas-config-aggregator": "^1.13" }, "require-dev": { - "antidot-fw/dev-tools": "^0.1.1", - "filp/whoops": "^2.5", + "antidot-fw/dev-tools": "^2.0", "franzl/whoops-middleware": "^2.0", - "laminas/laminas-component-installer": "^2.6", + "laminas/laminas-component-installer": "^3.2", "phpro/grumphp": "~1.0", "phpstan/phpstan": "^1.2", "phpunit/phpunit": "^9.2", "roave/security-advisories": "dev-master", "squizlabs/php_codesniffer": "^3.4", - "symfony/var-dumper": "^5.1" + "symfony/var-dumper": "^5.1 || ^6.0" }, "autoload": { "psr-4": { @@ -80,12 +68,8 @@ "antidot-fw/doctrine", "antidot-fw/message-queue", "antidot-fw/no-floc-middleware", - "antidot-fw/session", "antidot-fw/cli", - "antidot-fw/phug-template-renderer", - "antidot-fw/event-dispatcher", - "antidot-fw/symfony-config-translator", - "wshafer/psr11-monolog" + "antidot-fw/event-dispatcher" ] } } diff --git a/config/cli-config.php b/config/cli-config.php index cb936e8..7c0b0fb 100644 --- a/config/cli-config.php +++ b/config/cli-config.php @@ -3,7 +3,7 @@ declare(strict_types=1); use Laminas\ConfigAggregator\ArrayProvider; -use Antidot\SymfonyConfigTranslator\Container\Config\ConfigAggregator; +use Laminas\ConfigAggregator\ConfigAggregator; $config = require __DIR__ . '/config.php'; $cliConfig['services'] = $config['console']['services'] ?? []; diff --git a/config/config.php b/config/config.php index 37776c3..d1d5850 100644 --- a/config/config.php +++ b/config/config.php @@ -3,9 +3,8 @@ declare(strict_types=1); use Antidot\DevTools\Container\Config\ConfigProvider as DevToolsConfigProvider; -use Antidot\SymfonyConfigTranslator\Container\Config\ConfigAggregator; -use Antidot\Yaml\YamlConfigProvider; use Laminas\ConfigAggregator\ArrayProvider; +use Laminas\ConfigAggregator\ConfigAggregator; use Laminas\ConfigAggregator\PhpFileProvider; // To enable or disable caching, set the `ConfigAggregator::ENABLE_CACHE` boolean in @@ -17,7 +16,6 @@ $aggregator = new ConfigAggregator([ \Antidot\Framework\Config\ConfigProvider::class, \Antidot\Runtime\Config\ConfigProvider::class, - \WShafer\PSR11MonoLog\ConfigProvider::class, \Antidot\Logger\Container\Config\ConfigProvider::class, \Antidot\Event\Container\Config\ConfigProvider::class, \Antidot\Cli\Container\Config\ConfigProvider::class, @@ -33,7 +31,6 @@ class_exists(DevToolsConfigProvider::class) ? DevToolsConfigProvider::class : fn // - `*.local.yaml` // - `*.dev.yaml` new PhpFileProvider(realpath(__DIR__).'/services/{{,*.}prod,{,*.}local,{,*.}dev}.php'), - new YamlConfigProvider(realpath(__DIR__).'/services/{{,*.}prod,{,*.}local,{,*.}dev}.yaml'), new ArrayProvider($cacheConfig), ], $cacheConfig['config_cache_path']); diff --git a/config/services/dependencies.dev.php b/config/services/dependencies.dev.php new file mode 100644 index 0000000..ca2aa5a --- /dev/null +++ b/config/services/dependencies.dev.php @@ -0,0 +1,9 @@ + true, + 'config_cache_enabled' => false, + 'log_level' => 'DEBUG', +]; diff --git a/config/services/dependencies.dev.php.dist b/config/services/dependencies.dev.php.dist new file mode 100644 index 0000000..ca2aa5a --- /dev/null +++ b/config/services/dependencies.dev.php.dist @@ -0,0 +1,9 @@ + true, + 'config_cache_enabled' => false, + 'log_level' => 'DEBUG', +]; diff --git a/config/services/dependencies.dev.yaml.dist b/config/services/dependencies.dev.yaml.dist deleted file mode 100644 index fd5a07b..0000000 --- a/config/services/dependencies.dev.yaml.dist +++ /dev/null @@ -1,8 +0,0 @@ -parameters: - debug: true - config_cache_enabled: false - monolog: - handlers: - default: - options: - level: 0 diff --git a/config/services/dependencies.prod.php b/config/services/dependencies.prod.php new file mode 100644 index 0000000..3ee4bd0 --- /dev/null +++ b/config/services/dependencies.prod.php @@ -0,0 +1,42 @@ + false, + 'config_cache_enabled' => true, + 'log_level' => 'WARNING', + 'server' => [ + 'workers' => 4, + 'host' => '0.0.0.0', + 'port' => 3000, + ], + // Dependencies + 'services' => [ + HomePage::class => HomePage::class, + SomeMiddleware::class => SomeMiddleware::class, + SomeEventListener::class => SomeEventListener::class, + ], + 'app-events' => [ + 'event-listeners' => [ + SomeEvent::class => [ + SomeEventListener::class, + ], + ], + ], + 'console' => [ + 'commands' => [ + 'my:custom:command' => SomeCommandExample::class, + ], + 'services' => [ + SomeCommandExample::class => SomeCommandExample::class, + ], + ], +]; diff --git a/config/services/dependencies.prod.yaml b/config/services/dependencies.prod.yaml deleted file mode 100644 index 99106ce..0000000 --- a/config/services/dependencies.prod.yaml +++ /dev/null @@ -1,26 +0,0 @@ -services: - App\Application\Http\Handler\HomePage: - App\Application\Http\Handler\SomeMiddleware: - App\Application\EventListener\SomeEventListener: - tags: - - { name: 'event_listener', event: 'App\Application\Event\SomeEvent' } - some.command: - class: App\Application\Command\SomeCommandExample - tags: - - { name: 'console.command', command: 'my:custom:command' } - Psr\EventDispatcher\EventDispatcherInterface: - factory: Antidot\Event\Container\AsyncEventDispatcherFactory - -parameters: - debug: false - config_cache_enabled: true - server: - workers: 8 - host: 127.0.0.1 - port: 3000 - monolog: - handlers: - default: - type: 'echo' - options: - level: 400 diff --git a/router/routes.php b/router/routes.php index 53fe3aa..30a35df 100644 --- a/router/routes.php +++ b/router/routes.php @@ -3,8 +3,8 @@ declare(strict_types=1); use Antidot\Framework\Application; -use App\Application\Http\Handler\HomePage; -use App\Application\Http\Handler\SomeMiddleware; +use App\Handler\HomePage; +use App\Handler\SomeMiddleware; use Psr\Container\ContainerInterface; /** diff --git a/src/Application/Command/SomeCommandExample.php b/src/Command/SomeCommandExample.php similarity index 92% rename from src/Application/Command/SomeCommandExample.php rename to src/Command/SomeCommandExample.php index 4e75106..f3c5ab1 100644 --- a/src/Application/Command/SomeCommandExample.php +++ b/src/Command/SomeCommandExample.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Command; +namespace App\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Application/Event/SomeEvent.php b/src/Event/SomeEvent.php similarity index 88% rename from src/Application/Event/SomeEvent.php rename to src/Event/SomeEvent.php index d89adef..f0ea943 100644 --- a/src/Application/Event/SomeEvent.php +++ b/src/Event/SomeEvent.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Event; +namespace App\Event; use Antidot\Event\Event; diff --git a/src/Application/EventListener/SomeEventListener.php b/src/EventListener/SomeEventListener.php similarity index 81% rename from src/Application/EventListener/SomeEventListener.php rename to src/EventListener/SomeEventListener.php index 4115fb6..e957440 100644 --- a/src/Application/EventListener/SomeEventListener.php +++ b/src/EventListener/SomeEventListener.php @@ -2,11 +2,10 @@ declare(strict_types=1); -namespace App\Application\EventListener; +namespace App\EventListener; -use App\Application\Event\SomeEvent; use Psr\Log\LoggerInterface; - +use App\Event\SomeEvent; use function sprintf; final class SomeEventListener diff --git a/src/Application/Http/Handler/HomePage.php b/src/Handler/HomePage.php similarity index 92% rename from src/Application/Http/Handler/HomePage.php rename to src/Handler/HomePage.php index e84ea01..9e044ae 100644 --- a/src/Application/Http/Handler/HomePage.php +++ b/src/Handler/HomePage.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace App\Application\Http\Handler; +namespace App\Handler; -use App\Application\Event\SomeEvent; use Psr\EventDispatcher\EventDispatcherInterface; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; +use App\Event\SomeEvent; final class HomePage implements RequestHandlerInterface { diff --git a/src/Application/Http/Handler/SomeMiddleware.php b/src/Handler/SomeMiddleware.php similarity index 92% rename from src/Application/Http/Handler/SomeMiddleware.php rename to src/Handler/SomeMiddleware.php index b9987dc..a116cbe 100644 --- a/src/Application/Http/Handler/SomeMiddleware.php +++ b/src/Handler/SomeMiddleware.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Http\Handler; +namespace App\Handler; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface;