oscarotero / psr7-middlewares

[DEPRECATED] Collection of PSR-7 middlewares
MIT License
668 stars 56 forks source link

Split into separate discrete packages? #23

Open jakejohns opened 8 years ago

jakejohns commented 8 years ago

I had some recollection of this being discussed, but I don't see it in the issue tracker, so I figure I'd raise it here. I assume there has been some discussion on this, so at minimum, I think it would be nice to have the record of it here.

Firstly, I'm a fan of minimalism and the 'do one thing and do it right' ethos. In my opinion, it would be nice to have this collection split into separate, discrete packages. Things like the Authentication middleware might be grouped together, but things of disparate concerns with varying requirements could/should be separate.

I think the most obvious reason is that a handful of these have real requirements (i.e. AuraRouter), which are only listed as suggestions. The ability to actually require the dependency (including version requirements) seems like an obvious benefit.

Additionally, it just doesn't feel right to me to require the whole thing to use a single component. It would be nice to glance at componser.json and have at least some idea of what functionality is being leveraged. It's also strange to continually get updates which are possibly unrelated to the utilized functionality.

I also assume (possibly without cause) that release versioning is/will-become cumbersome with this paradigm. Given two components of unrelated concerns, should not one be able to change it's public API and require a 1.0 release without affecting the other?

I would register my vote for separate vendor prefix with discrete packages (eg oscarware/aura-router, oscarware/auth, etc.). If absolutely necessary, they could require a common utility package. For those desiring the "all-in-one" paradigm, an additional package could be created which simply requires the discrete ones.

Thoughts?

oscarotero commented 8 years ago

Yeah, I had this discussion other times, but not in github, so it's fine. The original idea of this package is to provide a set of micro-middleware pieces that you can use in your projects. Most of them with less than 100 lines, and only a couple more than 200. The goal was to be something like underscore or other similar packages that provide a collection of utilities for a specific purpose, in this case psr7 middlewares.

The benefits of the "all-in-one" apropach:

The benefits of split packages:

I think both approaches are valid, but cannot live toghether. If this package is divided in micro-packages, with the dependencies required (not suggested as they are now), the "all-in-one" package will install all dependecies.

Currently we can find a lot of individual middlewares and I think a good point of this package, is precisely, provide a different way.

That being said, I'm open minded, so if more people prefer divide all, a good solution is use a "psr7-middlewares" vendor, and create a github organization with more people that want to be involved.

codeliner commented 8 years ago

+1 for splitting the package

atm I only use the Payload middleware in my cargo sample. Some days ago a user opened an issue because the sample app did not work. Reason was that the Psr7Middlewares\Middleware\Payload interface was changed in a minor version and I did not recognize it. Here is the related issue and the necessary change

If each middleware would live in its own package one can follow changes more easily. Besides that it is really a big advantage if individual packages can manage their dependencies. We apply this strategy for our prooph components and it works really well. You can test different versions of dependencies on travis and let each package evolve independent from the others. The drawback is a decentralized documentation. We solved the problem by using bookdown.io and aggregate package documentation in a meta package. Bookdown.io lacks some features but PRs are on their way.

wolfy-j commented 8 years ago

I might agree on splitting routers into separate packages as having multiple routers in one place seems very unrealistic. However having rest of middlewares together seems cool, being able to connect and play with middlewares is very useful on medium/big projects.

sander-bol commented 8 years ago

