On Tue, Jan 24, 2017 at 1:14 PM, Rasmus Schultz <[email protected]> wrote:
>> While I can certainly see the value in the architecture this would imply,
>> it's by no means the only architecture
>
> I disagree that this implies architecture.
>
> "takes a request and returns a response" is in my opinion the least
> opinionated, most open-ended definition you can have of a controller - in my
> opinion, it does not imply architecture, at all. You're completely free to
> use traits, composition, base-classes, external services, registries,
> dependency-injection, middleware - anything you can dream up, the only
> requirement is that you ultimately take a PSR-7 request and produce a
> response, which, ultimately, if you're using PSR-7, you're going to, one way
> or the other.

It does imply architecture, however: one controller, one action.

Most MVC systems I've surveyed or participated in maintaining provide
a way to map multiple actions to a single controller, which
necessarily means multiple entry points:

```php
class SomeController
{
    public function listAction($request)
    {
    }

    public function fetchAction($request)
    {
    }

    public function createAction($request)
    {
    }

    public function deleteAction($request)
    {
    }
}
```

Sometimes this means standardization of method names (as detailed
above), sometimes there is a 1:1 relationship between an action and
the method name, sometimes there's a single entry method that then
dispatches to the appropriate method based on the action matched, etc.

Additionally, I've seen systems that will pull path matches and pass
them as discrete arguments to the controller/action, often with the
request as a catch-all at the end of the list:

```php
// Route: /article/:id
public function update($id, $request)
{
}
```

I personally have been pushing folks to follow the "1 route, 1
controller" paradigm, which is what your proposal suggests, but that's
a _suggestion_; _requiring_ it via a standard, however, means any
implementing library _requires_ that approach, which I suggest would
limit adoption.

-- 
Matthew Weier O'Phinney
[email protected]
https://mwop.net/

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/CAJp_myWsLaaPKMaT%3DwG1OvDjsw9KH7ZiEpWgvFKo2%2BfiVo55UA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to