File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -57,5 +57,5 @@ And you will see the result: 123
57
57
You can run this route in CLI mode
58
58
59
59
``` shell
60
- php .\i ndex.php /teste/123
60
+ php .\i ndex.php GET /teste/123
61
61
```
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ public function getDynamicParameters(Route $acessedRoute) : RouteParameters
54
54
}
55
55
}
56
56
}
57
+
57
58
return $ parameters ;
58
59
}
59
60
}
Original file line number Diff line number Diff line change @@ -14,9 +14,10 @@ public function controllers(array $controllers = [])
14
14
{
15
15
$ this ->controllers = $ controllers ;
16
16
$ this ->run ();
17
+ return $ this ;
17
18
}
18
19
19
- public function run ()
20
+ private function run ()
20
21
{
21
22
$ acessedRoute = $ this ->getAccessedRoute ();
22
23
@@ -35,17 +36,17 @@ public function run()
35
36
}
36
37
}
37
38
}
38
-
39
- public function isCli ()
39
+
40
+ private function isCli ()
40
41
{
41
42
return php_sapi_name () === 'cli ' ;
42
43
}
43
44
44
- public function getAccessedRoute ()
45
+ private function getAccessedRoute ()
45
46
{
46
47
global $ argv ;
47
- $ route = $ this ->isCli () ? $ argv [1 ] : $ _SERVER ['REQUEST_URI ' ];
48
- $ method = $ this ->isCli () ? " GET " : $ _SERVER ['REQUEST_METHOD ' ];
48
+ $ route = $ this ->isCli () ? $ argv [2 ] : explode ( " ? " , $ _SERVER ['REQUEST_URI ' ])[ 0 ];
49
+ $ method = $ this ->isCli () ? $ argv [ 1 ] : explode ( " ? " , $ _SERVER ['REQUEST_METHOD ' ])[ 0 ];
49
50
50
51
return new Route ($ route , $ method );
51
52
}
You can’t perform that action at this time.
0 commit comments