Skip to content

Instantly share code, notes, and snippets.

@jmather
Created October 26, 2012 20:15
Show Gist options
  • Select an option

  • Save jmather/3961224 to your computer and use it in GitHub Desktop.

Select an option

Save jmather/3961224 to your computer and use it in GitHub Desktop.
How to filter a set of urls by a constraint
<?php
$app = new Silex\Application();
$app->mount('/admin', new MyCode\MyControllerProvider());
<?php
namespace MyCode;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
use Symfony\Component\HttpFoundation\Response;
class MyControllerProvider implements ControllerProviderInterface
{
public function connect(Application $app)
{
// creates a new controller based on the default route
/** @var $controllers ControllerCollection */
$controllers = $app['controllers_factory'];
$controllers->get('/', function (Application $app) {
return 'hello';
}):
$controllers->before(function() { throw new \Exception(); });
return $controllers;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment