@@ -19,6 +19,20 @@ public static function get($key, $default = null)
1919 return Env::get ($ keys [1 ], $ default );
2020 }
2121
22+ // Special handling for layout paths
23+ if ($ keys [0 ] === 'paths ' && $ keys [1 ] === 'layouts ' ) {
24+ // Handle layout paths specially
25+ if ($ keys [2 ] === 'welcome ' ) {
26+ return 'app/shared/layouts/welcome.php ' ;
27+ }
28+ if ($ keys [2 ] === 'default ' ) {
29+ return 'app/shared/layouts/main.php ' ;
30+ }
31+
32+ // Try to construct a path for other layouts
33+ return 'app/shared/layouts/ ' . $ keys [2 ] . '.php ' ;
34+ }
35+
2236 $ current = self ::$ config ;
2337
2438 foreach ($ keys as $ nestedKey ) {
@@ -39,7 +53,8 @@ protected static function loadConfig()
3953 if (file_exists ($ configFile )) {
4054 $ configContent = file_get_contents ($ configFile );
4155 self ::$ config = json_decode ($ configContent , true ) ?: [];
42-
56+
57+
4358 // Override database config with environment variables
4459 if (isset (self ::$ config ['database ' ])) {
4560 self ::$ config ['database ' ]['driver ' ] = Env::get ('DB_DRIVER ' , self ::$ config ['database ' ]['driver ' ]);
@@ -55,9 +70,18 @@ protected static function loadConfig()
5570 self ::$ config ['config ' ]['storage ' ]['max_size ' ] = Env::get ('STORAGE_MAX_SIZE ' , self ::$ config ['config ' ]['storage ' ]['max_size ' ]);
5671 }
5772 } else {
58- // Handle the case when the config file is not found
59- echo 'Error: Configuration file not found ' ;
60- self ::$ config = [];
73+ // Create a default config
74+ self ::$ config = [
75+ 'name ' => 'WarvilPHP ' ,
76+ 'description ' => 'A lightweight PHP framework ' ,
77+ 'author ' => 'WardVisual ' ,
78+ 'paths ' => [
79+ 'layouts ' => [
80+ 'default ' => 'app/shared/layouts/main.php ' ,
81+ 'welcome ' => 'app/shared/layouts/welcome.php '
82+ ]
83+ ]
84+ ];
6185 }
6286 }
6387}
0 commit comments