7 Commits
4.11 ... 5.1.1

Author SHA1 Message Date
User
1106b4af47 20250807#1 2025-08-07 01:31:59 +03:00
User
a2650ab53f 20250706#2 2025-07-06 20:12:09 +03:00
User
0558bb121d 20250706#1 2025-07-06 20:11:27 +03:00
User
b5ecb1fc86 20250622#1 2025-06-22 13:54:05 +03:00
User
618d0029fa 20250419#3 2025-04-19 19:02:53 +03:00
User
4f38812468 20250419#2 2025-04-19 19:00:46 +03:00
User
b263351289 20250419#1 2025-04-19 19:00:02 +03:00
10 changed files with 25 additions and 89 deletions

View File

@@ -8,7 +8,7 @@
# #
# Real environment variables win over .env files. # Real environment variables win over .env files.
# PROD / DEV # DEBUG / DEV / PROD
APP_MODE=DEV APP_MODE=DEV
APP_NODES_FILE=config/app.php APP_NODES_FILE=config/app.php
CLI_NODES_FILE=config/app-cli.php CLI_NODES_FILE=config/app-cli.php
@@ -21,5 +21,5 @@ PAGE404="/templates/error/404.tpl"
PAGE501="/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***", "charset":"utf8mb4", "logsEnable":true}'
REDIS_PARAM='{"host":"127.0.0.1","port":6379,"connectTimeout":2.5,"backoff":{"algorithm":1,"base":500,"cap":750}, "database":0, "defaultExpire":300}' REDIS_PARAM='{"host":"127.0.0.1","port":6379,"connectTimeout":2.5,"backoff":{"algorithm":1,"base":500,"cap":750}, "database":0, "defaultExpire":300}'

View File

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

View File

@@ -1,41 +0,0 @@
<?php
namespace Base\Application;
use Exception;
use ReflectionClass;
use Rmphp\Storage\Component\AbstractDataObject;
abstract class AbstractDTO extends AbstractDataObject {
/**
* @param array|object ...$data
* @return static
* @throws Exception
*/
public static function fromData(array|object ...$data) : static {
$array = array_map(function($item) {
return (is_object($item)) ? get_object_vars($item) : $item;
}, $data);
return self::fromArray(array_merge(...$array));
}
/**
* @param object $data
* @return static
* @throws Exception
*/
public static function fromObject(object $data) : static {
return self::fromArray(get_object_vars($data));
}
/**
* @param array $data
* @return static
* @throws Exception
*/
public static function fromArray(array $data) : static {
return self::fillObject(new ReflectionClass(static::class), new static(), $data);
}
}

View File

@@ -1,16 +0,0 @@
<?php
namespace Base\Application;
use Throwable;
class DTOException extends \Exception {
public array $data;
public function __construct($message="", $code=0, array $data = [], Throwable $previous=null) {
parent::__construct($message, $code, $previous);
$this->data = $data;
}
}

View File

@@ -3,33 +3,19 @@
namespace Base\Controllers; namespace Base\Controllers;
use Base\Application\ApplicationException; use Base\Application\ApplicationException;
use Base\Application\DTOException;
use Base\Domain\DomainException; use Base\Domain\DomainException;
use Exception; use Exception;
use Throwable; use Throwable;
abstract class AbstractPageController extends AbstractController { abstract class AbstractPageController extends AbstractController {
/**
* @param Exception $exception
* @param array $data
* @return void
*/
public function exceptionPage(Exception $exception, array $data = []) : void {
$this->logException($exception, $data);
$this->syslogger()->warning($exception->getMessage()." on ".$exception->getFile().":".$exception->getLine(), $data);
$this->template()->setSubtemplate("main", "/error/errpage.tpl", [
"errorText" => "<span style='color:red'>Error: ".$exception->getMessage()." (".$exception->getCode().")"."</span>"
]);
}
/** /**
* @param Throwable $e * @param Throwable $e
* @return string * @return string
*/ */
public function checkError(Throwable $e) : string { public function checkError(Throwable $e) : string {
($e instanceof Exception) ? $this->logException($e) : $this->logError($e); ($e instanceof Exception) ? $this->logException($e) : $this->logError($e);
if($e instanceof DTOException || $e instanceof DomainException || $e instanceof ApplicationException) return $e->getMessage(); if($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

@@ -5,20 +5,20 @@
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable" : true, "prefer-stable" : true,
"require": { "require": {
"php": "^8.1", "php": "^8.3",
"ext-json": "*", "ext-json": "*",
"ext-yaml": "*", "ext-yaml": "*",
"laminas/laminas-diactoros": "^2.5", "laminas/laminas-diactoros": "^2.26",
"monolog/monolog": "^2.3", "monolog/monolog": "^2.10",
"php-di/php-di": "^6.3", "php-di/php-di": "^6.4",
"ramsey/uuid": "^4.7", "ramsey/uuid": "^4.9",
"rmphp/content": "^4.0", "rmphp/content": "^4.1",
"rmphp/kernel": "^6.0", "rmphp/kernel": "^6.1",
"rmphp/router": "^2.0", "rmphp/router": "^2.1",
"rmphp/session": "^1.1", "rmphp/session": "^1.1",
"rmphp/redis": "^1.0", "rmphp/redis": "^1.0",
"rmphp/storage": "^9.0", "rmphp/storage": "^12.0",
"symfony/dotenv": "^6.2" "symfony/dotenv": "^6.4"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@@ -34,7 +34,7 @@
"process-timeout":0 "process-timeout":0
}, },
"require-dev": { "require-dev": {
"symfony/var-dumper": "^5.3", "symfony/var-dumper": "^5.4",
"rmphp/var-damper": "^1.0" "rmphp/var-damper": "^1.1"
} }
} }

View File

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

View File

@@ -0,0 +1,6 @@
<?php
return [
'MYSQL_PARAM' => json_decode(getenv("MYSQL_PARAM"), true),
'REDIS_PARAM' => json_decode(getenv("REDIS_PARAM"), true),
];

View File

@@ -4,7 +4,7 @@ use Rmphp\Storage\Mysql\MysqlStorage;
use Rmphp\Storage\Mysql\MysqlStorageInterface; use Rmphp\Storage\Mysql\MysqlStorageInterface;
return [ return [
MysqlStorageInterface::class => DI\create(MysqlStorage::class)->constructor(json_decode(getenv("MYSQL_PARAM"))), MysqlStorageInterface::class => DI\create(MysqlStorage::class)->constructor(DI\get("MYSQL_PARAM")),
'App\Domain\Repository\*RepositoryInterface' => DI\autowire('App\Infrastructure\Repository\*Repository'), 'App\Domain\Repository\*RepositoryInterface' => DI\autowire('App\Infrastructure\Repository\*Repository'),
'App\*\Domain\Repository\*RepositoryInterface' => DI\autowire('App\*\Infrastructure\Repository\*Repository'), 'App\*\Domain\Repository\*RepositoryInterface' => DI\autowire('App\*\Infrastructure\Repository\*Repository'),
]; ];

View File

@@ -23,7 +23,7 @@ $app = new App();
$response = $app->handler($request, new Response()); $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 && in_array(getenv("APP_MODE"), ['DEBUG', '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());
} }