@@ -43,12 +43,14 @@ public static function config($key, $default = null, string $base_folder = 'conf
4343 if ($ tame ->isAppFramework ()) {
4444 $ basePath = self ::pathReplacer (self ::formatWithBaseDirectory (), '\\' );
4545
46+ // Laravel: register Application if not already set on the container
4647 if ($ tame ->isLaravel ()){
47- // Laravel: register Application if not already set on the container
48- $ laravel = "\Illuminate\Foundation\Application " ;
49- new $ laravel (
50- $ _ENV ['APP_BASE_PATH ' ] ?? $ basePath
51- );
48+ try {
49+ $ bootstrap = "{$ basePath }/bootstrap/app.php " ;
50+ require_once $ bootstrap ;
51+ } catch (\Throwable $ th ) {
52+ // Ignore continous error
53+ }
5254 }
5355 }
5456 }
@@ -57,13 +59,14 @@ public static function config($key, $default = null, string $base_folder = 'conf
5759 }
5860
5961 // Convert the key to an array
60- $ parts = explode ('. ' , $ key );
62+ $ parts = explode ('. ' , $ key );
63+ $ config = [];
6164
6265 // Get the file name
6366 $ filePath = self ::formatWithBaseDirectory ("{$ base_folder }/ {$ parts [0 ]}.php " );
6467
6568 // Check if the configuration file exists
66- if (file_exists ($ filePath )) {
69+ if (File:: exists ($ filePath )) {
6770 // Load the configuration array from the file
6871 $ config = require ($ filePath );
6972 }
@@ -80,13 +83,8 @@ public static function config($key, $default = null, string $base_folder = 'conf
8083 }
8184 }
8285
83- // if config not set
84- if (!isset ($ config )){
85- $ config = null ;
86- }
87-
8886 // try merging data if an array
89- if (is_array ($ config ) && is_array ($ default )){
87+ if (! empty ($ config ) && is_array ($ default )){
9088 return array_merge ($ config , $ default );
9189 }
9290
0 commit comments