88use Tamedevelopers \Database \Traits \AutoLoaderTrait ;
99use Tamedevelopers \Database \Schema \Pagination \PaginatorAsset ;
1010
11- class AutoLoader{
12-
11+ class AutoLoader
12+ {
1313 use AutoLoaderTrait;
1414
1515 protected static $ default ;
16+
17+ /**
18+ * Boot the AutoLoader::start.
19+ * If the constant 'TAME_AUTOLOADER_BOOT' is not defined,
20+ * it defines it and starts the debugger automatically
21+ *
22+ * So that this is only called once in entire application life-cycle
23+ *
24+ * @param string|null $path
25+ * @param bool $createDummy
26+ * @return void
27+ */
28+ public static function boot ($ path = null , $ createDummy = true )
29+ {
30+ if (!defined ('TAME_AUTOLOADER_BOOT ' )){
31+ // start auto loader
32+ self ::start ($ path , $ createDummy );
33+
34+ // Define boot logger as true
35+ define ('TAME_AUTOLOADER_BOOT ' , 1 );
36+ }
37+ }
1638
1739 /**
1840 * Star env configuration
1941 *
20- * @param string|null $custom_path
42+ * @param string|null $path
2143 * path \Path to .env file
2244 * - [optional] path \By default we use project root path
2345 *
46+ * @param bool $createDummy
47+ *
2448 * @return void
2549 */
26- public static function start ($ custom_path = null )
50+ public static function start ($ path = null , $ createDummy = true )
2751 {
2852 /*
2953 |--------------------------------------------------------------------------
3054 | Instance of class
3155 |--------------------------------------------------------------------------
3256 */
33- $ Env = new Env ($ custom_path );
57+ $ env = new Env ($ path );
3458
3559 /*
3660 |--------------------------------------------------------------------------
3761 | Create a sample .env file if not exist in project
3862 |--------------------------------------------------------------------------
3963 */
40- $ Env ::createOrIgnore ();
64+ $ env ::createOrIgnore ();
4165
4266 /*
4367 |--------------------------------------------------------------------------
@@ -47,25 +71,16 @@ public static function start($custom_path = null)
4771 | or exit with error status code
4872 |
4973 */
50- $ Env ::loadOrFail ();
51-
52- /*
53- |--------------------------------------------------------------------------
54- | Storing data into a Constant once everything is successful
55- |--------------------------------------------------------------------------
56- | We can now use on anywhere on our application
57- | Mostly to get our defined .env root Path
58- */
59- if ( ! defined ('TAME_SERVER_CONNECT ' ) ) {
60- define ('TAME_SERVER_CONNECT ' , $ Env ->getServers ());
61- }
74+ $ env ::loadOrFail ();
6275
6376 /*
6477 |--------------------------------------------------------------------------
6578 | Automatically create dummy files
6679 |--------------------------------------------------------------------------
6780 */
68- self ::createDummy (realpath (__DIR__ ));
81+ if ($ createDummy ){
82+ self ::createDummy (realpath (__DIR__ ));
83+ }
6984 }
7085
7186 /**
0 commit comments