This commit is contained in:
User
2023-05-29 03:04:33 +03:00
commit 67221e0d93
41 changed files with 516 additions and 0 deletions

17
config/appnodes.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
/**
* Правила для точек монтирования модулей
* Каждый массив определяет порядок срабатывания, часть url с которого
*/
# Example:
# ['key'=>'/', "action"=>"App\\Main\\Controllers\\IndexController", "method"=>"index"],
# ['key'=>'/', 'router'=>'config/routes/main/collection.php'],
# ['key'=>'/', 'router'=>'config/routes/main.json']
# ['key'=>'/', 'router'=>'config/routes/main.yaml'],
return [
['key'=>'/', 'router'=>'config/routes/main.yaml'],
];

21
config/components.php Normal file
View File

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

View File

@@ -0,0 +1,11 @@
<?php
use Rmphp\Storage\MysqlStorage;
use Rmphp\Storage\MysqlStorageInterface;
return [
MysqlStorageInterface::class => DI\create(MysqlStorage::class)->constructor(json_decode(getenv("MYSQL_PARAM"), true)),
'App\*\Domain\Repository\*RepositoryInterface' => DI\autowire('App\*\Repository\Mysql\*Repository'),
'App\*\Services\*\*Service' => DI\autowire('App\*\Services\*\*Service'),
'App\*\Services\*Service' => DI\autowire('App\*\Services\*Service'),
];

View File

@@ -0,0 +1,5 @@
<?php
return [
//"container key"=>value
];

View File

@@ -0,0 +1,18 @@
<?php
use DI\ContainerBuilder;
$containerDir = (getenv("CONTAINER_DIR"))?:"config/container/";
$dependencies = glob(dirname(__DIR__,2)."/".$containerDir."/*.php");
$dependenciesCollection = array_map(function ($dependenciesFile){
return require $dependenciesFile;
}, $dependencies);
try {
$builder = new ContainerBuilder();
$builder->enableCompilation(__DIR__ . '/../../var/cache/container');
$builder->addDefinitions(array_replace_recursive(...$dependenciesCollection));
return $builder->build();
} catch (Exception $e) {echo $e->getMessage();}

View File

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

View File

@@ -0,0 +1,2 @@
<?php
return new \Rmphp\Router\Router();

View File

@@ -0,0 +1,2 @@
<?php
return (new \Rmphp\Content\Content('public/web/main/sheet.html'))->setSubtemplePath('templates');

14
config/routes/main.json Normal file
View File

@@ -0,0 +1,14 @@
[
{
"key": "/",
"routes": [
{"action": "App\\Main\\Controllers\\IndexController", "method": "index", "params": ""}
]
},
{
"key": "[any]",
"routes": [
{"action": "App\\Main\\Controllers\\IndexController", "method": "emptyAction", "params": ""}
]
}
]

12
config/routes/main.yaml Normal file
View File

@@ -0,0 +1,12 @@
- key: "/"
routes:
- action: "App\\Main\\Controllers\\IndexController"
method: "index"
params: ""
# Empty
- key: "[any]"
routes:
- action: "App\\Main\\Controllers\\IndexController"
method: "emptyAction"
params: ""

View File

@@ -0,0 +1,13 @@
# Index
- key: "/"
routes:
- action: "App\\Main\\Controllers\\IndexController"
method: "index"
params: ""
# Empty
- key: "[any]"
routes:
- action: "App\\Main\\Controllers\\IndexController"
method: "emptyAction"
params: ""

View File

@@ -0,0 +1,9 @@
<?php
$routes = glob(__DIR__."/{*.yaml}", GLOB_BRACE);
$routesCollection = array_map(function ($routesFile){
return file_get_contents($routesFile).PHP_EOL;
}, $routes);
return yaml_parse(implode($routesCollection));