Files
oficial/setup/cli.app.php
Juan Pablo Vial b212381bb7 Cli
2023-06-22 23:15:17 -04:00

49 lines
985 B
PHP

<?php
use Psr\Container\ContainerInterface;
use DI\ContainerBuilder;
use Symfony\Component\Console\Application;
require_once 'composer.php';
$builder = new ContainerBuilder();
$files = [
'config',
'setups'
];
foreach ($files as $f) {
$filename = implode(DIRECTORY_SEPARATOR, [
__DIR__,
'cli',
"{$f}.php"
]);
if (!file_exists($filename)) {
continue;
}
$builder->addDefinitions($filename);
}
$app = new class() extends Application
{
protected ContainerInterface $container;
public function getContainer(): ContainerInterface
{
return $this->container;
}
public function setContainer(ContainerInterface $container)
{
$this->container = $container;
return $this;
}
};
$app->setContainer($builder->build());
$filename = implode(DIRECTORY_SEPARATOR, [
__DIR__,
'cli',
'middlewares.php'
]);
if (file_exists($filename)) {
include_once $filename;
}
return $app;