Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jnvsor/composite-matcher

A composite matcher that runs RequestMatchers in sequence to find a match
https://github.com/jnvsor/composite-matcher

routing symfony

Last synced: 2 months ago
JSON representation

A composite matcher that runs RequestMatchers in sequence to find a match

Awesome Lists containing this project

README

        

# CompositeMatcher

Provides a "Composite matcher" for `symfony/routing` that takes multiple matchers and runs them in sequence.

Useful for duplicating overly-complex legacy routing systems.

## Example using Silex

```php
addMatcher(new RedirectableUrlMatcher($app['routes'], $app['request_context']));
$ret->addMatcher(new CatchLeftoversMatcher());

return $ret;
};

$app->get('/', function(){
return 'woot?';
});

$app->run();

class CatchLeftoversMatcher implements RequestMatcherInterface {
public function matchRequest(Request $r) {
if ($r->getPathInfo() != '/test/') {
throw new ResourceNotFoundException();
}

return [
'test' => 'test',
'foo' => 'bar',
'_controller' => function(){
return 'waat?';
},
];
}
}
```

## Requirements

Should work down to 5.4, but I'm only running CI on 5.6+

Depends on `symfony/http-foundation` and `symfony/routing`