Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Create Symfony Health Check Bundle Routing Config:

```yaml
health_check:
resource: '@SymfonyHealthCheckBundle/Resources/config/routes.xml'
resource: '@SymfonyHealthCheckBundle/Resources/config/routes.php'
```

Step 3: Configuration
Expand Down
10 changes: 5 additions & 5 deletions src/DependencyInjection/SymfonyHealthCheckExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use SymfonyHealthCheckBundle\Controller\HealthController;
use SymfonyHealthCheckBundle\Controller\PingController;

Expand All @@ -20,8 +20,8 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('controller.xml');
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('controller.php');

$this->loadHealthChecks($config, $loader, $container);

Expand All @@ -31,10 +31,10 @@ public function load(array $configs, ContainerBuilder $container): void

private function loadHealthChecks(
array $config,
XmlFileLoader $loader,
PhpFileLoader $loader,
ContainerBuilder $container
): void {
$loader->load('health_checks.xml');
$loader->load('health_checks.php');

$healthCheckCollection = $container->findDefinition(HealthController::class);

Expand Down
25 changes: 25 additions & 0 deletions src/Resources/config/controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use SymfonyHealthCheckBundle\Controller\HealthController;
use SymfonyHealthCheckBundle\Controller\PingController;

return static function (ContainerConfigurator $container) {
$services = $container->services();
$parameters = $container->parameters();

$services->defaults()
->autowire()
->autoconfigure();

$services->set(HealthController::class, HealthController::class)
->public()
->tag('container.service_subscriber');

$services->set(PingController::class, PingController::class)
->public()
->tag('container.service_subscriber');
};
16 changes: 0 additions & 16 deletions src/Resources/config/controller.xml

This file was deleted.

47 changes: 47 additions & 0 deletions src/Resources/config/health_checks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use SymfonyHealthCheckBundle\Adapter\RedisAdapterWrapper;
use SymfonyHealthCheckBundle\Check\DoctrineODMCheck;
use SymfonyHealthCheckBundle\Check\DoctrineORMCheck;
use SymfonyHealthCheckBundle\Check\EnvironmentCheck;
use SymfonyHealthCheckBundle\Check\RedisCheck;
use SymfonyHealthCheckBundle\Check\StatusUpCheck;

return static function (ContainerConfigurator $container) {
$services = $container->services();
$parameters = $container->parameters();

$services->defaults()
->public()
->autowire()
->autoconfigure();

$services->set('symfony_health_check.redis_adapter_wrapper', RedisAdapterWrapper::class)
->private();

$services->set('symfony_health_check.doctrine_check', DoctrineORMCheck::class)
->args([service('service_container')])
->deprecate(
'macpaw/symfony-health-check-bundle',
'1.4.2',
'The "%service_id%" service alias is deprecated, use symfony_health_check.doctrine_orm_check instead'
);

$services->set('symfony_health_check.doctrine_orm_check', DoctrineORMCheck::class)
->args([service('service_container')]);

$services->set('symfony_health_check.doctrine_odm_check', DoctrineODMCheck::class)
->args([service('service_container')]);

$services->set('symfony_health_check.redis_check', RedisCheck::class)
->args([service('symfony_health_check.redis_adapter_wrapper')]);

$services->set('symfony_health_check.environment_check', EnvironmentCheck::class)
->args([service('service_container')]);

$services->set('symfony_health_check.status_up_check', StatusUpCheck::class);
};
28 changes: 0 additions & 28 deletions src/Resources/config/health_checks.xml

This file was deleted.

19 changes: 19 additions & 0 deletions src/Resources/config/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use SymfonyHealthCheckBundle\Controller\HealthController;
use SymfonyHealthCheckBundle\Controller\PingController;

return function (RoutingConfigurator $routes): void {
$routes->add('health', '/health')
->controller([HealthController::class, 'check'])
->methods(['GET']);

$routes->add('ping', '/ping')
->controller([PingController::class, 'check'])
->methods(['GET']);
};
19 changes: 0 additions & 19 deletions src/Resources/config/routes.xml

This file was deleted.

2 changes: 1 addition & 1 deletion tests/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
framework:
secret: secret
router:
resource: "%kernel.project_dir%/Resources/config/routes.xml"
resource: "%kernel.project_dir%/Resources/config/routes.php"
test: ~
Loading