I can not transfer object to the controller.

Router:

$r->addRoute('GET', '/user', 'MainController@index'); 

Controller:

 use namespace\MyClass; $myObject = new MyClass; class MainController { private $myObject; public function __construct(MyClass $myObject) { $this->myObject= $myObject; } public function index() { echo 'MainController...'; } } 

How is this done in php in the classics?

  • According to the classics, this is done by a container of dependencies (Dependency Injection) - ArchDemon
  • Well, I'll see - MyNick 1:58 pm

0