bitExpert / prophiler-psr7-middleware

[DEPRECATED] Prophiler PSR7 Middleware
Apache License 2.0
7 stars 8 forks source link

Does not install on PHP7 #17

Closed belgattitude closed 7 years ago

belgattitude commented 7 years ago

Could not install with PHP7.1.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - fabfuel/prophiler 1.5.0 requires php ~5.4 -> your PHP version (7.1.5) does not satisfy that requirement.
    - fabfuel/prophiler 1.4.0 requires php ~5.4 -> your PHP version (7.1.5) does not satisfy that requirement.
    - bitexpert/prophiler-psr7-middleware v0.4.0 requires fabfuel/prophiler ^1.4|dev-feature/php7 -> satisfiable by fabfuel/prophiler[1.4.0, 1.5.0].
    - Installation request for bitexpert/prophiler-psr7-middleware ^0.4.0 -> satisfiable by bitexpert/prophiler-psr7-middleware[v0.4.0].
belgattitude commented 7 years ago

I could make it work with

$ composer require --dev fabfuel/prophiler:dev-feature/php7 bitexpert/prophiler-psr7-middleware

I might have missed in the doc ? But can be usefull to write it.

shochdoerfer commented 7 years ago

Thanks for pointing out. In the composer.json we require "fabfuel/prophiler": "^1.4|dev-feature/php7" which I thought would fix the problem. Maybe we should release a new version and specifically target PHP 7.1. Will think about it.

belgattitude commented 7 years ago

Would be great ;)

Note that I couldn't make it work under zend-expressive 2.0 with 'programmatic pipelines'... At least from the provided doc, as a solution you can see: https://github.com/zendframework/zend-expressive-skeleton/issues/157

shochdoerfer commented 7 years ago

Sorry but I haven't really followed the expressive development. Can you elaborate a bit what changed and what needs to be changed in the middleware to make it work again? Mind providing a PR?

Ideally we could then release a version that is compatible with expressive 2.0 and another release which is only compatible with PHP 7.1.

belgattitude commented 7 years ago

@shochdoerfer,

expressive 2.0 have introduced the 'programmatic pipelines' (became default) in addition to the existing module based configuration.

In other words, you probably need to update your blog post:

This part is valid for module based config:

At first I had to register a pre_routing middleware in config/autoload/middleware-pipeline.local.php:

return [
   'middleware_pipeline' => [[
       'middleware' => bitExpert\Http\Middleware\Psr7\
           Prophiler\ProphilerMiddleware::class,
       'priority' => 11000,
   ]]
];

But with programmatic pipelines, it must be defined in a file (just like for slim I guess)

Adding them in the config/pipeline.php file:

$app->pipe(ErrorHandler::class);
//... just after the ErrorHandler::class (must be the first one)

$debug = $app->getContainer()->get('config')['debug'] ?? false;
if ($debug) {
   /* example with prophilermiddleware */
   $prophiler  = new \Fabfuel\Prophiler\Profiler();
   $toolbar    = new \Fabfuel\Prophiler\Toolbar($prophiler);
   $middleware = new \bitExpert\Http\Middleware\Psr7\Prophiler\ProphilerMiddleware($toolbar);
   $app->pipe($middleware);
}

$app->pipe(ServerUrlMiddleware::class);
//... the rest of the pipeline

Actually there's no issue with your code... It's more about documentation to cover the two alternatives install on expressive.

belgattitude commented 7 years ago

@shochdoerfer, look at the P/R, if it works with php5 it might be a solution for now (no breaking changes needed). If aliased the dep to 2.0:

"fabfuel/prophiler": "^1.4|dev-feature/php7 as 2.0",

So the dev-feature/php7 will have precedence over 1.4

belgattitude commented 7 years ago

I need more time to test, because for now, looks the request collector does not give anything under expressive 2.0.

belgattitude commented 7 years ago

@shochdoerfer should work now, please have a look at the P/R #18 for infos.

shochdoerfer commented 7 years ago

Does it make sense to include a default config/pipeline.php in this package? Is that the way it is supposed to work?

belgattitude commented 7 years ago

No, when people use programmatic pipelines, they're suppose to code the pipeline. See https://github.com/zendframework/zend-expressive-skeleton/blob/master/config/pipeline.php

So documenting is enough.

shochdoerfer commented 7 years ago

@belgattitude mind checking the updated docs please? Thanks. See this PR.

shochdoerfer commented 7 years ago

Where you able to fix the problem with the request collector?

belgattitude commented 7 years ago

Hey @shochdoerfer ,

haven't had the time yet... But I guess this week-end will be possible or Monday.

shochdoerfer commented 7 years ago

Fixed with #18