20240708#1

This commit is contained in:
User
2024-07-08 13:57:42 +03:00
parent 3ebbe07db6
commit c3e7bc6fc7
15 changed files with 22 additions and 18 deletions

View File

@@ -9,5 +9,5 @@ composer create-project rmphp/skeleton project-name
``` ```
```bash ```bash
composer create-project rmphp/skeleton:"^4.2" project-name composer create-project rmphp/skeleton:"^4.3" project-name
``` ```

View File

@@ -1,4 +1,4 @@
<?php <?php
return (new \Rmphp\Content\Content('/application/src/Presentation/templates/base.tpl'))->setSubtemplatePath('/application/src/Presentation/templates/')->setSubtemplatePathAlias([ return (new \Rmphp\Content\Content('/application/src/Infrastructure/templates/base.tpl'))->setSubtemplatePath('/application/src/Infrastructure/templates/')->setSubtemplatePathAlias([
"main" => "/src/Main/Presentation/templates", "main" => "/src/Main/Infrastructure/templates",
]); ]);

View File

@@ -1,13 +1,13 @@
# Index # Index
- key: "/" - key: "/"
routes: routes:
- action: "App\\Main\\Presentation\\Controllers\\IndexController" - action: "App\\Main\\Infrastructure\\Controllers\\IndexController"
method: "index" method: "index"
params: "" params: ""
# Empty # Empty
- key: "<@any>" - key: "<@any>"
routes: routes:
- action: "App\\Main\\Presentation\\Controllers\\IndexController" - action: "App\\Main\\Infrastructure\\Controllers\\IndexController"
method: "emptyAction" method: "emptyAction"
params: "" params: ""

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace Base\Presentation\Controllers; namespace Base\Infrastructure\Controllers;
use Laminas\Diactoros\Response\HtmlResponse; use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\JsonResponse; use Laminas\Diactoros\Response\JsonResponse;
@@ -146,4 +146,4 @@ abstract class AbstractController extends Main {
public function getTemplatePath(string $path) : string { public function getTemplatePath(string $path) : string {
return $path; return $path;
} }
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace Base\Presentation\Controllers; namespace Base\Infrastructure\Controllers;
use Base\Application\ApplicationException; use Base\Application\ApplicationException;
use Base\Application\DTOException; use Base\Application\DTOException;
@@ -32,4 +32,4 @@ abstract class AbstractPageController extends AbstractController {
if($e instanceof DTOException || $e instanceof DomainException || $e instanceof ApplicationException) return $e->getMessage(); if($e instanceof DTOException || $e instanceof DomainException || $e instanceof ApplicationException) return $e->getMessage();
return "Ошибка. Дата и время: ".date("d-m-Y H:i:s"); return "Ошибка. Дата и время: ".date("d-m-Y H:i:s");
} }
} }

View File

@@ -1,7 +1,7 @@
<?php <?php
namespace Base\Presentation\Controllers; namespace Base\Infrastructure\Controllers;
class NotFoundException extends \Exception { class NotFoundException extends \Exception {
} }

View File

@@ -11,15 +11,19 @@ require_once dirname(__DIR__).'/vendor/autoload.php';
(new Symfony\Component\Dotenv\Dotenv())->usePutenv()->loadEnv(dirname(__DIR__).'/.env'); (new Symfony\Component\Dotenv\Dotenv())->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(); $request = ServerRequestFactory::fromGlobals();
$app = new App(); $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); (new ResponseEmitter())->emit($response);
if(($response->getStatusCode() !== 200 && getenv("APP_MODE") == 'DEV') || in_array("Dev", $response->getHeader("App-Mode"))){ if(($response->getStatusCode() !== 200 && getenv("APP_MODE") == 'DEV') || in_array("Dev", $response->getHeader("App-Mode"))){
$app->syslogger()->dump("Response", $response); $app->syslogger()->dump("Response", $response);
addShutdownInfo($app->syslogger()->getLogs()); addShutdownInfo($app->syslogger()->getLogs());
} }

View File

@@ -1,7 +1,7 @@
<?php <?php
namespace App\Main\Presentation\Controllers; namespace App\Main\Infrastructure\Controllers;
use Base\Presentation\Controllers\AbstractPageController; use Base\Infrastructure\Controllers\AbstractPageController;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
class IndexController extends AbstractPageController { class IndexController extends AbstractPageController {