This repository was archived by the owner on Jan 5, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Modulus \Framework ;
4+
5+ use Modulus \Http \Rest ;
6+ use Modulus \Http \Redirect ;
7+ use Modulus \Framework \Upstart ;
8+
9+ class Response
10+ {
11+ /**
12+ * Make application response
13+ *
14+ * @param Upstart $app
15+ */
16+ public static function make (Upstart $ app )
17+ {
18+ /**
19+ * Get application response
20+ */
21+ $ response = $ app ->getResponse ();
22+
23+ /**
24+ * Create a rest response
25+ */
26+ if (
27+ is_string ($ response ) ||
28+ is_int ($ response ) ||
29+ is_float ($ response ) ||
30+ is_double ($ response ) ||
31+ is_array ($ response )
32+ ) return is_array ($ response ) ? Rest::response ()->json ($ response )->send () : Rest::response ($ response )->send ();
33+
34+ if (is_bool ($ response )) return Rest::response ($ response ? 'true ' : 'false ' )->send ();
35+
36+ if ($ response instanceof Rest) return $ response ->send ();
37+
38+ /**
39+ * Create a redirect
40+ */
41+ if ($ response instanceof Redirect) return $ response ->send ();
42+
43+ /**
44+ * Avoid "Segmentation fault (core dumped)"
45+ */
46+ echo '' ;
47+ }
48+ }
Original file line number Diff line number Diff line change @@ -39,12 +39,20 @@ class Upstart
3939 */
4040 protected $ request ;
4141
42+ /**
43+ * $response
44+ *
45+ * @var mixed
46+ */
47+ protected $ response ;
48+
4249 /**
4350 * Start application
4451 *
45- * @return void
52+ * @param bool|null $isConsole
53+ * @return Upstart $this
4654 */
47- public function boot (?bool $ isConsole = false ) : void
55+ public function boot (?bool $ isConsole = false ) : Upstart
4856 {
4957 /**
5058 * Add cors to the request
@@ -55,7 +63,7 @@ public function boot(?bool $isConsole = false) : void
5563 * Don't load framework components, if
5664 * the application has already started.
5765 */
58- if (Upstart::$ isReady ) return ;
66+ if (Upstart::$ isReady ) return $ this ;
5967
6068 /**
6169 * Load application components
@@ -69,6 +77,8 @@ public function boot(?bool $isConsole = false) : void
6977 * it has started.
7078 */
7179 Upstart::$ isReady = true ;
80+
81+ return $ this ;
7282 }
7383
7484 /**
@@ -148,4 +158,14 @@ public function getRequest()
148158 {
149159 return $ this ->request ;
150160 }
161+
162+ /**
163+ * Get application response
164+ *
165+ * @return mixed
166+ */
167+ public function getResponse ()
168+ {
169+ return $ this ->response ;
170+ }
151171}
Original file line number Diff line number Diff line change 22
33namespace Modulus \Framework \Upstart ;
44
5- use Modulus \Http \Rest ;
65use Modulus \Http \Status ;
76use Modulus \Http \Request ;
87use Modulus \Utility \View ;
9- use Modulus \Http \Redirect ;
108use Modulus \Utility \Events ;
119use AtlantisPHP \Swish \Route ;
1210use Modulus \Utility \Reflect ;
@@ -112,24 +110,6 @@ private function swishView()
112110 */
113111 private function handleResponse ($ response )
114112 {
115- /**
116- * Create a rest response
117- */
118- if (
119- is_string ($ response ) ||
120- is_int ($ response ) ||
121- is_float ($ response ) ||
122- is_double ($ response ) ||
123- is_array ($ response )
124- ) return is_array ($ response ) ? Rest::response ()->json ($ response )->send () : Rest::response ($ response )->send ();
125-
126- if (is_bool ($ response )) return Rest::response ($ response ? 'true ' : 'false ' )->send ();
127-
128- if ($ response instanceof Rest) return $ response ->send ();
129-
130- /**
131- * Create a redirect
132- */
133- if ($ response instanceof Redirect) return $ response ->send ();
113+ $ this ->response = $ response ;
134114 }
135115}
Original file line number Diff line number Diff line change 11{
22 "name" : " modulusphp/framework" ,
33 "description" : " Framework component for Modulus" ,
4- "version" : " 1.9.8.11 " ,
4+ "version" : " 1.9.9.0 " ,
55 "license" : " MIT" ,
66 "type" : " package" ,
77 "authors" : [{
You can’t perform that action at this time.
0 commit comments