/**
  * Extracts the Action Name from a request uri
  *
  * @param string $name
  * @return \App\Action\iAction
  */
 private function getActionClass($name)
 {
     //Strip rest of url if not in its own VirtualHost
     $name = substr($name, strrpos($name, 'public'));
     $name = str_replace('public/', '', $name);
     $name = $name == "" || null === $name || $name == "/" ? 'list' : $name;
     if (\substr($name, 0, 1) == '/') {
         $name = \substr($name, 1);
     }
     if (strpos($name, '/') != false) {
         $name = strstr($name, '/', true);
     }
     $name = str_replace('-', ' ', $name);
     $name = ucwords($name);
     $name = str_replace(' ', '', $name);
     $class = 'App\\Action\\' . $name . 'Action';
     if (!class_exists($class)) {
         $action = new \App\Action\ErrorAction();
         $action->setError(new \Exception('Action ' . $name . ' not defined'));
         return $action;
     }
     return new $class();
 }
<?php

// DIC configuration
$container = $app->getContainer();
$container['view'] = function ($c) {
    $path = $c->get('settings')['view'];
    return new \Slim\Views\PhpRenderer($path);
};
$container['notFoundHandler'] = function ($c) {
    return function ($request, $response) use($c) {
        $app = new App\Action\ErrorAction($c);
        return $app->Error404($request, $response);
    };
};
// Action Factories
$container['App\\Action\\BaseAction'] = function ($c) {
    return new App\Action\BaseAction($c);
};