Version nueva

This commit is contained in:
2020-11-20 16:21:42 -03:00
parent 09f04263fe
commit aae35fc4d1
67 changed files with 8586 additions and 0 deletions

52
setup/app.php Normal file
View File

@ -0,0 +1,52 @@
<?php
use DI\ContainerBuilder;
use DI\Bridge\Slim\Bridge;
include_once 'composer.php';
$builder = new ContainerBuilder();
if (!isset($__environment)) {
throw new InvalidArgumentException('Missing __environment setting.');
}
$folders = [
'env',
'common',
$__environment
];
$files = [
'config',
'setup'
];
foreach ($files as $file) {
foreach ($folders as $folder) {
$filename = implode(DIRECTORY_SEPARATOR, [
__DIR__,
$folder,
$file . '.php'
]);
if (!file_exists($filename)) {
continue;
}
$builder->addDefinitions($filename);
}
}
$container = $builder->build();
$app = Bridge::create($container);
$app->setBasePath($container->get('base_url'));
foreach ($folders as $folder) {
$filename = implode(DIRECTORY_SEPARATOR, [
__DIR__,
$folder,
'middleware.php'
]);
if (!file_exists($filename)) {
continue;
}
include_once $filename;
}
include_once 'router.php';

15
setup/common/config.php Normal file
View File

@ -0,0 +1,15 @@
<?php
return [
'folders' => function() {
$arr = ['base' => dirname(__DIR__, 2)];
$arr['resources'] = implode(DIRECTORY_SEPARATOR, [
$arr['base'],
'resources'
]);
$arr['routes'] = implode(DIRECTORY_SEPARATOR, [
$arr['resources'],
'routes'
]);
return (object) $arr;
}
];

6
setup/composer.php Normal file
View File

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

8
setup/env/config.php vendored Normal file
View File

@ -0,0 +1,8 @@
<?php
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__, 2));
$dotenv->load();
return [
'base_url' => $_ENV['BASE_URL'],
'debug' => $_ENV['DEBUG']
];

8
setup/router.php Normal file
View File

@ -0,0 +1,8 @@
<?php
$filename = implode(DIRECTORY_SEPARATOR, [
$app->getContainer()->get('folders')->routes,
$__environment . '.php'
]);
if (file_exists($filename)) {
include_once $filename;
}

42
setup/web/config.php Normal file
View File

@ -0,0 +1,42 @@
<?php
use Psr\Container\ContainerInterface as Container;
return [
'folders' => DI\decorate(function($prev, Container $container) {
$arr = (array) $prev;
$arr['templates'] = implode(DIRECTORY_SEPARATOR, [
$arr['resources'],
'views'
]);
$arr['cache'] = implode(DIRECTORY_SEPARATOR, [
$arr['base'],
'cache'
]);
$arr['assets'] = implode(DIRECTORY_SEPARATOR, [
$arr['resources'],
'assets'
]);
return (object) $arr;
}),
'urls' => function(Container $container) {
$arr = ['base' => $container->get('base_url')];
$arr['assets'] = implode('/', [
$arr['base'],
'assets'
]);
$arr['styles'] = implode('/', [
$arr['assets'],
'styles'
]);
$arr['images'] = implode('/', [
$arr['assets'],
'images'
]);
$arr['scripts'] = implode('/', [
$arr['assets'],
'scripts'
]);
return (object) $arr;
},
'language' => 'en'
];

4
setup/web/middleware.php Normal file
View File

@ -0,0 +1,4 @@
<?php
$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware([
'enable' => $app->getContainer()->get('debug')
]));

16
setup/web/setup.php Normal file
View File

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