20240413#7
This commit is contained in:
@@ -9,10 +9,11 @@
|
|||||||
# Real environment variables win over .env files.
|
# Real environment variables win over .env files.
|
||||||
|
|
||||||
# PROD / DEV
|
# PROD / DEV
|
||||||
APP_MODE=DEV
|
APP_MODE=PROD
|
||||||
APP_COMPONENTS_FILE=config/app.php
|
|
||||||
APP_NODES_FILE=config/nodes.php
|
APP_COMPONENTS_FILE=application/config/app.php
|
||||||
CONTAINER_DIR=config/container
|
APP_NODES_FILE=application/config/nodes.php
|
||||||
|
CONTAINER_DIR=application/config/container
|
||||||
CONTAINER_CACHE=var/cache/container
|
CONTAINER_CACHE=var/cache/container
|
||||||
|
|
||||||
# Default page
|
# Default page
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ return [
|
|||||||
/**
|
/**
|
||||||
* Путь к файлу фабрики возвращающий реализацию RouterInterface или сам экземпляр класса
|
* Путь к файлу фабрики возвращающий реализацию RouterInterface или сам экземпляр класса
|
||||||
*/
|
*/
|
||||||
\Rmphp\Foundation\RouterInterface::class => 'config/factories/routerFactory.php',
|
\Rmphp\Foundation\RouterInterface::class => 'application/config/factories/routerFactory.php',
|
||||||
/**
|
/**
|
||||||
* Путь к файлу фабрики возвращающий реализацию TemplateInterface или сам экземпляр класса
|
* Путь к файлу фабрики возвращающий реализацию TemplateInterface или сам экземпляр класса
|
||||||
*/
|
*/
|
||||||
\Rmphp\Foundation\TemplateInterface::class => 'config/factories/templateFactory.php',
|
\Rmphp\Foundation\TemplateInterface::class => 'application/config/factories/templateFactory.php',
|
||||||
/**
|
/**
|
||||||
* Путь к файлу фабрики возвращающий реализацию PSR-3 LoggerInterface или сам экземпляр класса
|
* Путь к файлу фабрики возвращающий реализацию PSR-3 LoggerInterface или сам экземпляр класса
|
||||||
*/
|
*/
|
||||||
\Psr\Log\LoggerInterface::class => 'config/factories/loggerFactory.php',
|
\Psr\Log\LoggerInterface::class => 'application/config/factories/loggerFactory.php',
|
||||||
/**
|
/**
|
||||||
* Путь к файлу фабрики возвращающий реализацию PSR-11 ContainerInterface или сам экземпляр класса
|
* Путь к файлу фабрики возвращающий реализацию PSR-11 ContainerInterface или сам экземпляр класса
|
||||||
*/
|
*/
|
||||||
\Psr\Container\ContainerInterface::class => 'config/factories/containerFactory.php',
|
\Psr\Container\ContainerInterface::class => 'application/config/factories/containerFactory.php',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
use DI\ContainerBuilder;
|
use DI\ContainerBuilder;
|
||||||
|
|
||||||
$containerDir = (getenv("CONTAINER_DIR"))?:"config/container";
|
$containerDir = (getenv("CONTAINER_DIR")) ?: "application/config/container";
|
||||||
$containerCache = (getenv("CONTAINER_CACHE"))?:"var/cache/container";
|
$containerCache = (getenv("CONTAINER_CACHE"))?:"var/cache/container";
|
||||||
|
|
||||||
$dependencies = glob(dirname(__DIR__,2)."/".$containerDir."/*.php");
|
$dependencies = glob(dirname(__DIR__,3)."/".$containerDir."/*.php");
|
||||||
$dependenciesCollection = array_map(function ($dependenciesFile){
|
$dependenciesCollection = array_map(function ($dependenciesFile){
|
||||||
return require $dependenciesFile;
|
return require $dependenciesFile;
|
||||||
}, $dependencies);
|
}, $dependencies);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$builder = new ContainerBuilder();
|
$builder = new ContainerBuilder();
|
||||||
if(getenv("APP_MODE") != "DEV") $builder->enableCompilation(dirname(__DIR__,2)."/".$containerCache);
|
if(getenv("APP_MODE") == "PROD") $builder->enableCompilation(dirname(__DIR__,3)."/".$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();}
|
||||||
2
application/config/factories/loggerFactory.php
Normal file
2
application/config/factories/loggerFactory.php
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
return (new \Monolog\Logger('system'))->pushHandler(new \Monolog\Handler\StreamHandler(dirname(__DIR__, 3).'/var/logs/log'.date('Ymd').'.log'));
|
||||||
@@ -9,6 +9,6 @@
|
|||||||
# ['key'=>'/', 'router'=>[]],
|
# ['key'=>'/', 'router'=>[]],
|
||||||
|
|
||||||
return [
|
return [
|
||||||
['key'=>'/', 'router'=>'config/routes/main/routes.php'],
|
['key'=>'/', 'router'=>'application/config/routes/main/routes.php'],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"App\\": "src",
|
"App\\": "src",
|
||||||
"Base\\": "application"
|
"Base\\": "application/src"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
<?php
|
|
||||||
return (new \Monolog\Logger('system'))->pushHandler(new \Monolog\Handler\StreamHandler(__DIR__.'/../../var/logs/log'.date('Ymd').'.log'));
|
|
||||||
Reference in New Issue
Block a user