PHP code example of codexsoft / route-collection-filter
1. Go to this page and download the library: Download codexsoft/route-collection-filter 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/ */
codexsoft / route-collection-filter example snippets
use CodexSoft\RouteCollectionFilter\RouteCollectionFilter;
use CodexSoft\RouteCollectionFilter\RouteFilter;
use Psr\Log\NullLogger;
$routes = new \Symfony\Component\Routing\RouteCollection();
$filtered = (new RouteCollectionFilter(new NullLogger()))->apply($routes, [
(new RouteFilter())
->setAllowedMethods(['POST'])
->setAllowedHosts(['api.localhost',])
->setControllerClassInterfacesWhitelist([SomeInterface::class,])
->setControllerClassNamespacesWhitelist(['Some\Namespace',])
->setAllowedPathPrefixes(['/v1/','/v2/',]),
(new RouteFilter())
->setAllowedMethods(['GET'])
->setAllowedHosts(['api.localhost',])
->setControllerClassInterfacesWhitelist([OtherInterface::class, ThirdInterface::class])
->setControllerClassNamespacesWhitelist(['Other\Namespace',]),
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.