Skip to content

Migrate to mezzio, drop php 7.1 support #34

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

Merged
merged 1 commit into from
May 12, 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
composer.lock
infection.log
infection.log
.phpunit.result.cache
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ cache:
language: php

php:
- 7.1
- 7.2
- 7.3
- 7.4
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You don't need to copy any static assets from phpdebugbar vendor!

Sometimes you want to have control when enable or disable PHP Debug Bar:
* custom content negotiation,
* allow to debug redirects responses.
* allow debug redirects responses.

We allow you to disable attaching phpdebugbar using `X-Enable-Debug-Bar: false` header, cookie or request attribute.
To force enable just send request with `X-Enable-Debug-Bar` header, cookie or request attribute with `true` value.
Expand All @@ -42,22 +42,22 @@ This package isn't require any PSR-7 implementation - you need to provide it by

#### ... and PSR-11

If you use provided PSR-11 factories, then you container must have services registered as PSR-17 interface's name. Example for [zend-diactoros](https://github.com/zendframework/zend-diactoros) implementation and [Pimple](https://pimple.symfony.com/):
If you use provided PSR-11 factories, then your container must have services registered as PSR-17 interface's name. Example for [laminas-diactoros](https://github.com/laminas/laminas-diactoros) implementation and [Pimple](https://pimple.symfony.com/):

```php
$container[Psr\Http\Message\ResponseInterface::class] = new Zend\Diactoros\ResponseFactory();
$container[Psr\Http\Message\StreamFactoryInterface] = new Zend\Diactoros\StreamFactory();
$container[Psr\Http\Message\ResponseInterface::class] = new Laminas\Diactoros\ResponseFactory();
$container[Psr\Http\Message\StreamFactoryInterface::class] = new Laminas\Diactoros\StreamFactory();
```

### How to install on Zend Expressive?
### How to install on Mezzio?

You need to register `PhpMiddleware\PhpDebugBar\ConfigProvider` and pipe provided middleware:

```php
$app->pipe(\PhpMiddleware\PhpDebugBar\PhpDebugBarMiddleware::class);
```

