I'm trying to inject a dependency into my Silex Controller, because I need an object of type user in my controller and handle some stuff with it.
$app->mount("/users", new \MyApp\Controller\Provider\User($user));
And I implemented the controller by implementing the ControllerProviderInterface:
class User implements ControllerProviderInterface{
protected $user;
public function __construct($user){
//...
}
public function connect(Application $app)
{
//...
}
}
The routes and the methods are all set up in the controller. Without the dependency injection everything works fine. But as long as I edit the code and add the injection I get the following error:
Missing argument 1 for ...::__construct()
When I create the object, I send that parameter to it, but somehow Silex creates an instance before with a constructor without passing any argument.