<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jerowork / slim-route-attribute-provider example snippets
use Jerowork\RouteAttributeProvider\RouteAttributeConfigurator;
use Jerowork\RouteAttributeProvider\Slim\SlimRouteAttributeProvider;
use Slim\Factory\AppFactory;
// Setup a (fictive) PSR-11 container and create Slim application
$container = new Container();
$app = AppFactory::createFromContainer($container);
// ...
// Setup route attribute configuration
$routeConfigurator = new RouteAttributeConfigurator(
SlimRouteAttributeProvider::createFromApp($app)
);
$routeConfigurator
->addDirectory(sprintf('%s/src/Infrastructure/Api/Http/Action', __DIR__))
->configure();
// ...
// Run Slim application
$app->run();
use Jerowork\FileClassReflector\FileFinder\RegexIterator\RegexIteratorFileFinder;
use Jerowork\FileClassReflector\NikicParser\NikicParserClassReflectorFactory;
use Jerowork\RouteAttributeProvider\RouteAttributeConfigurator;
use Jerowork\RouteAttributeProvider\Slim\SlimRouteAttributeProvider;
use PhpParser\NodeTraverser;
use PhpParser\ParserFactory;
// ...
// All parts of the configurator can be replaced with a custom implementation
$routeConfigurator = new RouteAttributeConfigurator(
new SlimRouteAttributeProvider(
$app->getRouteCollector(),
$container
),
new ClassReflectorRouteLoader(
new NikicParserClassReflectorFactory(
new RegexIteratorFileFinder(),
(new ParserFactory())->create(ParserFactory::PREFER_PHP7),
new NodeTraverser()
)
)
);
// Multiple directories can be defined
$routeConfigurator
->addDirectory(
sprintf('%s/src/Infrastructure/Api/Http/Action', __DIR__),
sprintf('%s/src/Other/Controller', __DIR__)
)
->configure();
// ...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.