re: My PHP Toolkit to Build a (quite) Frameworkless App VIEW POST

VIEW FULL DISCUSSION
 

Good list. I use Slim in one project but what is the strategy you follow with a medium app? any link to explain controllers in Slim maybe

 

I'm used to build small to medium apps with something like 50kLoC.
I have no specific strategy so I usually end up with big routes files.
As you may know, Slim routes take a closure to handle the request and give the response:

$app = new \Slim\App();
$app->any('/books/[{id}]', function ($request, $response, $args) {
    // do the stuff here
});

Instead of having a big routes file, we have the possibility to define a controller class and to pass it to the \Slim\App:

$app = new \Slim\App();
$app->any('/books', BookController::class);

I never tried that but it's well described in the official doc.

 

I'am in the same way. I use group + multiple files for organize a litte the mess. :)

 

You could install a DI container and do something like this

 $app->get('/books', 'BookController@getBooks');
code of conduct - report abuse