function __construct(Config $config, Context $context) { error_reporting(E_ALL); ini_set("display_errors", "1"); $this->context = $context; $this->registerExceptionHandler(); $context->bind(DebugBar::class, $this->debugBar = new StandardDebugBar()); $this->debugBar->setStorage(new FileStorage('/tmp/debugbar_storage')); $context->bind(Config::class, $config); $this->init(); $config->parseDir(path('root')); if (isHttp() && !implicitDev()) { die('Unauthorized for dev!'); } }
public function __invoke(ContainerInterface $container = null) { $debugBar = new StandardDebugBar(); if ($container !== null) { $config = $container->has('config') ? $container->get('config') : []; $collectors = isset($config['phpmiddleware']['phpdebugbar']['collectors']) ? $config['phpmiddleware']['phpdebugbar']['collectors'] : []; foreach ($collectors as $collectorName) { $collector = $container->get($collectorName); $debugBar->addCollector($collector); } if (isset($config['phpmiddleware']['phpdebugbar']['storage']) && is_string($config['phpmiddleware']['phpdebugbar']['storage'])) { $storage = $container->get($config['phpmiddleware']['phpdebugbar']['storage']); $debugBar->setStorage($config['phpmiddleware']['phpdebugbar']['storage']); } } return $debugBar; }
/** * @param string $pathToDir */ public function setStorage($pathToDir) { $this->debugBar->setStorage(new Storage\FileStorage($pathToDir)); }