Created
February 6, 2013 16:11
-
-
Save reinier/4723638 to your computer and use it in GitHub Desktop.
Things to get controllers in a class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"silex/silex": "1.0.*@dev" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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!'; | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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