Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use router specific configuration #34

Merged
merged 2 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App/src/Handler/HomePageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface

if ($this->router instanceof Router\AuraRouter) {
$data['routerName'] = 'Aura.Router';
$data['routerDocs'] = 'http://auraphp.com/packages/2.x/Router.html';
$data['routerDocs'] = 'http://auraphp.com/packages/3.x/Router/';
} elseif ($this->router instanceof Router\FastRouteRouter) {
$data['routerName'] = 'FastRoute';
$data['routerDocs'] = 'https://github.com/nikic/FastRoute';
Expand Down
42 changes: 42 additions & 0 deletions src/MezzioInstaller/Resources/config/routes-aura-router-full.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

use Mezzio\Application;
use Mezzio\MiddlewareFactory;
use Psr\Container\ContainerInterface;

/**
* Aura.Router route configuration
*
* @see http://auraphp.com/packages/3.x/Router/defining-routes.html#2-4-2
*
* Setup routes with a single request method:
*
* $app->get('/', App\Handler\HomePageHandler::class, 'home');
* $app->post('/album', App\Handler\AlbumCreateHandler::class, 'album.create');
* $app->put('/album/{id}', App\Handler\AlbumUpdateHandler::class, 'album.put');
* $app->patch('/album/{id}', App\Handler\AlbumUpdateHandler::class, 'album.patch');
* $app->delete('/album/{id}', App\Handler\AlbumDeleteHandler::class, 'album.delete');
*
* Or with multiple request methods:
*
* $app->route('/contact', App\Handler\ContactHandler::class, ['GET', 'POST', ...], 'contact');
*
* Or handling all request methods:
*
* $app->route('/contact', App\Handler\ContactHandler::class)->setName('contact');
*
* or:
*
* $app->route(
* '/contact',
* App\Handler\ContactHandler::class,
* Mezzio\Router\Route::HTTP_METHOD_ANY,
* 'contact'
* );
*/
return static function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
$app->get('/', App\Handler\HomePageHandler::class, 'home');
$app->get('/api/ping', App\Handler\PingHandler::class, 'api.ping');
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use Mezzio\Application;
use Mezzio\MiddlewareFactory;
use Psr\Container\ContainerInterface;

/**
* Aura.Router route configuration
*
* @see http://auraphp.com/packages/3.x/Router/defining-routes.html#2-4-2
*
* Setup routes with a single request method:
*
* $app->get('/', App\Handler\HomePageHandler::class, 'home');
* $app->post('/album', App\Handler\AlbumCreateHandler::class, 'album.create');
* $app->put('/album/{id}', App\Handler\AlbumUpdateHandler::class, 'album.put');
* $app->patch('/album/{id}', App\Handler\AlbumUpdateHandler::class, 'album.patch');
* $app->delete('/album/{id}', App\Handler\AlbumDeleteHandler::class, 'album.delete');
*
* Or with multiple request methods:
*
* $app->route('/contact', App\Handler\ContactHandler::class, ['GET', 'POST', ...], 'contact');
*/
return static function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
};
42 changes: 42 additions & 0 deletions src/MezzioInstaller/Resources/config/routes-fastroute-full.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

use Mezzio\Application;
use Mezzio\MiddlewareFactory;
use Psr\Container\ContainerInterface;

/**
* FastRoute route configuration
*
* @see https://github.com/nikic/FastRoute
*
* Setup routes with a single request method:
*
* $app->get('/', App\Handler\HomePageHandler::class, 'home');
* $app->post('/album', App\Handler\AlbumCreateHandler::class, 'album.create');
* $app->put('/album/{id:\d+}', App\Handler\AlbumUpdateHandler::class, 'album.put');
* $app->patch('/album/{id:\d+}', App\Handler\AlbumUpdateHandler::class, 'album.patch');
* $app->delete('/album/{id:\d+}', App\Handler\AlbumDeleteHandler::class, 'album.delete');
*
* Or with multiple request methods:
*
* $app->route('/contact', App\Handler\ContactHandler::class, ['GET', 'POST', ...], 'contact');
*
* Or handling all request methods:
*
* $app->route('/contact', App\Handler\ContactHandler::class)->setName('contact');
*
* or:
*
* $app->route(
* '/contact',
* App\Handler\ContactHandler::class,
* Mezzio\Router\Route::HTTP_METHOD_ANY,
* 'contact'
* );
*/
return static function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
$app->get('/', App\Handler\HomePageHandler::class, 'home');
$app->get('/api/ping', App\Handler\PingHandler::class, 'api.ping');
};
27 changes: 27 additions & 0 deletions src/MezzioInstaller/Resources/config/routes-fastroute-minimal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use Mezzio\Application;
use Mezzio\MiddlewareFactory;
use Psr\Container\ContainerInterface;

