20240814#2

This commit is contained in:
User
2024-08-14 21:27:27 +03:00
parent 72d2445bb2
commit 99f78f7362
11 changed files with 14 additions and 15 deletions

View File

@@ -1,13 +1,13 @@
# Index
- key: "/"
routes:
- action: "App\\Main\\Infrastructure\\Controllers\\IndexController"
- action: "App\\Infrastructure\\Controllers\\IndexController"
method: "index"
params: ""
# Empty
- key: "<@any>"
routes:
- action: "App\\Main\\Infrastructure\\Controllers\\IndexController"
- action: "App\\nfrastructure\\Controllers\\IndexController"
method: "emptyAction"
params: ""

View File

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