middlewares/lowercase
Composer 安装命令:
composer require middlewares/lowercase
包简介
A lowercase repository for PSR-15 middleware packages
README 文档
README
Middleware to set the uri path to lowercase. For example, /Foo/Bar/ is converted to /foo/bar. Useful if you define your routes as lowercase and want to make your routes case insensitive.
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/lowercase.
composer require middlewares/lowercase
Example
$dispatcher = new Dispatcher([ (new Middlewares\Lowercase()) ->redirect() ->attribute('before-lowercase-uri') ]); $response = $dispatcher->dispatch(new ServerRequest());
Usage
redirect
If the path must be converted to lowercase, this option returns a 301 response redirecting to the new lowercase 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.
$responseFactory = new MyOwnResponseFactory(); //Simply set the path to lowercase $lowercase = new Middlewares\Lowercase(); //Returns a redirect response to the new path $lowercase = (new Middlewares\Lowercase())->redirect(); //Returns a redirect response to the new path using a specific response factory $lowercase = (new Middlewares\Lowercase())->redirect($responseFactory);
attribute
If the path must be converted to lowercase, this method will store the original path in an atrribute.
// Save the original non-lowercase uri in the custom attribute "pre-lowercase-path" $lowercase = (new Middlewares\Lowercase())->attribute('before-lowercase-uri');
Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.
统计信息
- 总下载量: 35.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-08