v0.1.0
This commit is contained in:
52
frontend/setup/app.php
Normal file
52
frontend/setup/app.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
use DI\ContainerBuilder as Builder;
|
||||
use DI\Bridge\Slim\Bridge;
|
||||
|
||||
include_once 'composer.php';
|
||||
|
||||
$builder = new Builder();
|
||||
|
||||
$folders = [
|
||||
'env',
|
||||
'common',
|
||||
'web'
|
||||
];
|
||||
$files = [
|
||||
'settings',
|
||||
'setups'
|
||||
];
|
||||
|
||||
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'));
|
||||
$app->addRoutingMiddleware();
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
__DIR__,
|
||||
$folder,
|
||||
'middlewares.php'
|
||||
]);
|
||||
if (!file_exists($filename)) {
|
||||
continue;
|
||||
}
|
||||
include_once $filename;
|
||||
}
|
||||
|
||||
include_once 'router.php';
|
||||
|
||||
$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware(['enable' => $container->get('debug') ?: true]));
|
9
frontend/setup/common/settings.php
Normal file
9
frontend/setup/common/settings.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'base_url' => function() {
|
||||
if (isset($_ENV['BASE_URL'])) {
|
||||
return $_ENV['BASE_URL'];
|
||||
}
|
||||
return $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
];
|
6
frontend/setup/composer.php
Normal file
6
frontend/setup/composer.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
include_once implode(DIRECTORY_SEPARATOR, [
|
||||
dirname(__DIR__),
|
||||
'vendor',
|
||||
'autoload.php'
|
||||
]);
|
4
frontend/setup/env/settings.php
vendored
Normal file
4
frontend/setup/env/settings.php
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'debug' => $_ENV['DEBUG'] ?? false
|
||||
];
|
5
frontend/setup/router.php
Normal file
5
frontend/setup/router.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
include_once implode(DIRECTORY_SEPARATOR, [
|
||||
$app->getContainer()->get('locations')->routes,
|
||||
'web.php'
|
||||
]);
|
68
frontend/setup/web/settings.php
Normal file
68
frontend/setup/web/settings.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
use Psr\Container\ContainerInterface as Container;
|
||||
|
||||
return [
|
||||
'login_time' => 5*60*60,
|
||||
'locations' => function() {
|
||||
$arr = ['base' => dirname(__DIR__, 2)];
|
||||
$arr['resources'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$arr['base'],
|
||||
'resources'
|
||||
]);
|
||||
$arr['data'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$arr['resources'],
|
||||
'data'
|
||||
]);
|
||||
$arr['routes'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$arr['resources'],
|
||||
'routes'
|
||||
]);
|
||||
$arr['templates'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$arr['resources'],
|
||||
'views'
|
||||
]);
|
||||
$arr['cache'] = implode(DIRECTORY_SEPARATOR, [
|
||||
$arr['base'],
|
||||
'cache'
|
||||
]);
|
||||
return (object) $arr;
|
||||
},
|
||||
'urls' => function(Container $c) {
|
||||
$arr = ['base' => $c->get('base_url'), 'api' => $_ENV['API_URL']];
|
||||
return (object) $arr;
|
||||
},
|
||||
'scripts' => function() {
|
||||
$arr = [
|
||||
[
|
||||
'full' => '<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>'
|
||||
],
|
||||
[
|
||||
'full' => '<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.7/semantic.min.js" integrity="sha512-1Nyd5H4Aad+OyvVfUOkO/jWPCrEvYIsQENdnVXt1+Jjc4NoJw28nyRdrpOCyFH4uvR3JmH/5WmfX1MJk2ZlhgQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>'
|
||||
]
|
||||
];
|
||||
foreach ($arr as $i => $a) {
|
||||
$arr[$i] = (object) $a;
|
||||
}
|
||||
return $arr;
|
||||
},
|
||||
'styles' => function() {
|
||||
$arr = [
|
||||
[
|
||||
'link' => '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.7/semantic.min.css" integrity="sha512-g/MzOGVPy3OQ4ej1U+qe4D/xhLwUn5l5xL0Fa7gdC258ZWVJQGwsbIR47SWMpRxSPjD0tfu/xkilTy+Lhrl3xg==" crossorigin="anonymous" referrerpolicy="no-referrer" />'
|
||||
],
|
||||
[
|
||||
'url' => 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.7/themes/default/assets/fonts/brand-icons.woff2'
|
||||
],
|
||||
[
|
||||
'url' => 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.7/themes/default/assets/fonts/icons.woff2'
|
||||
],
|
||||
[
|
||||
'url' => 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.7/themes/default/assets/fonts/outline-icons.woff2'
|
||||
]
|
||||
];
|
||||
foreach ($arr as $i => $a) {
|
||||
$arr[$i] = (object) $a;
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
];
|
17
frontend/setup/web/setups.php
Normal file
17
frontend/setup/web/setups.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
use Psr\Container\ContainerInterface as Container;
|
||||
|
||||
return [
|
||||
Slim\Views\Blade::class => function(Container $container) {
|
||||
return new Slim\Views\Blade(
|
||||
$container->get('locations')->templates,
|
||||
$container->get('locations')->cache,
|
||||
null,
|
||||
[
|
||||
'urls' => $container->get('urls'),
|
||||
'page_styles' => $container->get('styles'),
|
||||
'page_scripts' => $container->get('scripts')
|
||||
]
|
||||
);
|
||||
}
|
||||
];
|
Reference in New Issue
Block a user