PHP code example of yceruto / micro-symfony

1. Go to this page and download the library: Download yceruto/micro-symfony library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yceruto / micro-symfony example snippets


namespace Acme\FooBundle;

use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
// ...

class AcmeFooBundle extends AbstractBundle
{
    public function prependExtension(ContainerConfigurator $container, ContainerBuilder $builder): void
    {
        // prepend config from a config file
        $container->import('../config/packages/cache.yaml');
    }
}

// index.php

use MicroSymfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\HttpKernel\Kernel;

class StripeWebhookEventSubscriber extends Kernel
{
    use MicroKernelTrait;

    #[Route('/', methods: 'GET')]
    public function __invoke(Request $request, NotifierInterface $notifier): Response
    {
        // parse the webhook event and notify the user...
    
        return new Response('OK');
    }
}

return static function (array $context) {
    $kernel = new StripeWebhookEventSubscriber($context['APP_ENV'], (bool) $context['APP_DEBUG']);

    return \PHP_SAPI === 'cli' ? new Application($kernel) : $kernel;
};

return new EventStreamResponse(function () {
    yield new ServerEvent(time(), type: 'ping');

    sleep(1);
    
    yield new ServerEvent(time(), type: 'ping');
});
bash
$ php index.php cache:clear