Hey So I'm setting up some classes to keep my Routes out of the eye of my index.php,
index.php
require 'library/Slim/Slim.php';
$app=new Slim();
$app->map('/api/:class/:method(/:args1(/:args2(/:args3)))', function ($class,$method) use ($app) {
$args=array_slice(func_get_args(), 2);
require_once('library/controllers/'.str_replace('.','/',$class).'.php');
$Class=substr($class,strrpos($class,'.'));
$controller=new $Class($app);
if(method_exists($controller,$method)) $controller->{$method}($args);
})->via('GET', 'POST');
$app->run();
And am calling something like this __http://domain.com/api/photos/recent/args/args/args
Test Class Photos
<?php
class photos {
private $app;
public function __contruct() {
$this->app = Slim::getInstance();
}
public function recent() {
$this->app->render('test.html');
}
}
And am just trying to run an instance of Slim to render, but am not getting it for some reason? Test HTML is in the same dir as photos.php
What am I doing wrong? I'm dying with fatal error
PHP Fatal error: Call to a member function render() on a non-object in /library/controllers/photos.php on line 13