【发布时间】:2019-04-26 20:33:21
【问题描述】:
什么是实现依赖注入的最佳方式,这种方式:
new App\Controllers\HomeController();
类 HomeController
use App\Views\HomeView;
class HomeController {
private $view;
public function __construct() {
$this->view = new HomeView();
或者这样:
new App\Controllers\HomeController(new App\Views\HomeView());
【问题讨论】:
标签: php dependency-injection namespaces