@@ -69,6 +69,8 @@ public function bootstrap(Application $app)
69
69
//Additional adjustments
70
70
$ finalConfig ->set ('APP_DEBUG ' , $ finalConfig ->get ('debug ' ) ? true : false );
71
71
72
+ $ this ->setBaseConstants ($ finalConfig ->get ('appUrl ' ), $ app );
73
+
72
74
if ($ finalConfig ->get ('app.url ' ) == '' ) {
73
75
$ url = defined ('BASE_URL ' ) ? BASE_URL : 'http://localhost ' ;
74
76
$ finalConfig ->set ('app.url ' , $ url );
@@ -93,6 +95,38 @@ public function bootstrap(Application $app)
93
95
94
96
}
95
97
98
+ /**
99
+ * Sets the URL constants for the application.
100
+ *
101
+ * If the BASE_URL constant is not defined, it will be set based on the value of $appUrl parameter.
102
+ * If $appUrl is empty or not provided, it will be set using the getSchemeAndHttpHost method of the class.
103
+ *
104
+ * The APP_URL environment variable will be set to the value of $appUrl.
105
+ *
106
+ * If the CURRENT_URL constant is not defined, it will be set by appending the getRequestUri method result to the BASE_URL.
107
+ *
108
+ * @param string $appUrl The URL to be used as BASE_URL and APP_URL. Defaults to an empty string.
109
+ * @return void
110
+ */
111
+ public function setBaseConstants ($ appUrl , $ app ) {
112
+
113
+ if (! defined ('BASE_URL ' )) {
114
+ if (isset ($ appUrl ) && ! empty ($ appUrl )) {
115
+ define ('BASE_URL ' , $ appUrl );
116
+
117
+ } else {
118
+ define ('BASE_URL ' , request ()->getSchemeAndHttpHost ());
119
+ }
120
+ }
121
+
122
+ putenv ('APP_URL= ' .$ appUrl );
123
+
124
+ if (! defined ('CURRENT_URL ' )) {
125
+ define ('CURRENT_URL ' , BASE_URL .request ()->getRequestUri ());
126
+ }
127
+
128
+ }
129
+
96
130
/**
97
131
* Load the configuration files.
98
132
*
0 commit comments