Answer the question
In order to leave comments, you need to log in
Why is there no controllers folder in silex framework?
Hello.
Tell me please, where should controllers and models be stored in this framework?
Or are the controllers simply split into separate files (along with their respective routes) and then simply included in controllers.php?
Tell me please. I just installed silex, and I understand
Answer the question
In order to leave comments, you need to log in
Silex does not have a strict structure out of the box, we have a project with routing right in index.php in our production, and inside the routes, the methods of the necessary services simply twitch. Something like this:
$forecast = $app['controllers_factory'];
$forecast->get('/calculations', function (Request $request) use ($app) {
$data = new \App\Services\ForecastService($app['db'], $request, $app['user']);
$return = $data->getForecastCalculations();
return new JsonResponse((array)$return, 200, ['access-control-allow-origin' => '*']);
});
$app->mount('/forecast', $forecast);
$app->after($app['cors']);
$app->run();
it is expected that there will be few of them. Therefore, either in one file or include.
if you are going to write a dozen controllers and the same number of models, then take laravel, the same microframework, only everything is better organized and more functions.
(I do not recommend the lumen microframework, there are minimal differences from the full laravel)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question