Skip to content

Instantly share code, notes, and snippets.

@reinier
Created February 6, 2013 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save reinier/4723638 to your computer and use it in GitHub Desktop.
Save reinier/4723638 to your computer and use it in GitHub Desktop.
Things to get controllers in a class
{
"require": {
"silex/silex": "1.0.*@dev"
}
}
<?php
namespace Foo;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Silex\Application;
class Bar
{
public function dothis(Request $request, Application $app)
{
return 'Het werkt!';
}
}
?>
<?php
require_once __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/foobar.php';
$app = new Silex\Application();
$app['debug'] = true;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/*
ROUTE THINGS
*/
$app->get('/', function () use ($app) {
return $app->redirect('/hello/Reinier');
});
$app->get('/hello/{name}', function ($name) use ($app) {
return 'Hello '.$name.'!';
});
$app->get('/test', 'Foo\Bar::dothis');
$app->run();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment