20241004#1

This commit is contained in:
User
2024-10-04 03:00:11 +03:00
parent 99f78f7362
commit 1b0af12a46
37 changed files with 57 additions and 59 deletions

View File

@@ -10,14 +10,14 @@
# PROD / DEV # PROD / DEV
APP_MODE=DEV APP_MODE=DEV
APP_NODES_FILE=application/config/app.php APP_NODES_FILE=config/app.php
APP_COMPONENTS_FILE=application/config/components.php APP_COMPONENTS_FILE=config/components.php
CONTAINER_INI=application/config/container.php CONTAINER_INI=config/container.php
CONTAINER_CACHE=var/cache/container CONTAINER_CACHE=var/cache/container
# Default page # Default page
PAGE404="/application/src/Infrastructure/templates/error/404.tpl" PAGE404="/templates/error/404.tpl"
PAGE501="/application/src/Infrastructure/templates/error/501.tpl" PAGE501="/templates/error/501.tpl"
# Users environment # Users environment
MYSQL_PARAM='{"host":"host.docker.internal", "user":"***user***", "pass":"***password***","base":"***basename***", "logsEnable":true}' MYSQL_PARAM='{"host":"host.docker.internal", "user":"***user***", "pass":"***password***","base":"***basename***", "logsEnable":true}'

View File

@@ -1,5 +0,0 @@
<?php
return [
"application/config/container/services.php",
"application/config/container/settings.php",
];

View File

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

View File

