当我尝试在构造函数中使用自动解析依赖项时,我收到一个错误,尽管在方法中它工作正常。
<?php
namespace App\Controller;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
class AuthorController
{
// Produce an error
// public $app;
// public $request;
// public $entityManager;
//
// public function __construct(Application $app, Request $request)
// {
// $this->app=$app;
// $this->request=$request;
// }
public function create(Application $app, Request $request)
{
}
}
Argument 1 passed to App\Controller\AuthorController::__construct() must be an instance of Silex\Application, none given
子衿沉夜