Skip to content

Instantly share code, notes, and snippets.

@lyrixx
Last active July 18, 2024 09:51
Show Gist options
  • Select an option

  • Save lyrixx/2ea147609dc632d26e366aef60f61a9f to your computer and use it in GitHub Desktop.

Select an option

Save lyrixx/2ea147609dc632d26e366aef60f61a9f to your computer and use it in GitHub Desktop.

Revisions

  1. lyrixx revised this gist Sep 18, 2023. 1 changed file with 21 additions and 20 deletions.
    41 changes: 21 additions & 20 deletions test.php
    Original file line number Diff line number Diff line change
    @@ -1,30 +1,31 @@
    <?php

    require __DIR__ . '/vendor/autoload.php';
    use App\Kernel;

    require __DIR__.'/vendor/autoload_runtime.php';

    use Symfony\Component\Console\Output\StreamOutput;
    use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
    use Symfony\Component\DependencyInjection\ContainerBuilder;

    $k = new class('prod', false) extends AppKernel implements CompilerPassInterface {
    public function process(ContainerBuilder $container)
    {
    $container->getAlias('logger')->setPublic(true);
    $container->getDefinition('monolog.handler.console')->setPublic(true);
    }
    };
    $k->boot();
    $c = $k->getContainer();
    return function () {
    $k = new class('dev', true) extends Kernel implements CompilerPassInterface {
    public function process(ContainerBuilder $container)
    {
    $container->getAlias('logger')->setPublic(true);
    $container->getDefinition('monolog.handler.console')->setPublic(true);
    }
    };
    $k->boot();
    $c = $k->getContainer();

    $c->get('monolog.handler.console')->setOutput(
    new StreamOutput(fopen('php://stdout', 'w'),
    StreamOutput::VERBOSITY_VERY_VERBOSE,
    ));
    $logger = $c->get('logger');
    $c->get('monolog.handler.console')->setOutput(
    new StreamOutput(fopen('php://stdout', 'w'),
    StreamOutput::VERBOSITY_VERY_VERBOSE,
    ));

    function is_debug()
    {
    return 'cli' === \PHP_SAPI & 'test.php' === $_SERVER['argv'][0];
    }
    $logger = $c->get('logger');
    $em = $c->get('doctrine.orm.entity_manager');

    // Start of playground
    // Start of playground
    };
  2. lyrixx created this gist Aug 1, 2022.
    30 changes: 30 additions & 0 deletions test.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    <?php

    require __DIR__ . '/vendor/autoload.php';

    use Symfony\Component\Console\Output\StreamOutput;
    use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
    use Symfony\Component\DependencyInjection\ContainerBuilder;

    $k = new class('prod', false) extends AppKernel implements CompilerPassInterface {
    public function process(ContainerBuilder $container)
    {
    $container->getAlias('logger')->setPublic(true);
    $container->getDefinition('monolog.handler.console')->setPublic(true);
    }
    };
    $k->boot();
    $c = $k->getContainer();

    $c->get('monolog.handler.console')->setOutput(
    new StreamOutput(fopen('php://stdout', 'w'),
    StreamOutput::VERBOSITY_VERY_VERBOSE,
    ));
    $logger = $c->get('logger');

    function is_debug()
    {
    return 'cli' === \PHP_SAPI & 'test.php' === $_SERVER['argv'][0];
    }

    // Start of playground