Skip to content

Trailing slash control

sunrise-php edited this page Jan 7, 2019 · 2 revisions

Install middleware

Learn more about the middleware

composer require middlewares/trailing-slash

Using

Path of a route should be as:

/**
 * @Route(
 *   id="test",
 *   path="/test(/)",
 *   methods={"GET"}
 * )
 */
class TestController implements MiddlewareInterface
{
    // some code
}

Open the public/index.php and add to the file the following code before running the application:

$container->get(Sunrise\Http\Router\RouterInterface::class)
->addMiddleware((new Middlewares\TrailingSlash(false))->redirect());