by dools · 14y ago · 0 comments
In fact, if you want routes you'd have to build it as a package and in FACT you could just create a class like this:
class RocketHam implements rocketsled\Runnable
{
public function run()
{
$app = new Ham();
$app->config_from_file('settings.php');
$app->route('/pork', function($app) {
return "Delicious pork.";
});
$hello = function($app, $name='world') {
return $app->render('hello.html', array(
'name' => $name
));
};
$app->route('/hello/<string>', $hello);
$app->route('/', $hello);
$app->run();
}
}
then put your ham/ directory in packages with a file rs.config.php: spl_autoload_register(function($class)
{
if($class == 'Ham')
require_once(dirname(__FILE__).'/ham.php');
}
then use .htaccess or something similar to route all requests to:index.php?r=RocketHam
EDITS: oops sorry not used to formatting code on here
The __invoke method means I can use my apps AS closures which is totally sweet.