Skip to content
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

Add Plugin Client #14

Merged
merged 1 commit into from May 3, 2016
Merged

Add Plugin Client #14

merged 1 commit into from May 3, 2016

Conversation

sagikazarmark
Copy link
Member

@sagikazarmark sagikazarmark commented Mar 3, 2016

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets partially php-http/plugins#63, related php-http/plugins#64
Documentation php-http/documentation#104
License MIT

What's in this PR?

Moves Plugin client and plugins from the plugins repo

Checklist

  • Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix
  • Documentation pull request created (if not simply a bugfix)
  • Squash before merge

@@ -13,7 +13,8 @@
"require": {
"php": ">=5.4",
"php-http/httplug": "^1.0",
"php-http/message-factory": "^1.0"
"php-http/message-factory": "^1.0",
"symfony/options-resolver": "^2.6|^3.0"
Copy link
Member Author

Choose a reason for hiding this comment

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

This is one of my concerns. Adding this dependency here. Maybe we should rethink option handling in the plugin client?

Copy link
Contributor

Choose a reason for hiding this comment

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

the big benefit of options-resolver is that we are much more flexible to add things without a BC break. adding new constructor parameters can easily lead to BC break, and for these options things, its tricky to decide on the order of them - with separate parameters, the order can not be changed to make logical sense. the array is so much easier.

hm. on the other hand we have only one option for now. maybe we could instead do that manually instead of using OptionsResolver - we can add a requirement for the resolver when we add more options. for just one, its indeed overkill if its not a free include. wdyt?

  • remove the resolver dependency
  • keep $options an array
  • resolve manually for now
  • add a comment next to the options that if we add more options, we should introduce the OptionsResolver

Copy link
Member Author

Choose a reason for hiding this comment

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

This is exactly what I had in my mind.

@sagikazarmark
Copy link
Member Author

See php-http/plugins#64

@sagikazarmark
Copy link
Member Author

FYI @joelwurtz

*
* @author Joel Wurtz <joel.wurtz@gmail.com>
*
* TODO: make class final once removed from plugins.
Copy link
Contributor

Choose a reason for hiding this comment

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

"make class final in version 2.0, once plugins does not extend it anymore" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@joelwurtz
Copy link
Member

Sorry for the delay, under high load actually :)

In fact in my mind i would also move all plugins implementations since the dependency is very strong, it does not make sense IMO to have them alone in there repository, this would add a dependency on php-http/message however,

@sagikazarmark
Copy link
Member Author

The reason I didn't move all plugins here is that it would add too much dependency and code here. I think having plugins separated is not bad. That's our core collection of plugins. You might want to use the plugin client, even without our plugins.

@sagikazarmark
Copy link
Member Author

Although I see the point in lowering the number of repositories, I feel that plugins don't really fit here. @php-http/owners any other input regarding this? It's a 1-1 ATM.

@joelwurtz
Copy link
Member

You might want to use the plugin client, even without our plugins.

Yes there is this use case but it's only for the 1% IMO and we should not bother about that, so we should either move all code from plugins or nothing, but not something between the two.

@sagikazarmark
Copy link
Member Author

Well, I could even live with plugins that does not have any external dependencies. Adding any external dependencies here would make the package a monolith.

@sagikazarmark
Copy link
Member Author

Hm, wouldn't we add a dependency on message with #13? Can we make it an optional dependency?

@sagikazarmark sagikazarmark mentioned this pull request Mar 30, 2016
5 tasks
@dbu
Copy link
Contributor

dbu commented Mar 30, 2016

i think having the clients depend on message seems really not that wrong.

i would prefer to keep everything plugin in php-http/plugin, but if we want to move it anyways we can just as well move the plugins that have no extra dependencies here, and move each plugin with special dependencies to its own repository with properly declared dependencies.

@sagikazarmark
Copy link
Member Author

we want to move it anyways we can just as well move the plugins that have no extra dependencies here, and move each plugin with special dependencies to its own repository with properly declared dependencies.

Yeah, I could live with that. WDYT @joelwurtz?

IMO we had a discussion about doing this (extracting plugins with external dependencies). One possible thing we could do to avoid pluginception is that having message related, message dependent plugins in a message-plugins package. Log and cache could go into their own.

@hannesvdvreken
Copy link

move the plugins that have no extra dependencies here, and move each plugin with special dependencies to its own repository with properly declared dependencies.

Agreed!

@dbu
Copy link
Contributor

dbu commented Mar 30, 2016 via email

@sagikazarmark
Copy link
Member Author

but maybe the concrete example is moot if we need message anyways in client-common and can just put those plugins in here.

