From c3e7bc6fc76e93cbdb12adb364e49af21898bfe9 Mon Sep 17 00:00:00 2001 From: User Date: Mon, 8 Jul 2024 13:57:42 +0300 Subject: [PATCH] 20240708#1 --- README.md | 4 ++-- application/config/factories/templateFactory.php | 6 +++--- application/config/routes/main/90-main.yaml | 4 ++-- .../Controllers/AbstractController.php | 4 ++-- .../Controllers/AbstractPageController.php | 4 ++-- .../Controllers/NotFoundException.php | 4 ++-- .../templates/base.tpl | 0 .../templates/error/404.tpl | 0 .../templates/error/501.tpl | 0 .../templates/error/errpage.tpl | 0 .../templates/inc/footer.tpl | 0 .../templates/inc/header.tpl | 0 public/index.php | 10 +++++++--- .../Controllers/IndexController.php | 4 ++-- .../templates/index.tpl | 0 15 files changed, 22 insertions(+), 18 deletions(-) rename application/src/{Presentation => Infrastructure}/Controllers/AbstractController.php (98%) rename application/src/{Presentation => Infrastructure}/Controllers/AbstractPageController.php (96%) rename application/src/{Presentation => Infrastructure}/Controllers/NotFoundException.php (54%) rename application/src/{Presentation => Infrastructure}/templates/base.tpl (100%) rename application/src/{Presentation => Infrastructure}/templates/error/404.tpl (100%) rename application/src/{Presentation => Infrastructure}/templates/error/501.tpl (100%) rename application/src/{Presentation => Infrastructure}/templates/error/errpage.tpl (100%) rename application/src/{Presentation => Infrastructure}/templates/inc/footer.tpl (100%) rename application/src/{Presentation => Infrastructure}/templates/inc/header.tpl (100%) rename src/Main/{Presentation => Infrastructure}/Controllers/IndexController.php (83%) rename src/Main/{Presentation => Infrastructure}/templates/index.tpl (100%) diff --git a/README.md b/README.md index d2b9eeb..d14b882 100644 --- a/README.md +++ b/README.md @@ -9,5 +9,5 @@ composer create-project rmphp/skeleton project-name ``` ```bash -composer create-project rmphp/skeleton:"^4.2" project-name -``` \ No newline at end of file +composer create-project rmphp/skeleton:"^4.3" project-name +``` diff --git a/application/config/factories/templateFactory.php b/application/config/factories/templateFactory.php index 4d076c7..9e0c67a 100644 --- a/application/config/factories/templateFactory.php +++ b/application/config/factories/templateFactory.php @@ -1,4 +1,4 @@ setSubtemplatePath('/application/src/Presentation/templates/')->setSubtemplatePathAlias([ - "main" => "/src/Main/Presentation/templates", -]); \ No newline at end of file +return (new \Rmphp\Content\Content('/application/src/Infrastructure/templates/base.tpl'))->setSubtemplatePath('/application/src/Infrastructure/templates/')->setSubtemplatePathAlias([ + "main" => "/src/Main/Infrastructure/templates", +]); diff --git a/application/config/routes/main/90-main.yaml b/application/config/routes/main/90-main.yaml index 5c6c9e8..5ed7763 100644 --- a/application/config/routes/main/90-main.yaml +++ b/application/config/routes/main/90-main.yaml @@ -1,13 +1,13 @@ # Index - key: "/" routes: - - action: "App\\Main\\Presentation\\Controllers\\IndexController" + - action: "App\\Main\\Infrastructure\\Controllers\\IndexController" method: "index" params: "" # Empty - key: "<@any>" routes: - - action: "App\\Main\\Presentation\\Controllers\\IndexController" + - action: "App\\Main\\Infrastructure\\Controllers\\IndexController" method: "emptyAction" params: "" diff --git a/application/src/Presentation/Controllers/AbstractController.php b/application/src/Infrastructure/Controllers/AbstractController.php similarity index 98% rename from application/src/Presentation/Controllers/AbstractController.php rename to application/src/Infrastructure/Controllers/AbstractController.php index f9c54ff..a862689 100644 --- a/application/src/Presentation/Controllers/AbstractController.php +++ b/application/src/Infrastructure/Controllers/AbstractController.php @@ -1,6 +1,6 @@ getMessage(); return "Ошибка. Дата и время: ".date("d-m-Y H:i:s"); } -} \ No newline at end of file +} diff --git a/application/src/Presentation/Controllers/NotFoundException.php b/application/src/Infrastructure/Controllers/NotFoundException.php similarity index 54% rename from application/src/Presentation/Controllers/NotFoundException.php rename to application/src/Infrastructure/Controllers/NotFoundException.php index 42b657e..2e49ea0 100644 --- a/application/src/Presentation/Controllers/NotFoundException.php +++ b/application/src/Infrastructure/Controllers/NotFoundException.php @@ -1,7 +1,7 @@ usePutenv()->loadEnv(dirname(__DIR__).'/.env'); -error_reporting(0); ini_set('display_errors','Off'); +if(getenv("APP_MODE") == 'DEBUG'){ + error_reporting(E_ALL); ini_set('display_errors','On'); +} else { + error_reporting(0); ini_set('display_errors','Off'); +} $request = ServerRequestFactory::fromGlobals(); $app = new App(); -$response = $app->handler($request, (new Response())->withHeader("Content-Type", "text/html; charset=utf-8")); +$response = $app->handler($request, new Response()); (new ResponseEmitter())->emit($response); if(($response->getStatusCode() !== 200 && getenv("APP_MODE") == 'DEV') || in_array("Dev", $response->getHeader("App-Mode"))){ $app->syslogger()->dump("Response", $response); addShutdownInfo($app->syslogger()->getLogs()); -} \ No newline at end of file +} diff --git a/src/Main/Presentation/Controllers/IndexController.php b/src/Main/Infrastructure/Controllers/IndexController.php similarity index 83% rename from src/Main/Presentation/Controllers/IndexController.php rename to src/Main/Infrastructure/Controllers/IndexController.php index fa06461..b8d609c 100644 --- a/src/Main/Presentation/Controllers/IndexController.php +++ b/src/Main/Infrastructure/Controllers/IndexController.php @@ -1,7 +1,7 @@