Skip to content

Instantly share code, notes, and snippets.

@phpfour
Created January 20, 2012 09:27
Show Gist options
  • Save phpfour/1646386 to your computer and use it in GitHub Desktop.
Save phpfour/1646386 to your computer and use it in GitHub Desktop.
An MVC style use of Slim.
<?php
require 'Slim/Slim.php';
class SlimMvc extends Slim
{
public function __construct($userSettings = array())
{
parent::__construct($userSettings);
$this->init();
}
public function init()
{
$urlParts = explode('/', $this->request()->getResourceUri());
$controller = ucfirst($urlParts[1]) . 'Controller';
include_once "controllers/$controller.php";
new $controller($this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment