zendframework / zend-expressive

PSR-15 middleware in minutes!
BSD 3-Clause "New" or "Revised" License
711 stars 197 forks source link

http-interop/http-middleware 0.5 #513

Closed danizord closed 6 years ago

danizord commented 7 years ago

Hey! Any plans to upgrade Zend Expressive to http-interop/http-middleware 0.5? :)

weierophinney commented 7 years ago

Yes, though likely as a 3.0.0alpha. Not sure what our time frame is for addressing it; we have a number of other things we need to accomplish first.

firefred commented 7 years ago

expressive composer dependencies: "http-interop/http-middleware": "^0.4.1",

automatically installs 0.5, and this broke expressive

froschdesign commented 7 years ago

@webimpress Can you add a comment here? Thanks!

michalbundyra commented 7 years ago

@firefred Can you provide more information please? In expressive 2.0.5 we requires http-interop/http-middleware in version 0.4.1. What version of Expressive you are using? What is your test case which cause the issue?

We are preparing Expressive 2.1.0 which allows you to update your application to http-interop/http-middleware 0.5.0.

weierophinney commented 7 years ago

@firefred Pinning to ^0.4.1 should never install 0.5.0, for two reasons:

I've just verified the above in two ways:

So: can you provide information on how we might reproduce the issue, please? Were you creating a new project? or updating an existing one? Did you have http-interop/http-middleware required within your project? If so, at what version? If not, what version was installed prior to update? What prompts, if any, did you receive?

We know that versions of webimpress/http-middleware-compatibility prior to 0.1.3 could easily lead to installing http-interop/http-middleware 0.5.0, and thus its 0.1.3 release ensures that the currently installed version is added to your composer.json, instead of prompting you for a version. Expressive itself pins to a specific http-middleware version as of 2.0.5, which should trigger this properly.

Any information you can provide us will help us know if we missed an edge case, or if our recent (as in last 24 hours) approaches will resolve these problems.

firefred commented 7 years ago

@weierophinney Thanks for the full answer.

the first and the main problem was, that i lost my composer.lock file the second was, webimpress/http-middleware-compatibility

- Installing webimpress/http-middleware-compatibility (0.1.3): Loading from cache
Enter the version of http-interop/http-middleware to require (or leave blank to use the latest version):
Using version ^0.5.0 for http-interop/http-middleware

Any way, thanks for such powerful instrument like Expressive! )

weierophinney commented 7 years ago

@firefred I think this is all resolved currently with the 2.0.5 release of zend-expressive, and the 2.0.4 release of the skeleton. Please open a new issue if you still encounter problems. If you do, please include the following information:

Thanks!

batumibiz commented 7 years ago

I want to complain of the applied webimpress/http-middleware-compatibility package The matter is that he pulls for himself dependence of webimpress/composer-extra-dependency which forcibly changes the list of dependences in root composer.json even in spite of the fact that the necessary dependence is already registered in that package where I use zend-expressive I think that such behavior is unacceptable, Without my permission, there should be no change in the root composer. json

weierophinney commented 7 years ago

This is done to ensure there is an explicit dependency on http-middleware. Without it, if you remove your composer.lock file, your application will either be missing that, or potentially install a later version than you currently use, both of which situations will lead to a broken application.

Additionally, having the explicit dependency ensures that you must manually require a later version of the package if you want to upgrade it. This is done to force the developer to think about the consequences of upgrading: has the developer updated cider that uses these interfaces in a way that is forwards compatible?

While I understand your complaint, there are a ton of reasons for following this approach.

On Oct 22, 2017 10:09 AM, "Oleg Kasyanov" notifications@github.com wrote:

I want to complain of the applied webimpress/http-middleware-compatibility package The matter is that he pulls for himself dependence of webimpress/composer-extra-dependency which forcibly changes the list of dependences in root composer.json even in spite of the fact that the necessary dependence is already registered in that package where I use zend-expressive I think that such behavior is unacceptable, no package should without my permission change root dependency list

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zendframework/zend-expressive/issues/513#issuecomment-338484596, or mute the thread https://github.com/notifications/unsubscribe-auth/AABlV7tOp6JIhdAeaPlZ3VDaguds-eC3ks5su1q-gaJpZM4PcsdD .

belgattitude commented 6 years ago

http-middleware is now abandonned (on packagist) and have been splitted into

https://github.com/http-interop/http-server-middleware https://github.com/http-interop/http-server-handler

I think this issue can be closed.

@weierophinney I guess you're aware of this change, do you have any update about the news of PSR-15 ?

weierophinney commented 6 years ago

@belgattitude We're finalizing the packages this week so we can do a vote to enter the review period. If there are no further changes or feedback indicating changes are needed once review is over, we can put it up to an acceptance vote by the core committee.

The review period lasts for 4 weeks, the CC vote for 2 weeks, so, realistically, we're looking at early January at the earliest for it to be final.

We'll likely be providing a way to test against this latest version of the spec and its packages soon, but likely as a v3.0.0-beta or -alpha version.

belgattitude commented 6 years ago

@weierophinney Just wanted to thank you all you efforts and especially the good vibe you give to the project... Don't feel you need to rush for the 3.0.0-alpha version, I'm very confident you'll make everything best as it can. Keep up the good work.

gilbertoalbino commented 6 years ago

I used to be an extensive user of Zend Framework 1, and got quite disappointed with ZF2 being so slow - which made me switch to Laravel for long 3 years... and today I just tried to play with ZF3 installing Expressive and just came around to the same problem of http-interop/http-middleware not being compatible with that!

