pedrotroller / symfony-integration-checker
Assert that your bundle integration with symfony is still working.
Installs: 3 527
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.2
- symfony/config: ^3.4|^4.3|^5.0
- symfony/dependency-injection: ^3.4|^4.3|^5.0
- symfony/http-kernel: ^3.4|^4.3|^5.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16.1
- pedrotroller/php-cs-custom-fixer: ^2.19
- symfony/framework-bundle: ^3.4|^4.3|^5.0
- symfony/translation: ^3.4|^4.3|^5.0
README
Installation
$ composer require pedrotroller/symfony-integration-checker --dev
Usage
You just have to create a .symfony_checker
. This script should return a callback. This callback will have an instance of PedroTroller\Symfony\IntegrationChecker\ConfigurableKernel
as parameter.
use PedroTroller\Symfony\IntegrationChecker\ConfigurableKernel; return function (ConfigurableKernel $kernel) { // Your configuration };
Launch the checker
$ ./bin/symfony-integration-checker check
Available kernel customization
$kernel->addBundle(BundleInterface $bundle)
: you can dynamically inject bundles into your kernel.
$kernel->setConfig(array $config)
: inject a configuration.
$kernel->setContainerBuilder(ContainerBuilder $container)
: inject your own container.
$kernel->afterBoot(callable $callable)
: inject a callable. This callable will be executed after the kernel boot.
Example
<?php use PedroTroller\Symfony\IntegrationChecker\ConfigurableKernel; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Translation\TranslatorInterface; $config = array( 'framework' => array( 'translator' => array( 'enabled' => true, ), ), ); $test = function (KernelInterface $kernel) { if (false === $kernel->getContainer()->get('translator') instanceof TranslatorInterface) { throw new \Exception('Oups, there is a problem !'); } }; return function (ConfigurableKernel $kernel) use ($config, $test) { $container = new ContainerBuilder(); $container->setParameter('kernel.secret', md5(time())); $kernel ->setContainerBuilder($container) ->setConfig($config) ->addBundle(new FrameworkBundle()) ->afterBoot($test) ; };