UI incompleto

This commit is contained in:
2021-07-29 22:05:48 -04:00
parent 4374392af1
commit fb18129826
48 changed files with 1063 additions and 0 deletions

45
ui/setup/app.php Normal file
View File

@ -0,0 +1,45 @@
<?php
use DI\ContainerBuilder as Builder;
use DI\Bridge\Slim\Bridge as Bridge;
use Zeuxisoo\Whoops\Slim\WhoopsMiddleware;
include_once 'composer.php';
$builder = new Builder();
$folders = [
'settings',
'setups'
];
foreach ($folders as $f) {
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, $f]);
if (!file_exists($folder)) {
continue;
}
$files = new DirectoryIterator($folder);
foreach ($files as $file) {
if ($file->isDir()) {
continue;
}
$builder->addDefinitions($file->getRealPath());
}
}
$container = $builder->build();
$app = Bridge::create($container);
$app->addRoutingMiddleware();
$app->add(new WhoopsMiddleware());
$folder = 'middlewares';
if (file_exists($folder)) {
$files = new DirectoryIterator($folder);
foreach ($files as $file) {
if ($file->isDir() or $file->getExtension() != 'php') {
continue;
}
include_once $file->getRealPath();
}
}
include_once 'router.php';

6
ui/setup/composer.php Normal file
View File

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

9
ui/setup/router.php Normal file
View File

@ -0,0 +1,9 @@
<?php
$folder = $app->getContainer()->get('folders')->routes;
$files = new DirectoryIterator($folder);
foreach ($files as $file) {
if ($file->isDir() or $file->getExtension() != 'php') {
continue;
}
include_once $file->getRealPath();
}

View File

@ -0,0 +1,4 @@
<?php
return [
'debug' => $_ENV['DEBUG'] ?? false
];

View File

@ -0,0 +1,27 @@
<?php
use Psr\Container\ContainerInterface as Container;
return [
'folders' => function(Container $c) {
$arr = [
'base' => dirname(__DIR__, 2)
];
$arr['resources'] = implode(DIRECTORY_SEPARATOR, [
$arr['base'],
'resources'
]);
$arr['routes'] = implode(DIRECTORY_SEPARATOR, [
$arr['resources'],
'routes'
]);
$arr['cache'] = implode(DIRECTORY_SEPARATOR, [
$arr['base'],
'cache'
]);
$arr['templates'] = implode(DIRECTORY_SEPARATOR, [
$arr['resources'],
'views'
]);
return (object) $arr;
}
];

View File

@ -0,0 +1,22 @@
<?php
use Psr\Container\ContainerInterface as Container;
return [
'urls' => function(Container $c) {
$arr = ['base' => $_ENV['BASE_URL'] ?? '/'];
$arr['assets'] = str_replace('//', '/', implode('/', [
$arr['base'],
'assets'
]));
$arr['images'] = implode('/', [
$arr['assets'],
'images'
]);
$arr['scripts'] = implode('/', [
$arr['assets'],
'scripts'
]);
$arr['api'] = $_ENV['API_URL'] ?? 'http://localhost:9001';
return (object) $arr;
}
];

View File

@ -0,0 +1,15 @@
<?php
use Psr\Container\ContainerInterface as Container;
return [
Slim\Views\Blade::class => function(Container $c) {
return new Slim\Views\Blade(
$c->get('folders')->templates,
$c->get('folders')->cache,
null,
[
'urls' => $c->get('urls')
]
);
}
];