diff --git a/ui/public/index.php b/ui/public/index.php new file mode 100644 index 0000000..0606ece --- /dev/null +++ b/ui/public/index.php @@ -0,0 +1,7 @@ +run(); diff --git a/ui/setup/app.php b/ui/setup/app.php new file mode 100644 index 0000000..7367296 --- /dev/null +++ b/ui/setup/app.php @@ -0,0 +1,43 @@ +isDir()) { + continue; + } + $builder->addDefinitions($file->getRealPath()); + } +} +$app = \DI\Bridge\Slim\Bridge::create($builder->build()); + +$folder = implode(DIRECTORY_SEPARATOR, [ + __DIR__, + 'middleware' +]); +if (file_exists($folder)) { + $files = new FilesystemIterator($folder); + foreach ($files as $file) { + if ($file->isDir()) { + continue; + } + require_once $file->getRealPath(); + } +} + +return $app; diff --git a/ui/setup/composer.php b/ui/setup/composer.php new file mode 100644 index 0000000..b451f96 --- /dev/null +++ b/ui/setup/composer.php @@ -0,0 +1,6 @@ +addRoutingMiddleware(); + +$folder = $app->getContainer()->get('folders')->routes; +$files = new FilesystemIterator($folder); +foreach ($files as $file) { + if ($file->isDir()) { + continue; + } + include_once $file->getRealPath(); +} diff --git a/ui/setup/middleware/99_errors.php b/ui/setup/middleware/99_errors.php new file mode 100644 index 0000000..c168fe5 --- /dev/null +++ b/ui/setup/middleware/99_errors.php @@ -0,0 +1,2 @@ +add($app->getContainer()->get(\Zeuxisoo\Whoops\Slim\WhoopsMiddleware::class)); diff --git a/ui/setup/settings/01_env.php b/ui/setup/settings/01_env.php new file mode 100644 index 0000000..f138041 --- /dev/null +++ b/ui/setup/settings/01_env.php @@ -0,0 +1,4 @@ + $_ENV['API_KEY'] +]; diff --git a/ui/setup/settings/02_folders.php b/ui/setup/settings/02_folders.php new file mode 100644 index 0000000..f3a4efd --- /dev/null +++ b/ui/setup/settings/02_folders.php @@ -0,0 +1,25 @@ + function() { + $arr = ['base' => dirname(__FILE__, 3)]; + $arr['resources'] = implode(DIRECTORY_SEPARATOR, [ + $arr['base'], + 'resources' + ]); + $arr['routes'] = implode(DIRECTORY_SEPARATOR, [ + $arr['resources'], + 'routes' + ]); + $arr['views'] = implode(DIRECTORY_SEPARATOR, [ + $arr['resources'], + 'views' + ]); + $arr['cache'] = implode(DIRECTORY_SEPARATOR, [ + $arr['base'], + 'cache' + ]); + return (object) $arr; + } +]; \ No newline at end of file diff --git a/ui/setup/settings/03_urls.php b/ui/setup/settings/03_urls.php new file mode 100644 index 0000000..b0ca32d --- /dev/null +++ b/ui/setup/settings/03_urls.php @@ -0,0 +1,8 @@ + function() { + $arr = ['base' => '/']; + $arr['api'] = 'http://localhost:8080'; + return (object) $arr; + } +]; diff --git a/ui/setup/settings/98_log.php b/ui/setup/settings/98_log.php new file mode 100644 index 0000000..55328ea --- /dev/null +++ b/ui/setup/settings/98_log.php @@ -0,0 +1,4 @@ + '/logs/php.log' +]; \ No newline at end of file diff --git a/ui/setup/setups/03_views.php b/ui/setup/setups/03_views.php new file mode 100644 index 0000000..c8c7a06 --- /dev/null +++ b/ui/setup/setups/03_views.php @@ -0,0 +1,16 @@ + function(ContainerInterface $container) { + return new \Slim\Views\Blade( + $container->get('folders')->views, + $container->get('folders')->cache, + null, + [ + 'urls' => $container->get('urls'), + 'api_key' => sha1($container->get('api_key')) + ] + ); + } +]; diff --git a/ui/setup/setups/98_log.php b/ui/setup/setups/98_log.php new file mode 100644 index 0000000..eaef107 --- /dev/null +++ b/ui/setup/setups/98_log.php @@ -0,0 +1,15 @@ + function(ContainerInterface $container) { + $handler = new \Monolog\Handler\RotatingFileHandler($container->get('log_file')); + $handler->setFormatter($container->get(\Monolog\Formatter\LineFormatter::class)); + return $handler; + }, + \Psr\Log\LoggerInterface::class => function(ContainerInterface $container) { + $logger = new \Monolog\Logger('file_logger'); + $logger->pushHandler($container->get(\Monolog\Handler\RotatingFileHandler::class)); + return $logger; + } +]; \ No newline at end of file diff --git a/ui/setup/setups/99_errors.php b/ui/setup/setups/99_errors.php new file mode 100644 index 0000000..d79d93d --- /dev/null +++ b/ui/setup/setups/99_errors.php @@ -0,0 +1,8 @@ + function(ContainerInterface $container) { + return new \Zeuxisoo\Whoops\Slim\WhoopsMiddleware(); + } +]; \ No newline at end of file