Slim Framework 101

Hi there, folks!

My name is Revzan. I am new with Slim. I have couple of questions and i’ll be glad for good answers you gave.

  • I am currently working on a GOOD directory structure for my application. Any rules maybe?
  • I am going to use view template for slim and wil be mixed with angular.js. will it be okay?
  • the last one. i really need to know how slim does the subviews


  1. I have settled on this directory structure and am very happy with it:


  2. I’ve never used Angular but I see no reason why this should cause problems

  3. Not quite sure what you mean by “subviews”

Hope this helps.


Thanks man! This is inspiring.

  1. templating, i guess. like extending the other views, calling content, etc.

Here’s a sample call to return a rendered Twig template from your controller:

return $this->view->render ($response, 'myTemplate.twig', 
                            ['param1'=>$value1, 'param2'=>value2]);

The Controller constructor looks like this:

public function __construct (\Interop\Container\ContainerInterface $container)
    $this->auth          = $container->get ('auth');
    $this->flashMessages = $container->get ('flash');
    $this->hash          = $container->get ('hash');
    $this->logger        = $container->get ('logger');
    $this->router        = $container->get ('router');
    $this->settings      = $container->get ('settings');
    $this->session       = $container->get ('session');
    $this->view          = $container->get ('view');

    $this->jsonRender  = new JsonRenderer();
    $this->jsonRequest = new JsonRequest();

Hope this helps.

1 Like