I have been looking at various tutorial videos to understand Slim (only just discovered it) and I was liking what I saw. Having downloaded slim-skeleton however I see that it has a much more comprehensive file structure and a routing strategy that I just do not understand. I see the templates index file requires the routes file so that’s OK but the routes file has a method like:
return $this->renderer->render($response, ‘about.php’, $args);
There was no mention of ‘renderer’ in the videos I watched and I have searched the documentation without success. Can you point to some documentation that covers this? Using this approach, how for instance would I open up another website page?
Sorry if impossibly dim but I have to start somewhere.
If you started with a Skeleton, then you started with a package where someone made some decisions about the file structure they wanted and likely added additional components necessary for their example. The renderer
is likely using either the php-view
or twig-view
components, as covered by the Templates section of the documentation (under Add Ons).
Thanks for that. Neither of the templates here appears to use the same code as my download. Maybe I should have downloaded a vanilla version but this skeleton was heavily pushed from the home page as the ‘easiest’ way to start. I don’t think so. I wonder if it is possible to uninstall a plugin package without disabling the main functionality. And first how to discover what add-ons you’ve got…
It might be helpful to know what your experience is with PHP, frameworks, and composer, as well as perhaps your goals. Not necessarily all of those items but with some of that info we can better steer you in the right direction. The skeletons are often the way to best see how Slim can be put together rather than wiring it all yourself. That’s why they are shown as easier ways to get started. If you’d like to build it up yourself you are always welcome to do so, but that will take more work and background knowledge.
In your initial question, since you are within the context of $app
, $this->renderer
refers to the renderer
entry from the container, found here.
Your composer.json
file will list what packages are included/installed with your project. You could certainly remove some of them, but obviously any code that depends on those packages will fail.