Indeed. The router client is going to need it anyway.

@hannesvdvreken
Copy link

otherwise it gets really hard for people to figure out which plugins exist.

In flysystem you get local and FTP adapters out of the box (no dependencies) and it suggests (in composer.json) all of the available adapters

@sagikazarmark
Copy link
Member Author

Well, I think @dbu meant that we can do that, but plugins should either be completely separated or be together. However, it seems that message is going to be a dependency of this package. So plugins without dependencies and plugins depending on message could come here as well.

Pros:

  • Less separate plugin packages

Cons:

  • More dependency here.

@dbu
Copy link
Contributor

dbu commented Mar 30, 2016

exactly, things that add no additional dependencies in this repo, everything else in a clearly named repo. afaik flysystem does the same, grouping separate plugins together makes it really confusing, its an implementors logic rather than consumer logic, and we do these things for the consumers.

@sagikazarmark
Copy link
Member Author

@dbu How can we proceed in the HttplugBundle if get this sorted out? Can we just drop the plugins repo dependency and use the new packages? Isn't it a BC break? Is there such thing regarding dependencies at all?

@dbu
Copy link
Contributor

dbu commented Mar 30, 2016

hm. it certainly is not a patch version change to drop a dependency. but for a minor version i would be ok - it seems a bit of a grey area. but after a minor version upgrade, you should check your stuff and notice you miss the plugin. we can ease things by mentioning which plugins now need to be explicitly required if used in the changelog file.

@sagikazarmark sagikazarmark modified the milestone: v1.1.0 Mar 30, 2016
@joelwurtz
Copy link
Member

Well if we have the php-http/message dependency we can move all plugins since other dependencies are only in suggest on the php-http/plugins package, no ?

If we look at the suggestion also (about log and cache for exemple) this is a pretty common dependency to have (at least for log ATM, and cache should follow fast looking at how it is adopted), so the suggestion will be available only for a few people.

The only plugin we can certainly move out is the Stopwatch one (and make it a dependency on the bundle or directly add him as very few people use stopwatch withtout the symfony framework)

@sagikazarmark
Copy link
Member Author

I would say drop suggestions and move them to separate packages.

@sagikazarmark sagikazarmark changed the title Add Plugin Client [WIP] Add Plugin Client Mar 30, 2016
@joelwurtz
Copy link
Member

IMO we should be more focus on the most common developer experience rather than being perfect about package separation, and even if its better to have this separated in "architecture design", i think most people wants to have the LoggerPlugin out of the box rather to have to require another package.

@dbu
Copy link
Contributor

dbu commented Mar 30, 2016

i think having plugins with external dependencies in their own package is simpler to understand. its easier to say: "if you want logging: require php-http/plugin-logger" than to say: "if you want logging, there is a plugin already but you need to require psr/log".

@sagikazarmark
Copy link
Member Author

In that case, I would also go with #18 immediately.

@dbu
Copy link
Contributor

dbu commented Mar 31, 2016 via email

@sagikazarmark
Copy link
Member Author

the clients that already exist here can't be made final of course.

Yep, I will add todos for them.

@sagikazarmark
Copy link
Member Author

Okay, what's left is to decide whether we want cache and log plugins in this repo or not.

Pros:

  • Every plugin in one place
  • Less packages

