Answer the question
In order to leave comments, you need to log in
Is there an implementation of polymorphism for HTTP and CLI requests in PHP?
For example, in PHP a variable passed via get can be retrieved with `$_GET`, and one passed from the command line via $argv.
Is there some library/class that will allow you to use yourself like:
```
$var = $request->name
```
... and it will work regardless, pass `name` via `?name=myname` ( GET) or CLI `php script.php name=myname`?
Answer the question
In order to leave comments, you need to log in
No. There are separate libraries that provide you with an abstraction from HTTP and an abstraction from CLI. From above, you can then make your own wrap. I've made it for myself but it's more for http - in cli I can just map the data.
CleverStyle Framework provides just such an abstraction out of the box, but it is not a library, but a whole framework. There, the routing is identical for web and CLI requests, you can read the article: https://habrahabr.ru/post/307690/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question