@@ -22,8 +22,7 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "src", "App\\": "src"
"Base\\": "application/src"
} }
}, },
"scripts": { "scripts": {

View File

@@ -9,5 +9,5 @@
# ['key'=>'/', 'router'=>[]], # ['key'=>'/', 'router'=>[]],
return [ return [
['key'=>'/', 'router'=>'application/config/routes/routes.php'], ['key'=>'/', 'router'=>'config/routes/routes.php'],
]; ];

View File

@@ -4,18 +4,17 @@ return [
/** /**
* Путь к файлу фабрики возвращающий реализацию RouterInterface или сам экземпляр класса * Путь к файлу фабрики возвращающий реализацию RouterInterface или сам экземпляр класса
*/ */
\Rmphp\Foundation\RouterInterface::class => 'application/config/factories/routerFactory.php', \Rmphp\Foundation\RouterInterface::class => 'config/components/routerFactory.php',
/** /**
* Путь к файлу фабрики возвращающий реализацию TemplateInterface или сам экземпляр класса * Путь к файлу фабрики возвращающий реализацию TemplateInterface или сам экземпляр класса
*/ */
\Rmphp\Foundation\TemplateInterface::class => 'application/config/factories/templateFactory.php', \Rmphp\Foundation\TemplateInterface::class => 'config/components/templateFactory.php',
/** /**
* Путь к файлу фабрики возвращающий реализацию PSR-3 LoggerInterface или сам экземпляр класса * Путь к файлу фабрики возвращающий реализацию PSR-3 LoggerInterface или сам экземпляр класса
*/ */
\Psr\Log\LoggerInterface::class => 'application/config/factories/loggerFactory.php', \Psr\Log\LoggerInterface::class => 'config/components/loggerFactory.php',
/** /**
* Путь к файлу фабрики возвращающий реализацию PSR-11 ContainerInterface или сам экземпляр класса * Путь к файлу фабрики возвращающий реализацию PSR-11 ContainerInterface или сам экземпляр класса
*/ */
\Psr\Container\ContainerInterface::class => 'application/config/factories/containerFactory.php', \Psr\Container\ContainerInterface::class => 'config/components/containerFactory.php',
]; ];

View File

@@ -2,18 +2,18 @@
use DI\ContainerBuilder; use DI\ContainerBuilder;
$containerIni = (getenv("CONTAINER_INI")) ?: "application/config/container.php"; $containerIni = (getenv("CONTAINER_INI")) ?: "config/container.php";
$containerCache = (getenv("CONTAINER_CACHE")) ?: "var/cache/container"; $containerCache = (getenv("CONTAINER_CACHE")) ?: "var/cache/container";
$dependencies = require dirname(__DIR__,3).'/'.$containerIni; $dependencies = require dirname(__DIR__,2).'/'.$containerIni;
$dependenciesCollection = array_map(function ($dependenciesFile){ $dependenciesCollection = array_map(function ($dependenciesFile){
return require dirname(__DIR__,3)."/".$dependenciesFile; return require dirname(__DIR__,2)."/".$dependenciesFile;
}, $dependencies); }, $dependencies);
try { try {
$builder = new ContainerBuilder(); $builder = new ContainerBuilder();
if(getenv("APP_MODE") == "PROD") $builder->enableCompilation(dirname(__DIR__,3)."/".$containerCache); if(getenv("APP_MODE") == "PROD") $builder->enableCompilation(dirname(__DIR__,2)."/".$containerCache);
$builder->addDefinitions(array_replace_recursive(...$dependenciesCollection)); $builder->addDefinitions(array_replace_recursive(...$dependenciesCollection));
return $builder->build(); return $builder->build();
} catch (Exception $e) {echo $e->getMessage();} } catch (Exception $e) {echo $e->getMessage();}

View File

@@ -1,2 +1,2 @@
<?php <?php
return (new \Monolog\Logger('system'))->pushHandler(new \Monolog\Handler\StreamHandler(dirname(__DIR__, 3).'/var/logs/log'.date('Ymd').'.log')); return (new \Monolog\Logger('system'))->pushHandler(new \Monolog\Handler\StreamHandler(dirname(__DIR__, 2).'/var/logs/log'.date('Ymd').'.log'));

View File

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

5
config/container.php Normal file
View File

@@ -0,0 +1,5 @@
<?php
return [
"config/container/services.php",
"config/container/settings.php",
];

View File

@@ -1,7 +1,7 @@
<?php <?php
if(getenv("APP_MODE") == "PROD" && file_exists(dirname(__DIR__,3).'/var/routes/routes-main')){ if(getenv("APP_MODE") == "PROD" && file_exists(dirname(__DIR__,2).'/var/routes/routes-main')){
return unserialize(file_get_contents(dirname(__DIR__,3).'/var/routes/routes-main')); return unserialize(file_get_contents(dirname(__DIR__,2).'/var/routes/routes-main'));
} else { } else {
$routesCollection = array_map(function ($routesFile){ $routesCollection = array_map(function ($routesFile){
return file_get_contents($routesFile).PHP_EOL; return file_get_contents($routesFile).PHP_EOL;
@@ -9,7 +9,7 @@ if(getenv("APP_MODE") == "PROD" && file_exists(dirname(__DIR__,3).'/var/routes/r
$routes = yaml_parse(implode($routesCollection)); $routes = yaml_parse(implode($routesCollection));
if (!is_dir(dirname(__DIR__, 3).'/var/routes')) mkdir(dirname(__DIR__, 3).'/var/routes', 0777, true); if (!is_dir(dirname(__DIR__, 2).'/var/routes')) mkdir(dirname(__DIR__, 2).'/var/routes', 0777, true);
file_put_contents(dirname(__DIR__, 3).'/var/routes/routes-main', serialize($routes)); file_put_contents(dirname(__DIR__, 2).'/var/routes/routes-main', serialize($routes));
return $routes; return $routes;
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace Base\Application; namespace App\Infrastructure\Base\Application;
use ReflectionClass; use ReflectionClass;
@@ -24,4 +24,4 @@ abstract class AbstractDTO {
} }
return $self; return $self;
} }
} }

View File

@@ -1,7 +1,7 @@
<?php <?php
namespace Base\Application; namespace App\Infrastructure\Base\Application;
use Throwable; use Throwable;
@@ -13,4 +13,4 @@ class ApplicationException extends \Exception {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
$this->data = $data; $this->data = $data;
} }
} }

View File

@@ -1,7 +1,7 @@
<?php <?php
namespace Base\Application; namespace App\Infrastructure\Base\Application;
use Throwable; use Throwable;
@@ -13,4 +13,4 @@ class DTOException extends \Exception {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
$this->data = $data; $this->data = $data;
} }
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace Base\Infrastructure\Controllers; namespace App\Infrastructure\Base\Controllers;
use Laminas\Diactoros\Response\HtmlResponse; use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\JsonResponse; use Laminas\Diactoros\Response\JsonResponse;