Cons:

  • Optional dependencies
  • Harder to document (Add Plugin Client #14 (comment))
  • We cannot rely on psr/log-implementation and psr/cache-implementation virtual packages which would make dependency handling easier

I still think that we should avoid optional dependencies at all cost, because it adds a considerable maintenance overhead (which version compatible with which optional dependency). Also, I don't think that requiring to install a log-plugin package is any worse than requiring to install a log implementation.

On the other hand having everything at one place makes it easier for users to use the package (although we can document the fact of the installation).

If we can't make an agreement on this topic, I propose we have a vote about it (owners with "real" vote, community votes as feedback)

@sagikazarmark
Copy link
Member Author

Also let's set a deadline: this week.

@ddeboer
Copy link

ddeboer commented Apr 11, 2016

I’m in favour of having separate cache and log plugin packages.

For developer friendliness, we could apply Symfony’s trick, where we add one plugins package (with optional deps) that replaces the separate abc-plugin packages, just like symfony/symfony replaces all symfony/[subpackage] packages.

@Nyholm
Copy link
Member

Nyholm commented Apr 11, 2016

Sorry for not replying before.
I can agree that we should put our plugins in the same repo as our other "tools for HTTPlug".
The reson why we do this is as far as I can understand because:

Am I missing something?

About cache and log plugin:

I think (based on intuition only) that plugins that require no dependencies but Symfony OptionResolver and PSR7 should be in client-common. Other plugins should live in their own repository. This will address the issue php-http/plugins#61

About the namespaces:

The current PRs suggest that we have plugins in Http\Client\Common\Plugin and Http\Client\Plugin. Is that right? What will the new namespaces be for the plugins not moved? (logging and cache plugin)?

@sagikazarmark
Copy link
Member Author

What will the new namespaces be for the plugins not moved?

I think we can use Http\Client\Plugin for that purpose. It makes autoloader a little bit slower, if the same namespace is used in many packages, but in production, it should be optimized anyway.

@dbu
Copy link
Contributor

dbu commented Apr 11, 2016

i am +1 on having the plugins with extra dependencies in separate repositories so we can properly specify the requirements rather than have "optional dependencies".

i am -1 on the plugins meta package. we did that for the cmf and its quite tricky, coupling versioning of the packages for example. also, each time we add a new plugin with extra dependencies, this would lead to more things that need to get installed or in the case of virtual packages to composer errors. i would go with explicit dependencies, at least until we have a lot of separate plugins that we feel you would all want to install usually...

@dbu
Copy link
Contributor

dbu commented Apr 11, 2016

Re: Namespaces: why not keep the naming as we have it in this repo and make them Http\Client\Common\Plugin? otherwise we have two different autoload roots in one package, which would be quite confusing. if we really want to avoid Common, we better move everything else to a new folder Common and change the PSR-4 root namespace accordingly. but i would prefer to put the Common in the namespace

@sagikazarmark
Copy link
Member Author

coupling versioning of the packages for example.

Exactly my concern regarding the optional dependencies as well.

I don't have any arguments against using Common.

@sagikazarmark sagikazarmark force-pushed the plugin_client branch 3 times, most recently from ca9ca1c to 4fe307b Compare May 1, 2016 19:47
@sagikazarmark
Copy link
Member Author

@dbu what would happen with logging in HttplugBundle if we extract the logger plugin to a separate package?

Right now logging is enabled by default, which lets us choosing two paths:

  • Require the logger plugin in the bundle as well
  • Don't enable it by default

Planning to sort this out in the next few days and I am looking at other scenarios to finally decide if it could cause any problems to extract cache, log and stopwatch to separate packages.

@dbu
Copy link
Contributor

dbu commented May 2, 2016

in the cmf, we handled this sort of "optional" dependency by saying logging defaults to auto but can be explicitly enabled or disabled. the setting auto means that the DI extension checks if the required class exists and if so, enables logging, otherwise disables it. i can handle the bundle side of this.

@sagikazarmark sagikazarmark changed the title [WIP] Add Plugin Client Add Plugin Client May 2, 2016
@sagikazarmark
Copy link
Member Author

@sagikazarmark
Copy link
Member Author

Documentation added, squashed, remaining plugins separated from the main repo, ready for a final review.

About single repo: for v2 version of the plugins repo we could have it as a meta package requiring all major plugins. However, we have to be careful with versioning.

@@ -6,6 +6,7 @@

- Add a flexible http client providing both contract, and only emulating what's necessary
- HTTP Client Router: route requests to underlying clients
- Plugin client and implementations moved here from `php-http/plugins`
Copy link
Contributor

Choose a reason for hiding this comment

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

what implementations? (i assume you mean plugin implementations, but that is not clear)
should we say "Plugin client and simple plugins moved here from..."?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. We refer to these as core plugins in other places.

Copy link
Contributor

@dbu dbu May 3, 2016 via email

Choose a reason for hiding this comment

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

@dbu
Copy link
Contributor

dbu commented May 3, 2016

are the separate repos fully ready? then i would say go ahead and merge! thanks for the effort!

@sagikazarmark
Copy link
Member Author

From my POV they are ready. Update composer dev alias, changelog and tag necessary.

Update todo

Remove options resolver dependency

Revert: Remove options resolver dependency

Add AddHostPlugin

Add Authentication plugins

Add content length plugin

Add final warning to plugins

Add cookie plugin

Add decoder plugin

Add error plugin

Add header plugins

Add history plugin

Fix namespace import order

Add redirect plugin

Add retry plugin

Make plugin classes final, related #18

Fix throw keyword

Manually apply php-http/plugins#68

Manually apply and close php-http/plugins#65
@sagikazarmark sagikazarmark merged commit 556647f into master May 3, 2016
@sagikazarmark sagikazarmark deleted the plugin_client branch May 3, 2016 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants