-
Notifications
You must be signed in to change notification settings - Fork 37
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
Namespace of all packages #98
Comments
Looks good to me. One comment: Plugin seems to be a bit inconsistent with the other namespaces, which are mostly plural (in case of a collection instead of one, separated component). |
So Http\Plugins then ? |
Sounds logical to me 😄 |
👍 |
Hello! For me your proposal is a lot cleaner than the actual one! 👍
|
I spent hours writing this comment, so it might be that some of my thoughts got mingled. If you take something out of this, let it be two things: we have too many repos, and these are really nicely formatted tables :D. Overview of current repos
Suggested changesWith this categorization in mind, I would like to suggest the following changes. Overall: From php-http/utils, I would use just one message factory, either zend-diactoros or guzzle/psr7 - any PSR-7 compliant HTTP Client should be able to work with either of these. Both have no special dependencies, so this should just be a matter of decision. Message-related reposSuggestion: Merge all repos into one, e.g. Reasoning: It could of course be that I want to create messages with the factory, but I don't need authentication or a special stream, but the single components don't disturb each other. At the moment, if I wanted to create an authenticated HTTP Message with Cookies, I would have to require
Client-related Repos
Adapter-related repos
|
Wow @jeromegamez I cannot find words to describe this. 😄 👍 The fact that we have too many packages came up a few times already. There are upsides and downsides of both the single repo and the multi repo solution.
This is true, but I would at least partially modify this statement: I would exclude contracts and limit to implementations. Contracts are probably better to keep somewhat separated so that you can require them without implementations, which is useful when you want to implement your custom stuff.
I am not sure I understand this. Should we support only one? That's not really interoperable.
Well, as you originally proposed in April when we started the whole thing, we are actually working on an HTTP Client abstraction, not an apdater one. So when we implement something new, then it is actually a client. When we implement a wrapper something already existing, then it's an adapter. To tell the truth, the most useful proposal from your comment is the message thing for me. Message related stuff is really spread across many repositories. With the following modifications, I think that we should actually start working on php-http/message:
Honestly, we really have many components which can be categorized from this point of view (used with messages) and I haven't thought about them before. Good idea @jeromegamez |
I would to always use singular instead of plural (so Plugin and Adapter instead of Plugins and Adapters).Utils is the only namespace I would keep in plural. |
Not sure if we should merge encoding into a message package as it relies on guzzle psr7. |
Sorry, I'm writing from my mobile, so please excuse my brevity :) I don't think relying on guzzle/psr7 is a bad thing - it's a lib without dependencies and could be easily exchanged if someday something "better" comes up. For me it's the same argument as with the message factory: we have the psr/http-message specification, and as long as the generated messages/streams are PSR-7 compliant, it shouldn't matter which lib we use to create them - each client/adapter can handle PSR-7 compliant Message-/Stream-Objects. If they are created by guzzle/psr7 or zend-diactoros or any other factory, shouldn't matter in the end. Please tell me if I'm wrong! |
Here is an argument: php-coveralls/php-coveralls#80 (comment) I think it is the basic idea behind adapters, and should be for messages as well that you can use your own. So if you already use something in your project, why would you need to install another? |
Good point |
@xabbuh can you explain why you would use singular? it feels ok to me and would require less changes, which is a plus. but are there specific reasons for it? |
If the namespace were plural, I would expect each and every class from that namespace to a plugin, an Adapter and so on. While this might be true for Adapters right now a plugin usually contains lots more classes than just a single entry point class. |
Not quite: the guzzle6-adapter already contains an extra class: the wrapper (adapter?) around Guzzle promises. The fact that we (sometimes) have multiple classes per adapter makes me agree with @joelwurtz’s proposal to have a namespace per adapter, but I prefer singular too, so: Re the amount of packages: I’m not too happy with the tools and utils names; what, exactly, is the difference between the two? |
Well, this then supports my reasoning for using a singular |
Actually it is under discussion to merge the two under a better name: #99 The difference between them: Utils holds utilities for reusable library implementors, class-tools holds utilities for client implementors. |
Okay, based on community feedback, it seems that singular namespace names are more welcome. Based on this and #99 I would like to summarize the current package reorganization plan: authentication + message-factory-implementations + message-decorator + encoding = message Namespaces:
Did I mis(understood) something? (Not as nice as @jeromegamez's 😉 ) |
I like it! 👍 |
Some questions left :
|
how do you mean? if i got this correctly i am -1: if things depend on order of autoload or explode if for some reason i have more than one client/adapter in my project (e g partial migration) this is not nice. and its vety implicit |
I think what @sagikazarmark means is that in the following code I would maybe just have to replace use Http\Adapter\Guzzle6\Client;
$client = new Client(...);
// ... |
@xabbuh exactly. |
By the way, I don't think that this is really relevant (constructor arguments can differ or people just use a DI container). However, I like |
The only annoying thing with |
@sagikazarmark Cool! That's even better then. |
ah, got it. yeah Client as class name is fine. people not liking that can
always alias to something else in the use statemenz.
|
Implemented the new namespace setup in our Guzzle6 adapter. Last thing that needs to be decided for the adapters is whether the class name should be |
Ideas:
|
the issue says namespace, but we talk about the FQN here, right?
my vote goes for `Http\Guzzle6Adapter\Client` but i can live with all of
them. having adapter in the namespace and client as class name seems a
good idea to me.
|
Yeah, this discussion is kinda for everything now. So namespaceing then (and FQCNs): Adapters: |
+1
|
I would prefer a schema that follows |
Too long and the second is redundant. Why do you prefer this version? |
Http\Adapter\Guzzle6\Client looks good to me too. agree that Http\Adapter\Guzzle6Adapter\Client would be redundant. |
@sagikazarmark I meant the former one (the latter is indeed redundant). This way all adapters will be under a common namespace. |
@sagikazarmark I’m fine with use GuzzleHttp\Client as GuzzleClient;
use Http\Adapter\Guzzle6\Client;
$guzzleClient = new GuzzleClient(…);
$httplugClient = new Client($guzzle); |
Fine by me as well. |
i would do this to be explicit:
|
I think this is resolved, isn't it? |
Yes. |
I think react and curl adpater / client need to change their namespace, but maybe better to do an issue directly on the repository. |
You are right. Issues are opened. |
More tests for the DI extension * Added test for discovery strategy * Added test for no-debug * Test if profiling is enabled when it should be
I would like to propose the following namespace for our different package (goal is to have, in the future, possibility to assemble all package into a single one with subsplit):
Http\Client
(not changed)Http\Promise
(not changed)Http\Message
(not changed)Http\Tools
(Http\Client\Tools
actually)Http\Utils
(Http\Client\Utils actually)Http\Plugin
(Http\Client\Plugin actually)Http\Adapters\[Adapter Name]
, so Guzzle6 will have this namespace for example :Http\Adapters\Guzzle6
(instead ofHttp\Adapter
actually)Http\Clients\[Client Name]
, so Socket will haveHttp\Clients\Socket
Http\Discovery
(not changed)WDYT ?
The text was updated successfully, but these errors were encountered: