Skip to content

Commit

Permalink
Add usage examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaposa committed Jun 25, 2017
1 parent 917f8f5 commit 8b8b995
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions examples/setting_error_handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

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

use Phoundation\Bootstrap\Bootstrap;
use Phoundation\Config\Loader\StaticConfigLoader;
use Phoundation\Di\Container\Factory\ZendServiceManagerFactory;
use Phoundation\ErrorHandling\Handler\LogHandler;
use Phoundation\ErrorHandling\RunnerInterface;
use Phoundation\ErrorHandling\WhoopsRunner;
use Psr\Container\ContainerInterface;
use Psr\Log\NullLogger;
use Whoops\Run;

$config = [
'db' => [
'dsn' => 'mysql:dbname=test;host=127.0.0.1',
'user' => 'root',
'password' => 'secret',
],
'di' => [
'factories' => [
//automatically registered during bootstrap
RunnerInterface::class => function () {
$runner = new WhoopsRunner(new Run());
$runner->pushHandler(new LogHandler(new NullLogger()));

return $runner;
},
]
],
];

$bootstrap = new Bootstrap(
new StaticConfigLoader($config),
new ZendServiceManagerFactory()
);
/* @var $diContainer ContainerInterface */
$diContainer = $bootstrap();

assert($diContainer->has(RunnerInterface::class));

0 comments on commit 8b8b995

Please sign in to comment.