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
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
return (new \Rmphp\Content\Content('/application/src/Presentation/templates/base.tpl'))->setSubtemplatePath('/application/src/Presentation/templates/')->setSubtemplatePathAlias([
"main" => "/src/Main/Presentation/templates",
]);
return (new \Rmphp\Content\Content('/application/src/Infrastructure/templates/base.tpl'))->setSubtemplatePath('/application/src/Infrastructure/templates/')->setSubtemplatePathAlias([
"main" => "/src/Main/Infrastructure/templates",
]);

View File

@@ -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: ""

View File

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

View File

@@ -1,6 +1,6 @@
<?php
namespace Base\Presentation\Controllers;
namespace Base\Infrastructure\Controllers;
use Base\Application\ApplicationException;
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();
return "Ошибка. Дата и время: ".date("d-m-Y H:i:s");
}
}
}

View File

@@ -1,7 +1,7 @@
<?php
namespace Base\Presentation\Controllers;
namespace Base\Infrastructure\Controllers;
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');
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());
}
}

View File

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