Download the PHP package middlewares/trailing-slash without Composer
On this page you can find all versions of the php package middlewares/trailing-slash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download middlewares/trailing-slash
More information about middlewares/trailing-slash
Files in middlewares/trailing-slash
Package trailing-slash
Short Description Middleware to normalize the trailing slash of the uri path
License MIT
Homepage https://github.com/middlewares/trailing-slash
Informations about the package trailing-slash
middlewares/trailing-slash
Middleware to normalize the trailing slash of the uri path. By default removes the slash so, for example, /post/23/
is converted to /post/23
. Useful if you have problems with the router.
Requirements
- PHP >= 7.2
- A PSR-7 http library
- A PSR-15 middleware dispatcher
Installation
This package is installable and autoloadable via Composer as middlewares/trailing-slash.
Example
Usage
By default, this middleware removes the trailing slash of the uri path. Set true
to the constructor's first argument to add instead remove:
Of course, if the path contains an extension, the slash is NOT added. For example, images/image.png
remains the same, instead be converted to images/image.png/
.
redirect
If the path must be converted, this option returns a 301
response redirecting to the new path. Optionally, you can provide a Psr\Http\Message\ResponseFactoryInterface
that will be used to create the redirect response. If it's not defined, Middleware\Utils\Factory will be used to detect it automatically.
Please see CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.
All versions of trailing-slash with dependencies
middlewares/utils Version ^3.0 || ^4.0
psr/http-server-middleware Version ^1.0