Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Upgrade to programmatic pipeline and the new error handler #119

Merged
merged 25 commits into from
Jan 9, 2017
Merged

Upgrade to programmatic pipeline and the new error handler #119

merged 25 commits into from
Jan 9, 2017

Conversation

geerteltink
Copy link
Member

@geerteltink geerteltink commented Nov 20, 2016

This PR adds support for zendframework/zend-expressive#396.

  • Convert to the programmatic pipeline
  • Enable new error handler
  • Update header license
  • Update link to docs
  • Remove routes from config/routes.php for minimal install
  • Remove PHP 5.5 support
  • Update to PHPUnit 5.6
  • Update tests
  • Enable Whoops 2 error handler

TODO after zend-expressive 1.1 is released:

  • Remove 1.1.x-dev branch from zend-expressive version in composer.json

@geerteltink geerteltink added this to the 1.1.0 milestone Nov 20, 2016
@geerteltink
Copy link
Member Author

@weierophinney I've started with updating the skeleton to zend-expressive 1.3 and programmatic configuration, It seems to work.

@geerteltink geerteltink removed the WIP label Dec 9, 2016
Copy link
Member

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! A few minor changes requested, mainly around importing classes and/or namespaces into some of the generated files to make them more readable. The bigger question I have is around what prompted the removal of the lowest/locked/latest testing strategy.

- DEPS=latest
- php: 5.6
env:
- DEPS=lowest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's prompting removal of the lowest/latest/locked strategy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly there are dependency issues when the composer.lock file is committed. Or at least there were warnings. That explains the missing locked strategy.

I even have my doubts if "lowest" is useful. When creating a new project always the latest versions are installed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that I've removed the "lowest". I'll revert that one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also do we need hhvm builds? They fail anyway.

@@ -79,7 +79,7 @@ scripts** with `--no-scripts`, otherwise it will remove the installer and all
tests.

```bash
$ composer install --no-scripts
$ composer update --no-scripts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why update and not install? Don't we want developers to use the same set of deps we've tested against?

Copy link
Member Author

@geerteltink geerteltink Dec 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is no composer.lock file it doesn't really matter if install or update is used. Just in case there is a leftover composer.lock file for whatever reason, I prefer update so it does the same in all situations.

EDIT: Thinking about this, we definitely want update so the local composer.lock is ignored and always the latest dependencies are used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"roave/security-advisories": "dev-master",
"zendframework/zend-expressive": "^1.0",
"zendframework/zend-expressive": "^1.1.x-dev || ^1.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 1.1.x-dev constrating should probably read ^1.1.x-dev@dev. Additionally, since || returns the first that matches, switch the order of the two to ensure the stable release is selected once available.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH!!! I've got Travis powers :D

PHP 7 build was still failing. After removing the cache and restarting the build it was successful.

Zend\Expressive\Container\ErrorResponseGeneratorFactory::class,

Zend\Expressive\Middleware\NotFoundHandler::class =>
Zend\Expressive\Container\NotFoundHandlerFactory::class,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's import these classes, or, at the least, the Middleware and Container subnamespaces; that'll make these shorter and more readable.

// The handlers in each middleware attached this way will see a URI with that PATH SEGMENT STRIPPED !!!
// - $app->pipe('/api', $apiMiddleware);
// - $app->pipe('/docs', $apiDocMiddleware);
// - $app->pipe('/files', $filesMiddleware);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit should be above the pipeRoutingMiddleware() call, as segregated middleware will usually have its own routing.

}

if (!$this->template) {
return new JsonResponse([
'welcome' => 'Congratulations! You have installed the zend-expressive skeleton application.',
'docsUrl' => 'zend-expressive.readthedocs.org',
'docsUrl' => 'https://docs.zendframework.com/zend-expressive/',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch on all of these documentation links!

// 'middleware' => App\Action\HomePageAction::class,
// 'allowed_methods' => ['GET'],
// ],
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the changes in the various router configuration files interesting, as I noticed earlier when drafting the information on how to handle module-specific routing that the routes do not change between implementations unless there are dynamic segments in play. None of the default routes have those! (In other words: nice work!)

* $app->post('path', MiddlewareAction::class, 'route.name');
* $app->put('path', MiddlewareAction::class, 'route.name');
* $app->patch('path', MiddlewareAction::class, 'route.name');
* $app->delete('path', MiddlewareAction::class, 'route.name');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd likely give some concrete examples here, instead of using the same path, class, and name for each, to make it more clear that each middleware handles a specific HTTP method/path combination.

@@ -15,7 +15,7 @@
<div class="row">
<div class="col-md-4">
<h2>
<a href="https://zendframework.github.io/zend-expressive/getting-started/features/" target="_blank">
<a href="https://docs.zendframework.com/zend-expressive/getting-started/features/" target="_blank">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing these documentation URIs!

@@ -78,7 +79,7 @@ public function testRouter(
$expectedRouter,
$config['dependencies']['invokables'][Router\RouterInterface::class]
);
$this->assertEquals($expectedRoutes, $config['routes']);
//$this->assertEquals($expectedRoutes, $config['routes']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out, instead of removed outright?

"since || returns the first that matches, switch the order of the two to ensure the stable release is selected once available" - @weierophinney
Without the `--no-scripts` flag the installer starts and it removes itself and there is nothing left to contribute to.
At least version 2.3.1 is required for `Generic.Arrays.DisallowLongArraySyntax`.
@geerteltink geerteltink self-assigned this Dec 13, 2016
@weierophinney weierophinney merged commit df7d997 into zendframework:develop Jan 9, 2017
weierophinney added a commit that referenced this pull request Jan 9, 2017
Upgrade to programmatic pipeline and the new error handler
weierophinney added a commit that referenced this pull request Jan 9, 2017
@weierophinney
Copy link
Member

Thanks, @xtreamwayz!

@geerteltink geerteltink deleted the feature/programmatic branch January 10, 2017 17:59
@weierophinney weierophinney modified the milestones: 1.1.0, 2.0.0 Jan 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants