Request in DI-Container


i wanted to use the yii di-container for my project. Everything is working fine so far, but i came across a problem with constructor injection. In my project i want to create a ‘service’ for crud operations and i want to implement the service against an interface, but the service needs the request->post() and i dont want to set the request, because it is not part of the interface:

use base\yii\Object;

class UserService extends Object implements UserServiceInterface {

public $request;

public function __construct($request, config = []) {}


Can i inject the request into the Object, for example in bootstrap file: Yii::$container->set(‘UserServiceInterface’, ‘UserService’, [‘request’ => Yii::$app->request->post());


this seems wrong. Is this even best practice or shouldnt you be injecting this??