Skip to content

Commit 5d61e21

Browse files
committed
chore(config): symfony yaml configs converted to php format
1 parent c0ea0d4 commit 5d61e21

File tree

5 files changed

+683
-513
lines changed

5 files changed

+683
-513
lines changed

src/Bridge/Symfony/Bundle/DependencyInjection/SwooleExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
use Symfony\Component\DependencyInjection\ContainerBuilder;
5252
use Symfony\Component\DependencyInjection\Definition;
5353
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
54-
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
54+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
5555
use Symfony\Component\DependencyInjection\Reference;
5656
use Symfony\Component\ErrorHandler\ErrorHandler;
5757
use Symfony\Component\Filesystem\Filesystem;
@@ -72,9 +72,9 @@ public function prepend(ContainerBuilder $container): void
7272
public function load(array $configs, ContainerBuilder $container): void
7373
{
7474
$configuration = Configuration::fromTreeBuilder();
75-
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
76-
$loader->load('services.yaml');
77-
$loader->load('commands.yaml');
75+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
76+
$loader->load('services.php');
77+
$loader->load('commands.php');
7878

7979
$container->registerForAutoconfiguration(BootableInterface::class)
8080
->addTag('swoole_bundle.bootable_service')
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use K911\Swoole\Bridge\Symfony\Bundle\Command\ServerProfileCommand;
6+
use K911\Swoole\Bridge\Symfony\Bundle\Command\ServerReloadCommand;
7+
use K911\Swoole\Bridge\Symfony\Bundle\Command\ServerRunCommand;
8+
use K911\Swoole\Bridge\Symfony\Bundle\Command\ServerStartCommand;
9+
use K911\Swoole\Bridge\Symfony\Bundle\Command\ServerStatusCommand;
10+
use K911\Swoole\Bridge\Symfony\Bundle\Command\ServerStopCommand;
11+
use K911\Swoole\Metrics\MetricsProvider;
12+
use K911\Swoole\Server\Api\ApiServerClientFactory;
13+
use K911\Swoole\Server\Config\Sockets;
14+
use K911\Swoole\Server\Configurator\CallableChainConfigurator;
15+
use K911\Swoole\Server\Configurator\CallableChainConfiguratorFactory;
16+
use K911\Swoole\Server\HttpServer;
17+
use K911\Swoole\Server\HttpServerConfiguration;
18+
use K911\Swoole\Server\Runtime\BootableInterface;
19+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
20+
21+
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
22+
23+
return static function (ContainerConfigurator $containerConfigurator): void {
24+
$services = $containerConfigurator->services();
25+
26+
$services->defaults();
27+
28+
$services->set(ServerStatusCommand::class)
29+
->arg('$sockets', service(Sockets::class))
30+
->arg('$apiServerClientFactory', service(ApiServerClientFactory::class))
31+
->arg('$metricsProvider', service(MetricsProvider::class))
32+
->arg('$parameterBag', service('parameter_bag'))
33+
->tag('console.command', [
34+
'command' => 'swoole:server:status',
35+
])
36+
;
37+
38+
$services->set(ServerStopCommand::class)
39+
->arg('$server', service(HttpServer::class))
40+
->arg('$serverConfiguration', service(HttpServerConfiguration::class))
41+
->arg('$parameterBag', service('parameter_bag'))
42+
->tag('console.command', [
43+
'command' => 'swoole:server:stop',
44+
])
45+
;
46+
47+
$services->set(ServerReloadCommand::class)
48+
->arg('$server', service(HttpServer::class))
49+
->arg('$serverConfiguration', service(HttpServerConfiguration::class))
50+
->arg('$parameterBag', service('parameter_bag'))
51+
->tag('console.command', [
52+
'command' => 'swoole:server:reload',
53+
])
54+
;
55+
56+
$services->set('swoole_bundle.server.http_server.configurator.for_server_start_command', CallableChainConfigurator::class)
57+
->factory([
58+
service(CallableChainConfiguratorFactory::class),
59+
'make',
60+
])
61+
->args([
62+
service('swoole_bundle.server.http_server.configurator_collection'),
63+
service('swoole_bundle.server.http_server.configurator.with_request_handler'),
64+
])
65+
;
66+
67+
$services->set(ServerStartCommand::class)
68+
->arg('$server', service(HttpServer::class))
69+
->arg('$serverConfiguration', service(HttpServerConfiguration::class))
70+
->arg('$serverConfigurator', service('swoole_bundle.server.http_server.configurator.for_server_start_command'))
71+
->arg('$parameterBag', service('parameter_bag'))
72+
->arg('$bootManager', service(BootableInterface::class))
73+
->tag('console.command', [
74+
'command' => 'swoole:server:start',
75+
])
76+
;
77+
78+
$services->set('swoole_bundle.server.http_server.configurator.for_server_run_command', CallableChainConfigurator::class)
79+
->factory([
80+
service(CallableChainConfiguratorFactory::class),
81+
'make',
82+
])
83+
->args([
84+
service('swoole_bundle.server.http_server.configurator_collection'),
85+
service('swoole_bundle.server.http_server.configurator.with_request_handler'),
86+
service('swoole_bundle.server.http_server.configurator.default_handler'),
87+
])
88+
;
89+
90+
$services->set(ServerRunCommand::class)
91+
->arg('$server', service(HttpServer::class))
92+
->arg('$serverConfiguration', service(HttpServerConfiguration::class))
93+
->arg('$serverConfigurator', service('swoole_bundle.server.http_server.configurator.for_server_run_command'))
94+
->arg('$parameterBag', service('parameter_bag'))
95+
->arg('$bootManager', service(BootableInterface::class))
96+
->tag('console.command', [
97+
'command' => 'swoole:server:run',
98+
])
99+
;
100+
101+
$services->set('swoole_bundle.server.http_server.configurator.for_server_profile_command', CallableChainConfigurator::class)
102+
->factory([
103+
service(CallableChainConfiguratorFactory::class),
104+
'make',
105+
])
106+
->args([
107+
service('swoole_bundle.server.http_server.configurator_collection'),
108+
service('swoole_bundle.server.http_server.configurator.with_limited_request_handler'),
109+
service('swoole_bundle.server.http_server.configurator.default_handler'),
110+
])
111+
;
112+
113+
$services->set(ServerProfileCommand::class)
114+
->arg('$server', service(HttpServer::class))
115+
->arg('$serverConfiguration', service(HttpServerConfiguration::class))
116+
->arg('$serverConfigurator', service('swoole_bundle.server.http_server.configurator.for_server_profile_command'))
117+
->arg('$parameterBag', service('parameter_bag'))
118+
->arg('$bootManager', service(BootableInterface::class))
119+
->tag('console.command', [
120+
'command' => 'swoole:server:profile',
121+
])
122+
;
123+
};

src/Bridge/Symfony/Bundle/Resources/config/commands.yaml

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)