Well, it's a very common problem of software dependencies... but what scared me was the fact that it is a "PSR" Implementation breaking change!!! What were PSR's supposed to do other than breaking changes? Interoperate? Inter-what?

Can someone effectively guide how to install Zend Expressive alongside this obscure implementation of PS'atan'R's dependency?

@weierophinney I just followed the Getting Started from the docs and run accross this question from composer:

Enter the version of http-interop/http-middleware to require (or leave blank to use the latest version):

If I leave as is PHP says that:

Fatal error: Interface 'Interop\Http\ServerMiddleware\MiddlewareInterface' not found in C:\Users\Zyne\htdocs\zend-expressive\vendor\zendframework\zend-expressive\src\Middleware\RouteMiddleware.php on line 33

How to proceed with the above question - because leaving it blank keeps triggering this error.

What "version" should I use? Don't make me go back to Laravel!!!!

[Edited] I tried ^0.4.1 but it says I should avoid it! Is that the way to go?

michalbundyra commented 6 years ago

@gilbertoalbino Sorry to hear about your issues. PSR-15 it is not yet accepted and it has been changed recently very dynamically. Expressive 2.0 was supporting http-interop/http-middleware in version 0.4.1, then version 0.5.0 has been release. I've prepared compatibility layer (webimpress/http-middleware-compatibility) which allows choose the version of http-interop middleware to use - this is why you've got the question. We released some components whit support of 0.5.0 version, but unfortunately not expressive. It was already merged to develop and almost ready to go live, but in the last moment new version of PSR-15 base has been released - they decided to split the repository into two libraries, and support only PHP 7.0 - and now we have http-interop/http-server-middleware and http-interop/http-server-handler. Since then http-interop/http-middleware is abandoned. Because of that we decided to work on Expressive 3.0 which will support only final PSR-15. For more information about it you can have a look on forum: https://discourse.zendframework.com/t/psr-15-compatibility-issues-and-proposal/378 We can't provide easly support of every version of http-interop middleware because these requires different version of PHP and are in different libraries. I believe PSR-15 will be accepted in January 2018, before that we should have Expressive 3.0 alpha, and as soon as PSR-15 is accepted Expressive 3.0 beta/RC :)

The way to go right now is to use expressive with http-interop/http-middleware 0.4.1, because it is the only supported version by zend-expressive module. All other modules also support this version, and some of them support version 0.5.0 through compatibility layer mentioned above. I recommend to use expressive-skeleton: https://github.com/zendframework/zend-expressive-skeleton and command:

$ composer create-project zendframework/zend-expressive-skeleton <project-path>

(I've just checked this on my machine and all seems to be right).

Please tell us what exactly you did - did you try to install only expressive, without the skeleton? I hope it was helpful for you and let us know if you have any further issues. Thanks!

gilbertoalbino commented 6 years ago

@webimpress Thanks for so fast reply!

To make the switch from Laravel to Zend Expressive I have recently bought the Matthew Setter's book. He proposes to start by creating the bootstrap process manually in order to get acquainted of how Expressive works. I really enjoy this approach. As soon as I experienced this issue I visited the official docs and in fact the overall process was quite the same.

Lastly, I might have got stuck in this approach.

I am Ok to use the Skeleton Project, but will Expressive 3.0 cause to be different from what it is now?

Also, I am not in the mood to refactor my code in the next few months.

I built two huge projects with ZF2 and got quite frustrated making the move to the modern ZF3 approach.

Will take a try with the Skeleton, anyways!

Thanks!

michalbundyra commented 6 years ago

@gilbertoalbino

@weierophinney Thanks for so fast reply!

I'm @webimpress, not @weierophinney :)

Also, I am not in the mood to refactor my code in the next few months.

If you start now on Expressive 2.0 then you will have update to Expressive 3.0 but I think this update shouldn't be difficult. Of course I'm not sure how far we are gonna go with version 3.0 but definitely everything will be documented and we will be always happy to help you with migration (see our forum and slack).

I migrated couple applications from Expressive 1.0 to 2.0 and it was quite easy.

We try to make migration as easiest as possible. We working also on some tools which helps with migration - see https://github.com/zendframework/zend-expressive-tooling and here is my PR with new tool for expressive 3.0.0-alpha1: https://github.com/zendframework/zend-expressive-tooling/pull/39 As you can see it's a bit different than between ZF2->ZF3. I believe that in final version of expressive we will have even more tools and the update path will be clear and painless. I wouldn't be worried about this right now :smile:

belgattitude commented 6 years ago

@gilbertoalbino

I tried ^0.4.1 but it says I should avoid it! Is that the way to go?

I guess you explicitly added the requirement to your project composer.json ? Like this:

  "require": {
        "http-interop/http-middleware": "^0.4.1",

This should resolve your issue, IMHO don't worry about the message 'http-interop-http-middleware is abandoned...',

Also, I am not in the mood to refactor my code in the next few months.

it's gonna be easy to upgrade when (if) PSR15 is final (for now in voting phase). I agree with @webimpress, upgrading from 1.0 to 2.0 was really easy (both with the provided tooling, or by-hand refactoring: it's gonna be changing an interface name and a method in your middlewares. Logic will be the same, no worry).

A good tip, subscribe to the slack channel and the discourse forums. The community is really helpful.

Ocramius commented 6 years ago

FWIW, PSR-15 is final, so I wouldn't pursue this any further. Upgrading to PSR-15 is the way to go here.