20240719#1
This commit is contained in:
@@ -9,6 +9,5 @@
|
||||
# ['key'=>'/', 'router'=>[]],
|
||||
|
||||
return [
|
||||
['key'=>'/', 'router'=>'application/config/routes/main/routes.php'],
|
||||
['key'=>'/', 'router'=>'application/config/routes/routes.php'],
|
||||
];
|
||||
|
||||
0
application/config/routes/main/.gitkeep
Normal file
0
application/config/routes/main/.gitkeep
Normal file
@@ -1,9 +0,0 @@
|
||||
<?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));
|
||||
17
application/config/routes/routes.php
Normal file
17
application/config/routes/routes.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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'));
|
||||
} 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)));
|
||||
|
||||
$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));
|
||||
}
|
||||
return $routes;
|
||||
}
|
||||
Reference in New Issue
Block a user