Return to homepage

Comments

Steve

In lesson "21. Using the container in controllers" you use \Interop\Container\ContainerInterface in the TopicController constructor. I'm just curious why this is used instead of \Slim\Container?

  • 0
Christian

I'm working on a (very lightweight) CMS on Slim 3. I’m struggling with the routing. Maybe someone here can nudge me in the right direction.

The admin is able to add new frontend pages in the backend. If added a page creates (automatically) a slug. There are a couple of pages (like the index page) that can't be deleted or edited (change the slug)

Now I have no idea how to set up the routing.

Example of what I want: www.example.com/ www.example.com/contact.html www.example.com/some-page.html

I was able to set up a wildcard route but, to make things more interesting, I have some routes for the backend, too:

www.example.com/backend/ www.example.com/backend/dashboard/

etc. as soon as I implement those too I get en error "Static route "/backend/dashboard.html" is shadowed by previously defined variable route "/(.*)" for method "GET""

My routes so far: $app->get('/[{path:.*}]', function($request, $response, $path = null) { return $response->write($path ? 'subroute' : 'index'); });

1$app->group('', function () {
2 $this->get('/backend/dashboard.html', 'BackendDashboardController:index')->setName('backend');
3});

Every hint would be much appreciated.

  • 0
Christian

Here's the solution, if anyone is wondering: https://stackoverflow.com/questions/55856143/cms-like-wildcard-routing-with-slim-3

  • 0
Martin

Thanks Alex, this is the best Slim framework series I could see. You taught me to better use this framework. And thanks to that I learned to create smaller web applications more effectively.

  • 0
Noel

Nice serie ! I wanted to make a very small little break with Laravel, and discover slim because the CRM I use is written with it. And now everything is more clear ! I will certainly need more practice and maybe to rewatch some episods, but for sure I will use it slowly for small apps, as it looks simple and solid. So once again, thanks for sharing your knowledge with us, I'm learning a lot with you !

  • 0
Chris

I'm using Plates PHP Template engine instead of Twig. Can you tell me what exactly the forPath() extension in returning in the template? Is it '/contact' or is it the entire path? I just want to make sure than the Plates URI extension is returning the same path info. Also, what does it accomplish, since the code seems to work without an action even being specified? Sorry, just seeking a bit of clarification.

  • 0