-
Notifications
You must be signed in to change notification settings - Fork 0
/mail
50 lines (40 loc) · 1.67 KB
/mail
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env php
<?php declare(strict_types=1);
use Dangle\Mailer\App;
use Dangle\Mailer\Events\ConsoleNotificationEvent;
use Dangle\Mailer\Events\ConsoleNotificationEventListener;
use Dangle\Mailer\Events\FilesystemChangedEvent;
use Dangle\Mailer\Events\FilesystemChangedEventListener;
use Symfony\Component;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
require __DIR__ . '/vendor/autoload.php';
// convert warnings to errors https://www.php.net/manual/en/class.errorexception.php
function exception_error_handler($severity, $message, $file, $line)
{
if (!(error_reporting() & $severity)) {
// This error code is not included in error_reporting
return;
}
throw new ErrorException($message, 0, $severity, $file, $line);
}
set_error_handler("exception_error_handler");
// load env variables
$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env');
// set up container
$container = new Component\DependencyInjection\ContainerBuilder();
$phpFileLoader = new Component\DependencyInjection\Loader\PhpFileLoader(
$container,
new Component\Config\FileLocator(__DIR__ . '/config')
);
$phpFileLoader->load('services.php');
$container->compile();
// configure event listeners
/** @var EventDispatcherInterface $dispatcher */
$dispatcher = $container->get(EventDispatcherInterface::class);
$dispatcher->addListener(FilesystemChangedEvent::NAME, $container->get(FilesystemChangedEventListener::class));
$dispatcher->addListener(ConsoleNotificationEvent::NAME, $container->get(ConsoleNotificationEventListener::class));
/** @var Component\Console\Application $app */
$app = $container->get(App::class);
$app->run();