Hey.
Faced with a rather strange problem - I can’t pass an object of class \ Silex \ Application to the controller's constructor
And without it, the controller is essentially not very useful. In general, what exactly I want to get is the ability to access the service container from the controller. (Twig, database, etc.).
$app->get('/','AppComponents\Controllers\HelloController::index' );
Well, the controller code itself
// HelloController.php namespace AppComponents\Controllers; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Silex; use Silex\Application; class HelloController{ protected $app; function __construct(Application $app) { $this->app = $app; } function index() { return new Response("hello"); } }
Yes, I know that you can register a controller as a service, but you want a more simple solution.
public function indexAction(Application $app)
- mantigatos 6:01 pm