Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Drupal/Component level code is intended to be reusable outside of Drupal itself via composer inclusion. Adding composer.json files to these code bases is the first step in doing that and many of those depend upon Utility, so I've begun by adding the composer.json file for utility first. This will ultimately enable us to do subtree splits against drupal core and distribute our Components into separate git repositories that others can pull from individually.
Eclipse
Comment | File | Size | Author |
---|---|---|---|
#21 | 2176065-21.patch | 635 bytes | EclipseGc |
Comments
Comment #1
EclipseGc CreditAttribution: EclipseGc commentedI've emulated Symfony's approach to attribution here, dunno if Dries is a.) ok with this and b.) if he wants to use the email address.
Eclipse
Comment #2
penyaskitotypo :-P
Comment #3
EclipseGc CreditAttribution: EclipseGc commentedTypo
Eclipse
Comment #4
EclipseGc CreditAttribution: EclipseGc commentedWe don't have any attribution in the base composer.json for drupal, so I just went ahead and removed it here as well. I think this probably puts this into a committable state.
Eclipse
Comment #5
dawehnerLet's go with 5.3.10 for now.
Maybe some examples would be helpful (String/XSS)
Should we link to https://www.drupal.org/project/drupal instead?
I wonder whether we should prefix the drupal core components somehow. (drupal/core-utility). Just wondering.
Comment #6
EclipseGc CreditAttribution: EclipseGc commented1.) Crell and I discussed this and he suggested setting it the same as D8, I didn't argue, but I see no reason to set it arbitrarily higher than what is actually needed here.
2.) OOOOOK
3.) You're not the first person to suggest that. I disagree, but am apparently in the minority, and it seems a really minor thing.
4.) Not sure what we'll do for Drupal/Core stuff... you're solution doesn't seem bad, but I question whether any of that will ever end up "composerable".
Eclipse
Comment #7
EclipseGc CreditAttribution: EclipseGc commentedwe'll make it https
Eclipse
Comment #8
dawehnerLet's go with that as a first step.
We should consider to create an issue somewhere to do an automatic subtree cron based splitting
Comment #10
sunIs it is very likely that we'll copy/paste this first file as a template later on, can we (1) fix the indentation and (2) turn the inner namespace hashmap onto a separate line?
In short:
Comment #11
dawehnerThis 4 spaces clearly from the outside world which pretty much all uses 4 spaces in the composer.json files. Maybe we should discuss that somewhere.
Comment #12
sunI've seen composer.json files in the wild using 2 spaces, 4 spaces, or even tabs.
I don't think there is a coding standard for composer.json files. → As long as it's valid JSON, everything works.
I don't really care which form we're going to use, but I think there is one crystal clear rule that we can all agree to:
Within the scope of a single file, the style should be consistent.
The autoload:psr-0 lines are the only lines that diverge from the rest of the file. There are multiple ways to fix this, just choose one. I'd personally prefer to stick to 2 spaces, but again, only consistency matters. :)
Comment #13
EclipseGc CreditAttribution: EclipseGc commentedYou are completely right, my bad.
Eclipse
Comment #14
sunThanks! :-)
Now, personally, I'd like to perform the following change for maximum accuracy + architectural sanity, but I'm not sure whether we're able to do it right now, because AFAIK there is at least one offender (Settings):
In other words: Any class that is not a static utility function class (mainly wrapping PHP core code) has absolutely no place in \Drupal\Component\Utility. It concerns me that this is not a hard requirement for \Utility.
That said, I'd also drop the "Drupal components including" part. → By exposing them to the public, they are no longer for "Drupal components" only. :P
Comment #15
EclipseGc CreditAttribution: EclipseGc commentedwhat about:
"description": "Mostly static utility classes for string, xss, array, image, and other commonly needed manipulations.",
??? I know, it's totally suboptimal, but at least it's honest.
Let me know.
Eclipse
Comment #16
sun"Mostly static" is an excellent idea and compromise! :-)
Comment #17
EclipseGc CreditAttribution: EclipseGc commentedOk then.
Eclipse
Comment #18
Damien Tournoud CreditAttribution: Damien Tournoud commentedThe license property doesn't seem to match the documented ones. From the doc, we should be using
GPL-2.0+
.Comment #19
EclipseGc CreditAttribution: EclipseGc commentedSorry, didn't realize there was a page documenting that standard. Thanks!
Eclipse
Comment #20
Tor Arne Thune CreditAttribution: Tor Arne Thune commentedhttps://www.drupal.org/ redirects to https://drupal.org/ so wouldn't it be more correct to use: https://drupal.org/project/drupal ?
Comment #21
EclipseGc CreditAttribution: EclipseGc commentedSeems kosher.
Eclipse
Comment #22
Damien Tournoud CreditAttribution: Damien Tournoud commentedLooks like a good start.
Comment #23
webchickI have no idea what this is for, let's get an updated issue summary.
When I asked Eclipse what it was for, he said it was to allow Component to be split off and that sounds like a strategic question, so also assigning to Dries. This might not actually need to happen, but I can't tell because there's no issue summary. :)
Comment #24
EclipseGc CreditAttribution: EclipseGc commentedComment #25
Crell CreditAttribution: Crell commentedAdding parent issue for context.
Comment #26
dawehner@webchick
So yeah it is not about splitting up the code itself, it is about supporting people which want to reuse the component in NON-drupal variants.
Theoretically this is already possible, though it is kind of a mess without the composer.json file.
Comment #27
EclipseGc CreditAttribution: EclipseGc commentedI updated the summary but failed to remove the tag.
Eclipse
Comment #28
EclipseGc CreditAttribution: EclipseGc commentedComment #29
tstoeckler"xss" should be "XSS", I think.
Comment #30
sunI'm not sure why this needs approval from Dries — for now, the intention is just to perform periodical git-subtree splits (exports) from git.drupal.org/project/drupal into standalone repos per component. The "master"/originating code stays in core.
The composer.json only needs to be added to core, because the subtree-split should be a 1:1 copy of the originating code. A composer.json file is required to use a standalone component with Composer.
In essence, we want to do the exact same thing as Symfony: All Symfony components are maintained in a single project repository, and each of them is split/exported into a standalone repository. This allows other projects (like Drupal) to cherry-pick the components they want to use.
Comment #31
EclipseGc CreditAttribution: EclipseGc commentedThank you sun for explaining what I appear to be incapable of communicating.
sun++
Eclipse
Comment #32
EclipseGc CreditAttribution: EclipseGc commented@tstoeckler
I'd prefer to not do that since they're all currently lower case, consistency and all, and I don't have to decide if various elements of this need additional capitalization.
Eclipse
Comment #33
Dries CreditAttribution: Dries commentedThis looks like a good idea to me (but a low priority).
I'm fine with having read-only clones outside of core, but for now I want these components to be maintained in Drupal core itself.
Comment #34
effulgentsia CreditAttribution: effulgentsia commentedUnassigning from Dries since he answered.
Comment #35
EclipseGc CreditAttribution: EclipseGc commentedYeah, I think we have the same goals in that regard, all this does is make it possible for us to begin working toward that goal. Thanks for responding! I think we're still RTBC.
Eclipse
Comment #36
alexpottCommitted a50ebdf and pushed to 8.x. Thanks!
I validated the the composer json by running
composer validate core/lib/Drupal/Component/Utility/composer.json
I think we should have a change record to detail the purpose of this.
Comment #37
EclipseGc CreditAttribution: EclipseGc commentedAdded a change record.
Eclipse
Comment #38
EclipseGc CreditAttribution: EclipseGc commentedComment #39
EclipseGc CreditAttribution: EclipseGc commentedComment #41
XanoSee #2210257: Bump \Drupal\Component\Utility's PHP requirement to 5.4.2.
Comment #42
davidwbarratt CreditAttribution: davidwbarratt commentedComment #43
Mile23