Another +1 for splitting. See for example how Zend Framework does this (https://github.com/zendframework/zf2) they have a zf2 package which just groups all their small packages together.

adamaltman commented 8 years ago

+1 for splitting... the main issue I see with splitting is the shared traits, which are used by many of the middlewares. Although, those could also be split into their own repository, and required as needed by the middleware. A meta package which groups the smaller packages together would work fine, for someone who wants the all-in-one, or mainly, I think, a way to explore for new packages and ideas.

+1 "create a github organization with more people that want to be involved"

hdimo commented 8 years ago

+1 for splitting, using right package for right job, not need all packages for doing foe example recaptcha

mindplay-dk commented 8 years ago

+1 for splitting.

Per OP, being able to correctly use require rather than suggests is quite compelling.

Moreover, how would you manage a breaking change in one of these middleware components?

You'd have two choices: major version bump, which will cause conflicts between packages that use any of these components - or breaking semver, which will cause run-time errors.

That alone should be a sufficiently compelling reason to package these individually. (The odds of never needing to make a breaking change to any of a growing number of components? Not good.)

I'd suggestion creating a GitHub organization for the individual packages. Rather than inviting people to PR against a monolithic package, you should invite them to publish their middleware packages under the organization banner.

With PSR-15 coming up (and I'm assuming you're interested, because you've been participating in the discussions) you will need to make breaking changes to every component anyhow, so that should be an opportunity to gradually port these components to individual packages under a new organization-name.

You could invite the community to participate in that effort. I'd be happy to help port some of these - I'm eventually going to need PSR-15 versions of some of these anyhow.

oscarotero commented 8 years ago

Yes, finally I'm agree to split the packages 🎉 The idea I had in mind was the following:

What do you think?

mindplay-dk commented 8 years ago

@oscarotero "middleland" sounds a lot like a "brand-name". Isn't that also the name of your middleware dispatcher package? That would seem to imply this is middleware designed specifically for that library.

I think that a community effort should have a more neutral name, like e.g. php-middleware, psr-middleware or even psr15-middleware.

(my personal favorite would be php-middleware, since, hopefully, that's what PSR-15 will become: the standard for PHP middleware.)

mindplay-dk commented 8 years ago

(would it make sense to gather not only middleware, but also dispatchers, under a single organization-name? everything middleware-related in one place?)

oscarotero commented 8 years ago

would it make sense to gather not only middleware, but also dispatchers, under a single organization-name? everything middleware-related in one place?

This is why "middleland" (the land of middleware). I know that it's a brand name, but what isn't?

Isn't that also the name of your middleware dispatcher package?

The dispatcher name is simply Dispatcher, but yes, it's included in the organization, using the same namespace. Anyway, this was only an experiment (it's not even registered in packagist) and can be removed (or moved out of the organization).

I think that a community effort should have a more neutral name, like e.g. php-middleware, psr-middleware or even psr15-middleware.

php-middleware exists. And I don't think we could use psr-middleware, because seems a PSR official package (in fact, initially I renamed the vendor name of this package because this. And the problem with Psr15-middleware is whether Psr-15 becomes obsolete and replaced by other specification (ex psr-34).

mindplay-dk commented 8 years ago

Brand-names have corporate connotations to me, that's all. I'd prefer a name that sounds more like a neutral community/group-effort than a product/brand-name, which (to some) could imply ownership.

middlewares is available.

middleware-group, middleware-list and middleware-community are all available, and .org domain-names are available for any of those too, in case we want to set up a community hub or other non-GitHub presence at some later time.

oscarotero commented 8 years ago

Ok, I've created middlewares and invited you (feel free to reject if you don't want to join now). I think the prefixes -group -list or -community are innecessary (at least in the organization name of github).

oscarotero commented 8 years ago

Hello There's the first version of the psr-15 port of these middlewares, splitted in individual packages and other improvements. You can check it here: https://github.com/middlewares/psr15-middlewares

mindplay-dk commented 8 years ago

Holy shit, you just did all that work yourself! Kudos! 👍 :-)

mindplay-dk commented 8 years ago

Really, this is incredible work, man! This is really going to help set fire to PSR-15. Thank you :-)

oscarotero commented 8 years ago

Holy shit, you just did all that work yourself! Kudos! 👍 :-)

Thank you. I had a couple of weeks with lot of free time. I did almost all work but there's some middlewares that I didn't ported:

Anyway, I'd like to use the new repository to discuss about this or other issues.

mindplay-dk commented 8 years ago

My coworker is working on PSR-7/15 components and middleware for cookies and sessions. Should have a release in a week or two. I'll keep you posted :-)

oscarotero commented 8 years ago

Great. FYI, I have a roadmap with several random ideas of possible new components (https://github.com/middlewares/psr15-middlewares/projects/1)

mindplay-dk commented 8 years ago

Haha, you have my new chrome-logger on there already - I haven't even announced it anywhere yet, you're fast ;-)

That one will have middleware soon though - the package might just come with it, or I might create a separate project under middlewares, not sure; it'll be very small and simple, obviously.

oscarotero commented 8 years ago

I think using the middlewares vendor should increase its discovery. Btw, I decided to change the list of packages in the README and group the components by type instead alphabetically (security, development utils, optimization, authentication, routers, session, etc...)