For more - follow Zend Expressive [documentation](https://docs.zendframework.com/zend-expressive/v3/features/modular-applications/).
For more - follow Mezzio [documentation](https://docs.mezzio.dev/mezzio/v3/features/modular-applications/).

### How to install on Slim 3?

Expand All @@ -79,7 +79,7 @@ $app->add(

### How to configure using existing factories?

Put array with configuration into `PhpMiddleware\PhpDebugBar\ConfigProvider` service in your container:
Put array with a configuration into `PhpMiddleware\PhpDebugBar\ConfigProvider` service in your container:

```php
return [
Expand All @@ -106,7 +106,7 @@ return array_merge(PhpMiddleware\PhpDebugBar\ConfigProvider::getConfig(), $myOve
## It's just works with any modern php framework!

Middleware tested on:
* [Zend Expressive](https://github.com/zendframework/zend-expressive)
* [Mezzio](https://github.com/mezzio/mezzio)
* [Slim 3.x](https://github.com/slimphp/Slim)

And any other modern framework [supported PSR-17 middlewares and PSR-7](https://mwop.net/blog/2015-01-08-on-http-middleware-and-psr-7.html).
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"psr-11"
],
"require": {
"php": "^7.1",
"php": "^7.2",
"maximebf/debugbar": "^1.4",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
Expand All @@ -22,13 +22,13 @@
"psr/http-factory-implementation": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5.20",
"phpunit/phpunit": "^8.5.4 || ^9.1.4",
"mikey179/vfsStream": "^1.6.8",
"slim/slim": "^3.0",
"zendframework/zend-expressive": "^3.0",
"zendframework/zend-expressive-fastroute": "^3.0.1",
"zendframework/zend-servicemanager": "^3.3.2",
"zendframework/zend-diactoros": "^2.0",
"mezzio/mezzio": "^3.0",
"mezzio/mezzio-fastroute": "^3.0.1",
"laminas/laminas-servicemanager": "^3.3.2",
"laminas/laminas-diactoros": "^2.0",
"infection/infection": "^0.13.3"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __invoke(): array
{
$config = include __DIR__ . '/../config/phpdebugbar.config.php';
$config['dependencies'] = include __DIR__ . '/../config/dependency.config.php';
$config['middleware_pipeline'] = include __DIR__ . '/../config/zend-expressive.middleware_pipeline.config.php';
$config['middleware_pipeline'] = include __DIR__ . '/../config/mezzio.middleware_pipeline.config.php';

return $config;
}
Expand Down
10 changes: 5 additions & 5 deletions test/AbstractMiddlewareRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response;
use Laminas\Diactoros\Response;

abstract class AbstractMiddlewareRunnerTest extends TestCase
{
Expand All @@ -27,9 +27,9 @@ final public function testAppendJsIntoHtmlContent(): void

$responseBody = (string) $response->getBody();

$this->assertContains('var phpdebugbar = new PhpDebugBar.DebugBar();', $responseBody);
$this->assertContains('Hello!', $responseBody);
$this->assertContains('"/phpdebugbar/debugbar.js"', $responseBody);
$this->assertStringContainsString('var phpdebugbar = new PhpDebugBar.DebugBar();', $responseBody);
$this->assertStringContainsString('Hello!', $responseBody);
$this->assertStringContainsString('"/phpdebugbar/debugbar.js"', $responseBody);
}

final public function testGetStatics(): void
Expand All @@ -53,7 +53,7 @@ final public function testGetStatics(): void

$contentType = $response->getHeaderLine('Content-type');

$this->assertContains('text/javascript', $contentType);
$this->assertStringContainsString('text/javascript', $contentType);
}

abstract protected function dispatchApplication(array $server, array $pipe = []): ResponseInterface;
Expand Down
62 changes: 31 additions & 31 deletions test/ZendExpressiveTest.php → test/MezzioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Zend\Diactoros\Response;
use Zend\Diactoros\ResponseFactory;
use Zend\Diactoros\ServerRequestFactory;
use Zend\Diactoros\StreamFactory;
use Zend\Expressive\Container\ApplicationFactory;
use Zend\Expressive\Container\MiddlewareContainerFactory;
use Zend\Expressive\Container\MiddlewareFactoryFactory;
use Zend\Expressive\Container\RequestHandlerRunnerFactory;
use Zend\Expressive\Container\ResponseFactoryFactory;
use Zend\Expressive\Container\ServerRequestErrorResponseGeneratorFactory;
use Zend\Expressive\MiddlewareContainer;
use Zend\Expressive\MiddlewareFactory;
use Zend\Expressive\Response\ServerRequestErrorResponseGenerator;
use Zend\Expressive\Router\FastRouteRouter;
use Zend\Expressive\Router\FastRouteRouterFactory;
use Zend\Expressive\Router\Middleware\DispatchMiddleware;
use Zend\Expressive\Router\Middleware\DispatchMiddlewareFactory;
use Zend\Expressive\Router\Middleware\RouteMiddleware;
use Zend\Expressive\Router\Middleware\RouteMiddlewareFactory;
use Zend\Expressive\Router\RouteCollector;
use Zend\Expressive\Router\RouteCollectorFactory;
use Zend\Expressive\Router\RouterInterface;
use Zend\HttpHandlerRunner\Emitter\EmitterInterface;
use Zend\HttpHandlerRunner\RequestHandlerRunner;
use Zend\ServiceManager\Factory\InvokableFactory;
use Zend\ServiceManager\ServiceManager;
use Zend\Stratigility\MiddlewarePipe;

final class ZendExpressiveTest extends AbstractMiddlewareRunnerTest
use Laminas\Diactoros\Response;
use Laminas\Diactoros\ResponseFactory;
use Laminas\Diactoros\ServerRequestFactory;
use Laminas\Diactoros\StreamFactory;
use Mezzio\Container\ApplicationFactory;
use Mezzio\Container\MiddlewareContainerFactory;
use Mezzio\Container\MiddlewareFactoryFactory;
use Mezzio\Container\RequestHandlerRunnerFactory;
use Mezzio\Container\ResponseFactoryFactory;
use Mezzio\Container\ServerRequestErrorResponseGeneratorFactory;
use Mezzio\MiddlewareContainer;
use Mezzio\MiddlewareFactory;
use Mezzio\Response\ServerRequestErrorResponseGenerator;
use Mezzio\Router\FastRouteRouter;
use Mezzio\Router\FastRouteRouterFactory;
use Mezzio\Router\Middleware\DispatchMiddleware;
use Mezzio\Router\Middleware\DispatchMiddlewareFactory;
use Mezzio\Router\Middleware\RouteMiddleware;
use Mezzio\Router\Middleware\RouteMiddlewareFactory;
use Mezzio\Router\RouteCollector;
use Mezzio\Router\RouteCollectorFactory;
use Mezzio\Router\RouterInterface;
use Laminas\HttpHandlerRunner\Emitter\EmitterInterface;
use Laminas\HttpHandlerRunner\RequestHandlerRunner;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Stratigility\MiddlewarePipe;

final class MezzioTest extends AbstractMiddlewareRunnerTest
{
final public function testContainsConfigCollectorOutput(): void
{
Expand All @@ -56,7 +56,7 @@ final public function testContainsConfigCollectorOutput(): void

$responseBody = (string) $response->getBody();

$this->assertContains('DebugBar\\\DataCollector\\\ConfigCollector', $responseBody);
$this->assertStringContainsString('DebugBar\\\DataCollector\\\ConfigCollector', $responseBody);
}

protected function dispatchApplication(array $server, array $pipe = []): ResponseInterface
Expand Down Expand Up @@ -105,7 +105,7 @@ private function createContainer(array $server): ContainerInterface
$serviceManagerConfig['factories'][ResponseFactory::class] = InvokableFactory::class;
$serviceManagerConfig['factories'][StreamFactory::class] = InvokableFactory::class;
$serviceManagerConfig['aliases'][RouterInterface::class] = FastRouteRouter::class;
$serviceManagerConfig['aliases'][\Zend\Expressive\ApplicationPipeline::class] = MiddlewarePipe::class;
$serviceManagerConfig['aliases'][\Mezzio\ApplicationPipeline::class] = MiddlewarePipe::class;
$serviceManagerConfig['aliases'][ResponseFactoryInterface::class] = ResponseFactory::class;
$serviceManagerConfig['aliases'][StreamFactoryInterface::class] = StreamFactory::class;

Expand Down
12 changes: 6 additions & 6 deletions test/PhpDebugBarMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
use org\bovigo\vfs\vfsStream;
use PhpMiddleware\PhpDebugBar\PhpDebugBarMiddleware;
use PHPUnit\Framework\TestCase;
use Zend\Diactoros\Response;
use Zend\Diactoros\ResponseFactory;
use Zend\Diactoros\ServerRequest;
use Zend\Diactoros\StreamFactory;
use Zend\Diactoros\Uri;
use Laminas\Diactoros\Response;
use Laminas\Diactoros\ResponseFactory;
use Laminas\Diactoros\ServerRequest;
use Laminas\Diactoros\StreamFactory;
use Laminas\Diactoros\Uri;

/**
* PhpDebugBarMiddlewareTest
Expand All @@ -24,7 +24,7 @@ class PhpDebugBarMiddlewareTest extends TestCase
/** @var PhpDebugBarMiddleware */
protected $middleware;

protected function setUp()
protected function setUp(): void
{
$this->debugbarRenderer = $this->getMockBuilder(JavascriptRenderer::class)->disableOriginalConstructor()->getMock();
$this->debugbarRenderer->method('renderHead')->willReturn('RenderHead');
Expand Down
4 changes: 2 additions & 2 deletions test/Slim3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use Psr\Http\Message\StreamFactoryInterface;
use Slim\App;
use Slim\Http\Environment;
use Zend\Diactoros\ResponseFactory;
use Zend\Diactoros\StreamFactory;
use Laminas\Diactoros\ResponseFactory;
use Laminas\Diactoros\StreamFactory;

final class Slim3Test extends AbstractMiddlewareRunnerTest
{
Expand Down
2 changes: 1 addition & 1 deletion test/TestEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use BadMethodCallException;
use Psr\Http\Message\ResponseInterface;
use Zend\HttpHandlerRunner\Emitter\EmitterInterface;
use Laminas\HttpHandlerRunner\Emitter\EmitterInterface;

final class TestEmitter implements EmitterInterface
{
Expand Down