0

Slim's controllers receive PSR-7 Request and Response objects. The problem is that I want to use my own SomeCustomRequest classes that extends Slim's one in different controller's actions. I know how to set my own Request and Response classes in container but then it will be used for all the controllers. I don't want this.

Example:

class UserController {
    public function store(CreateRequest $request, Response $response) {
        // Some logic to create user using CreateRequest
    }

    public function update(UpdateRequest $request, Response $response) {
        // Some logic to update user using UpdateRequest
    }
}

Is it possible to inject proper custom Request class into action? Like Laravel does it.

Thanks a lot for any advice!

Shandur
  • 41
  • 8
  • Why would you want to do this? – jmattheis Jun 13 '17 at 06:18
  • 1
    @jmattheis Because I have interfaces like getUserCredentials() or getCompanyCredentials() in particular request, and it's very comfortable to work with like in Laravel. But I don't need all the Laravel's stuff :( That's why I decided to ask people – Shandur Jun 13 '17 at 09:51

0 Answers0