Create route/view/controller dynamically using a dashboard with slim PHP

What I can do :

Create a dashboard using eloquant with slim to be able to create for example a gallery with photos. The dashboard will contain all the created galleries, each gallery with a link to the gallery’s page.

Problem :

I can’t figure out how, with slim, I could add a button on the dashboard that will automatically upon submitting the button :

  • Create a route :

$app->get('/gallery1', 'GalleryController:gallery1')->setName('gallery1');

  • Create a view called gallery1.html.twig

  • Update GalleryController.php to add a function to generate that view :

    public function gallery1($request, $response) { return $this->container->view->render($response, 'gallery1.html.twig'); }

I’m new to Slim, sorry.

you could crate a generic:

$app->get(’/gallery/{id}’, ‘GalleryController:gallery’);

in your GalleryController:gallery you can access the id with $args[‘id’], and display the photos belonging to gallery $id.