49 lines
985 B
PHP
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;
|