View File

@@ -1,10 +1,10 @@
<?php <?php
namespace Base\Infrastructure\Controllers; namespace App\Infrastructure\Base\Controllers;
use Base\Application\ApplicationException; use App\Infrastructure\Base\Application\ApplicationException;
use Base\Application\DTOException; use App\Infrastructure\Base\Application\DTOException;
use Base\Domain\DomainException; use App\Infrastructure\Base\Domain\DomainException;
use Exception; use Exception;
use Throwable; use Throwable;

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace Base\Infrastructure\Controllers; namespace App\Infrastructure\Base\Controllers;
class NotFoundException extends \Exception { class NotFoundException extends \Exception {

View File

@@ -4,7 +4,7 @@
* User: Zuev Yuri * User: Zuev Yuri
*/ */
namespace Base\Domain; namespace App\Infrastructure\Base\Domain;
abstract class AbstractObject implements EntityInterface { abstract class AbstractObject implements EntityInterface {
@@ -14,4 +14,4 @@ abstract class AbstractObject implements EntityInterface {
public function getId(): mixed { public function getId(): mixed {
return (isset($this->id)) ? (($this->id instanceof ValueObjectInterface) ? $this->id->get() : $this->id) : null; return (isset($this->id)) ? (($this->id instanceof ValueObjectInterface) ? $this->id->get() : $this->id) : null;
} }
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace Base\Domain; namespace App\Infrastructure\Base\Domain;
use Throwable; use Throwable;
@@ -12,4 +12,4 @@ class DomainException extends \Exception {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
$this->data = $data; $this->data = $data;
} }
} }

View File

@@ -6,7 +6,7 @@
* Time: 3:58 * Time: 3:58
*/ */
namespace Base\Domain; namespace App\Infrastructure\Base\Domain;
interface EntityInterface { interface EntityInterface {
@@ -15,4 +15,4 @@ interface EntityInterface {
*/ */
public function getId(): mixed; public function getId(): mixed;
} }

View File

@@ -6,11 +6,11 @@
* Time: 3:58 * Time: 3:58
*/ */
namespace Base\Domain; namespace App\Infrastructure\Base\Domain;
interface ValueObjectInterface { interface ValueObjectInterface {
public function get(); public function get();
public function __toString(): string; public function __toString(): string;
} }

View File

@@ -1,8 +1,8 @@
<?php <?php
namespace Base\Infrastructure\Repository; namespace App\Infrastructure\Base\Repository;
use Base\Domain\EntityInterface; use App\Infrastructure\Base\Domain\EntityInterface;
use Rmphp\Storage\Mysql\MysqlStorageInterface; use Rmphp\Storage\Mysql\MysqlStorageInterface;
abstract class AbstractMysqlRepository extends AbstractRepository { abstract class AbstractMysqlRepository extends AbstractRepository {

View File

@@ -6,9 +6,9 @@
* Time: 13:06 * Time: 13:06
*/ */
namespace Base\Infrastructure\Repository; namespace App\Infrastructure\Base\Repository;
use Base\Domain\ValueObjectInterface; use App\Infrastructure\Base\Domain\ValueObjectInterface;
use ReflectionClass; use ReflectionClass;
use ReflectionException; use ReflectionException;
@@ -90,4 +90,4 @@ class AbstractRepository {
} }
return $out ?? []; return $out ?? [];
} }
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace Base\Infrastructure\Repository; namespace App\Infrastructure\Base\Repository;
use Throwable; use Throwable;
@@ -12,4 +12,4 @@ class RepositoryException extends \Exception {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
$this->data = $data; $this->data = $data;
} }
} }

View File

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