Seteo inicial
This commit is contained in:
60
setup/app.php
Normal file
60
setup/app.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
use DI\ContainerBuilder as Builder;
|
||||
use DI\Bridge\Slim\Bridge;
|
||||
|
||||
if (!isset($__environment)) {
|
||||
throw new Exception('Missing __environment variable');
|
||||
}
|
||||
|
||||
include_once 'composer.php';
|
||||
|
||||
$builder = new Builder();
|
||||
|
||||
$files = [
|
||||
'config',
|
||||
'setup'
|
||||
];
|
||||
$folders = [
|
||||
'common',
|
||||
$__environment
|
||||
];
|
||||
|
||||
foreach ($files as $file) {
|
||||
foreach ($folders as $folder) {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
__DIR__,
|
||||
$folder,
|
||||
$file . '.php'
|
||||
]);
|
||||
if (file_exists($filename)) {
|
||||
$builder->addDefinitions($filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$container = $builder->build();
|
||||
$app = Bridge::create($container);
|
||||
try {
|
||||
$app->setBasePath($container->get('base_url'));
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
__DIR__,
|
||||
$folder,
|
||||
'middleware.php'
|
||||
]);
|
||||
if (file_exists($filename)) {
|
||||
include_once $filename;
|
||||
}
|
||||
}
|
||||
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders')->routes,
|
||||
'router.php'
|
||||
]);
|
||||
if (!file_exists($filename)) {
|
||||
throw new Exception('Missing router file.');
|
||||
}
|
||||
include_once $filename;
|
22
setup/common/config.php
Normal file
22
setup/common/config.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
return [
|
||||
'base_url' => dirname(__DIR__),
|
||||
'urls' => function() {
|
||||
$arr = [];
|
||||
$arr['base'] = '/provm/demos/provm';
|
||||
return (object) $arr;
|
||||
},
|
||||
'folders' => function() {
|
||||
$arr = [];
|
||||
$arr['base'] = dirname(__DIR__, 2);
|
||||
$arr['resources'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$arr['base'],
|
||||
'resources'
|
||||
]);
|
||||
$arr['routes'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$arr['resources'],
|
||||
'routes'
|
||||
]);
|
||||
return (object) $arr;
|
||||
}
|
||||
];
|
10
setup/composer.php
Normal file
10
setup/composer.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
dirname(__DIR__)
|
||||
'vendor'
|
||||
'autoload.php'
|
||||
])
|
||||
if (!file_exists($filename)) {
|
||||
throw new Exception('Missing composer install.');
|
||||
}
|
||||
include_once $filename;
|
34
setup/web/config.app
Normal file
34
setup/web/config.app
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
use Psr\Container\ContainerInterface as Container;
|
||||
|
||||
return [
|
||||
'folders' => DI\decorate(function($prev, Container $c) {
|
||||
$arr = (array) $prev;
|
||||
$arr['templates'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$prev->resources,
|
||||
'views'
|
||||
]);
|
||||
$arr['cache'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$prev->base,
|
||||
'cache'
|
||||
]);
|
||||
return (object) $arr;
|
||||
}),
|
||||
'assets' => (object) [
|
||||
'styles' => [
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/semantic.min.css'
|
||||
],
|
||||
'scripts' => [
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/semantic.min.js'
|
||||
],
|
||||
'fonts' => [
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/brand-icons.woff',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/brand-icons.woff2',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/icons.woff',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/icons.woff2',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/outline-icons.woff',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/outline-icons.woff2'
|
||||
]
|
||||
]
|
||||
];
|
16
setup/web/setup.php
Normal file
16
setup/web/setup.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
use Psr\Container\ContainerInterface as Container;
|
||||
|
||||
return [
|
||||
ProVM\Common\Alias\View::class => function(Container $c) {
|
||||
return new ProVM\Common\Define\View(
|
||||
$c->get('folders')->templates,
|
||||
$c->get('folders')->cache,
|
||||
null,
|
||||
[
|
||||
'urls' => $c->get('urls'),
|
||||
'assets' => $c->get('assets')
|
||||
]
|
||||
);
|
||||
}
|
||||
];
|
Reference in New Issue
Block a user