PHP code example of fcpl / phpstan-container-extension

1. Go to this page and download the library: Download fcpl/phpstan-container-extension 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/ */

    

fcpl / phpstan-container-extension example snippets


use Monolog\Handler\HandlerInterface;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Pimple\Container;
use Pimple\Psr11\ServiceLocator;
use Psr\Log\LoggerInterface;
...
    $container = new Container();
    $container->offsetSet(HandlerInterface::class, new StreamHandler($this->getLogFile()));
    $container->offsetSet(
        LoggerInterface::class,
        function (Container $container): Logger {
            /** @var HandlerInterface $streamHandler */
            $streamHandler = $container->offsetGet(HandlerInterface::class);
            return new Logger(self::class, [$streamHandler]);
        }
    );
    return new ServiceLocator($container, [LoggerInterface::class, ConverterFileInterface::class]);
...