PHP code example of jnvsor / composite-matcher

1. Go to this page and download the library: Download jnvsor/composite-matcher library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jnvsor / composite-matcher example snippets




use Silex\Provider\Routing\RedirectableUrlMatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Matcher\RequestMatcherInterface;

stMatcher($app['request_context']);
    $ret->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?';
            },
        ];
    }
}