michaelbiberich/turbolinks-location-middleware

遵守PSR-15规范的MiddlewareInterface实现,将Turbolinks-Location头插入每个响应中

1.0.0 2020-08-09 13:56 UTC

This package is auto-updated.

Last update: 2024-09-09 22:38:44 UTC


README

standard-readme compliant PDS Skeleton Latest version on Packagist

遵守PSR-15规范的MiddlewareInterface实现,将Turbolinks-Location头插入每个响应中

查看Turbolinks关于跟随重定向的文档

灵感来源于code-orange/turbolinks-location

目录

安装

使用composerturbolinks-location-middleware作为依赖项添加到您的项目中。

composer require michaelbiberich/turbolinks-location-middleware ^1 

测试

可以使用PHPUnit运行测试,请参阅phpunit.xml.dist

phpunit --configuration ./phpunit.xml.dist

还可以报告代码覆盖率,例如,使用PHPDBG

phpdbg -qrr ./vendor/bin/phpunit --coverage-text

Composer脚本是针对这两个任务的。

composer test
composer coverage

可以使用官方的composer Docker镜像快速运行这些任务而无需安装composer。

例如 docker run --rm --interactive --tty --volume $PWD:/app composer coverage

用法

创建一个新的TurbolinksLocationMiddleware实例并将其添加到您的分发器/路由处理器/管道

<?php

require_once __DIR__ . '/../vendor/autoload.php';

use MichaelBiberich\TurbolinksLocationMiddleware\TurbolinksLocationMiddleware;

$turbolinksLocation = new TurbolinksLocationMiddleware;

// ---
// Example: Slim 4 application middleware
// see: https://slim.php.ac.cn/docs/v4/concepts/middleware.html
// ---

use Slim\Factory\AppFactory;

$app = AppFactory::create();

// ...

$app->add($turbolinksLocation);

// ---
// Example: Mezzio middleware pipe
// see: https://docs.laminas.dev/laminas-stratigility/v3/middleware/
// ---

use Laminas\Stratigility\MiddlewarePipe;
use function Laminas\Stratigility\middleware;

$app = new MiddlewarePipe();

// ...

$app->pipe(middleware($turbolinksLocation));

贡献

请随意深入了解!创建一个问题或提交PR。

许可证

BSD-3-Clause © Michael Biberich