This commit is contained in:
2024-08-22 19:49:44 -04:00
parent a617bcf040
commit d251d8bd7d
14 changed files with 2971 additions and 0 deletions

50
app/bootstrap/app.php Normal file
View File

@ -0,0 +1,50 @@
<?php
use DI\ContainerBuilder;
use ProVM\ComposeManager\Wrapper\Application;
require_once 'composer.php';
function buildApp(): Application
{
$containerBuilder = new ContainerBuilder();
$folders = [
'configs',
'setups'
];
foreach ($folders as $folderName) {
$folder = implode(DIRECTORY_SEPARATOR, [
__DIR__,
$folderName
]);
if (!file_exists($folder)) {
continue;
}
$files = new FilesystemIterator($folder);
foreach ($files as $file) {
if ($file->isDir()) {
continue;
}
$containerBuilder->addDefinitions($file->getPathname());
}
}
$app = (new Application)->setContainer($containerBuilder->build());
$folder = implode(DIRECTORY_SEPARATOR, [
__DIR__,
'commands'
]);
if (file_exists($folder)) {
$files = new FilesystemIterator($folder);
foreach ($files as $file) {
if ($file->isDir()) {
continue;
}
require_once $file->getPathname();
}
}
return $app;
}
return buildApp();

View File

@ -0,0 +1,2 @@
<?php
$app->setCommandLoader($app->getContainer()->get(Symfony\Component\Console\CommandLoader\CommandLoaderInterface::class));

View File

@ -0,0 +1,6 @@
<?php
require_once implode(DIRECTORY_SEPARATOR, [
dirname(__DIR__),
'vendor',
'autoload.php'
]);

View File

@ -0,0 +1,9 @@
<?php
return [
'commands' => function() {
return [
'create' => ProVM\ComposeManager\Command\Create::class
];
}
];

View File

@ -0,0 +1,2 @@
<?php
return $_ENV;

View File

@ -0,0 +1,14 @@
<?php
use Psr\Container\ContainerInterface;
return [
ProVM\ComposeManager\Command\Create::class => function(ContainerInterface $container) {
return new ProVM\ComposeManager\Command\Create($container->get('ROOT'), $container->get('OUTPUT'));
},
Symfony\Component\Console\CommandLoader\CommandLoaderInterface::class => function(ContainerInterface $container) {
return new Symfony\Component\Console\CommandLoader\ContainerCommandLoader(
$container,
$container->get('commands')
);
}
];

View File

@ -0,0 +1,18 @@
<?php
use Psr\Container\ContainerInterface;
return [
Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
return new Monolog\Logger('app', [
(new Monolog\Handler\RotatingFileHandler('/logs/error.log'))
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, true, true)),
], [
new Monolog\Processor\UidProcessor(),
new Monolog\Processor\MemoryUsageProcessor(),
new Monolog\Processor\MemoryPeakUsageProcessor(),
new Monolog\Processor\PsrLogMessageProcessor(),
new Monolog\Processor\IntrospectionProcessor(),
]);
}
];