-
-
Save bobdenotter/4723879 to your computer and use it in GitHub Desktop.
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 Silex; | |
use Silex\ControllerProviderInterface; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
class Bar implements ControllerProviderInterface | |
{ | |
public function connect(Silex\Application $app) | |
{ | |
$ctr = $app['controllers_factory']; | |
$ctr->match("/test", array($this, 'dothis')); | |
$ctr->match('/hello/{name}', array($this, 'hello')); | |
return $ctr; | |
} | |
public function dothis(Request $request, Silex\Application $app) | |
{ | |
return 'Het werkt, naam is ' . $app['naam']; | |
} | |
public function hello(Silex\Application $app, $name) { | |
return 'Hello '.$name.'!'; | |
} | |
} |
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; | |
// Even een 'naam' zetten, om te testen dat in je eigen controllers de $app | |
// nog beschikbaar is: | |
$app['naam'] = "pompidom"; | |
/* | |
ROUTE THINGS | |
*/ | |
$app->get('/', function () use ($app) { | |
return $app->redirect('/hello/Reinier'); | |
}); | |
$app->mount('', new Foo\Bar()); | |
$app->run(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment