Init
This commit is contained in:
17
config/appnodes.php
Normal file
17
config/appnodes.php
Normal 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
21
config/components.php
Normal 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',
|
||||
];
|
||||
|
||||
11
config/container/services.php
Normal file
11
config/container/services.php
Normal 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'),
|
||||
];
|
||||
5
config/container/settings.php
Normal file
5
config/container/settings.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
//"container key"=>value
|
||||
];
|
||||
18
config/factories/containerFactory.php
Normal file
18
config/factories/containerFactory.php
Normal 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();}
|
||||
2
config/factories/loggerFactory.php
Normal file
2
config/factories/loggerFactory.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
return (new \Monolog\Logger('system'))->pushHandler(new \Monolog\Handler\StreamHandler(__DIR__.'/../../var/logs/log'.date('Ymd').'.log'));
|
||||
2
config/factories/routerFactory.php
Normal file
2
config/factories/routerFactory.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
return new \Rmphp\Router\Router();
|
||||
2
config/factories/templateFactory.php
Normal file
2
config/factories/templateFactory.php
Normal 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
14
config/routes/main.json
Normal 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
12
config/routes/main.yaml
Normal 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: ""
|
||||
13
config/routes/main/09-main.yaml
Normal file
13
config/routes/main/09-main.yaml
Normal 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: ""
|
||||
9
config/routes/main/collection.php
Normal file
9
config/routes/main/collection.php
Normal 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));
|
||||
Reference in New Issue
Block a user