Compare commits

...

2 Commits

Author SHA1 Message Date
jay 3872996fa7 use APPLICATION_NAME 2026-08-12 15:49:35 -04:00
jay fecc73408a require vlucas/phpdotenv 2026-08-12 15:49:25 -04:00
2 changed files with 15 additions and 3 deletions
+7 -1
View File
@@ -15,10 +15,16 @@
],
"minimum-stability": "stable",
"require": {
"graham-campbell/result-type": ">=1.1.4",
"monolog/monolog": ">=3.10.0",
"phpoption/phpoption": ">=1.9.5",
"potter/console": ">=0.0.1",
"potter/container": ">=0.0.1",
"potter/event": ">=0.0.3",
"psr/log": ">=3.0.2"
"psr/log": ">=3.0.2",
"symfony/polyfill-ctype": ">=1.37.0",
"symfony/polyfill-mbstring": ">=1.38.2",
"symfony/polyfill-php80": ">=1.37.0",
"vlucas/phpdotenv": ">=5.6.4"
}
}
+8 -2
View File
@@ -38,21 +38,25 @@ trait Behaviour
return; }
$dispatcher = static::getDispatcher($container);
static::getEnvironment($container)->required('APPLICATION_NAME');
$dispatcher->subscribeTo('applicationStart', function (Event $event) {
$container = $event->getArgument('container');
if (!self::hasLogger($container)) {
return; }
self::getLogger($container)->notice('Application start.'); });
self::getLogger($container)->notice('Application start: ' . $_ENV['APPLICATION_NAME']); });
$dispatcher->subscribeTo('applicationStop', function (Event $event) {
$container = $event->getArgument('container');
if (!self::hasLogger($container)) {
return; }
self::getLogger($container)->notice('Application stop.'); });
self::getLogger($container)->notice('Application stop: ' . $_ENV['APPLICATION_NAME']); });
}
abstract private static function getDispatcher(Container $container): \Potter\Event\Dispatcher;
abstract private static function getEnvironment(Container $container): \Dotenv\Dotenv;
private static function getLogger(Container $container): Logger
{
return $container->get(Logger::class);
@@ -65,6 +69,8 @@ trait Behaviour
abstract private static function hasDispatcher(Container $container): bool;
abstract private static function hasEnvironment(Container $container): bool;
private static function hasLogger(Container $container): bool
{
return $container->has(Logger::class);