41 lines
860 B
PHP
41 lines
860 B
PHP
|
<?php
|
||
|
use DI\ContainerBuilder;
|
||
|
use DI\Bridge\Slim\Bridge;
|
||
|
|
||
|
require_once 'composer.php';
|
||
|
|
||
|
$builder = new ContainerBuilder();
|
||
|
|
||
|
$folders = [
|
||
|
'settings',
|
||
|
'setups'
|
||
|
];
|
||
|
foreach ($folders as $f) {
|
||
|
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, $f]);
|
||
|
if (!file_exists($folder)) {
|
||
|
continue;
|
||
|
}
|
||
|
$files = new FilesystemIterator($folder);
|
||
|
foreach ($files as $file) {
|
||
|
if ($file->isDir()) {
|
||
|
continue;
|
||
|
}
|
||
|
$builder->addDefinitions($file->getRealPath());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$app = Bridge::create($builder->build());
|
||
|
|
||
|
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'middlewares']);
|
||
|
if (file_exists($folder)) {
|
||
|
$files = new FilesystemIterator($folder);
|
||
|
foreach ($files as $file) {
|
||
|
if ($file->isDir()) {
|
||
|
continue;
|
||
|
}
|
||
|
include_once $file->getRealPath();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return $app;
|