/**
* FastRoute route configuration
*
* @see https://github.com/nikic/FastRoute
*
* Setup routes with a single request method:
*
* $app->get('/', App\Handler\HomePageHandler::class, 'home');
* $app->post('/album', App\Handler\AlbumCreateHandler::class, 'album.create');
* $app->put('/album/{id:\d+}', App\Handler\AlbumUpdateHandler::class, 'album.put');
* $app->patch('/album/{id:\d+}', App\Handler\AlbumUpdateHandler::class, 'album.patch');
* $app->delete('/album/{id:\d+}', App\Handler\AlbumDeleteHandler::class, 'album.delete');
*
* Or with multiple request methods:
*
* $app->route('/contact', App\Handler\ContactHandler::class, ['GET', 'POST', ...], 'contact');
*/
return static function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
use Psr\Container\ContainerInterface;

/**
* laminas-router route configuration
*
* @see https://docs.laminas.dev/laminas-router/
*
* Setup routes with a single request method:
*
* $app->get('/', App\Handler\HomePageHandler::class, 'home');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
use Psr\Container\ContainerInterface;

/**
* laminas-router route configuration
*
* @see https://docs.laminas.dev/laminas-router/
*
* Setup routes with a single request method:
*
* $app->get('/', App\Handler\HomePageHandler::class, 'home');
Expand Down
18 changes: 9 additions & 9 deletions src/MezzioInstaller/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@
'mezzio/mezzio-aurarouter',
],
'flat' => [
'Resources/config/routes-full.php' => 'config/routes.php',
'Resources/config/routes-aura-router-full.php' => 'config/routes.php',
],
'modular' => [
'Resources/config/routes-full.php' => 'config/routes.php',
'Resources/config/routes-aura-router-full.php' => 'config/routes.php',
],
'minimal' => [
'Resources/config/routes-minimal.php' => 'config/routes.php',
'Resources/config/routes-aura-router-minimal.php' => 'config/routes.php',
],
],
2 => [
Expand All @@ -229,13 +229,13 @@
'mezzio/mezzio-fastroute',
],
'flat' => [
'Resources/config/routes-full.php' => 'config/routes.php',
'Resources/config/routes-fastroute-full.php' => 'config/routes.php',
],
'modular' => [
'Resources/config/routes-full.php' => 'config/routes.php',
'Resources/config/routes-fastroute-full.php' => 'config/routes.php',
],
'minimal' => [
'Resources/config/routes-minimal.php' => 'config/routes.php',
'Resources/config/routes-fastroute-minimal.php' => 'config/routes.php',
],
],
3 => [
Expand All @@ -244,13 +244,13 @@
'mezzio/mezzio-laminasrouter',
],
'flat' => [
'Resources/config/routes-full.php' => 'config/routes.php',
'Resources/config/routes-laminas-router-full.php' => 'config/routes.php',
],
'modular' => [
'Resources/config/routes-full.php' => 'config/routes.php',
'Resources/config/routes-laminas-router-full.php' => 'config/routes.php',
],
'minimal' => [
'Resources/config/routes-minimal.php' => 'config/routes.php',
'Resources/config/routes-laminas-router-minimal.php' => 'config/routes.php',
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion test/MezzioInstallerTest/HomePageResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class HomePageResponseTest extends OptionalPackagesTestCase
private $expectedRouterAttributes = [
AuraRouter::class => [
'routerName' => 'Aura.Router',
'routerDocs' => 'http://auraphp.com/packages/2.x/Router.html',
'routerDocs' => 'http://auraphp.com/packages/3.x/Router/',
],
FastRouteRouter::class => [
'routerName' => 'FastRoute',
Expand Down