Config, setup and bootstrap

This commit is contained in:
Juan Pablo Vial
2024-12-21 19:00:31 -03:00
parent 0fddc3a310
commit 211b6b0b94
10 changed files with 149 additions and 0 deletions

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

@ -0,0 +1,32 @@
<?php
function buildApp(): Symfony\Component\Console\Application
{
$builder = new DI\ContainerBuilder();
$baseFolder = dirname(__DIR__);
$folders = [
'configs',
'setups'
];
foreach ($folders as $folderName) {
$folder = implode(DIRECTORY_SEPARATOR, [$baseFolder, $folderName]);
if (!isset($folder)) {
continue;
}
$files = new FilesystemIterator($folder);
foreach ($files as $file) {
if ($file->isDir()) {
continue;
}
$builder->addDefinitions($file->getRealPath());
}
}
$app = (new ProVM\Extend\Application())
->setContainer($builder->build());
return require_once 'commands.php';
}
require_once 'composer.php';
return buildApp();

View File

@ -0,0 +1,9 @@
<?php
function buildCommands(\Symfony\Component\Console\Application &$app): \Symfony\Component\Console\Application {
$commands = $app->getContainer()->get('commands');
foreach ($commands as $commandClass) {
$app->add($app->getContainer()->get($commandClass));
}
return $app;
}
return buildCommands($app);

View File

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