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.
Comment | File | Size | Author |
---|---|---|---|
#2 | composer-2770355-2.patch | 414 bytes | Shreya Shetty |
Comments
Comment #2
Shreya Shetty CreditAttribution: Shreya Shetty as a volunteer and at Trigyn Technologies Ltd commentedComment #3
Shreya Shetty CreditAttribution: Shreya Shetty as a volunteer and at Trigyn Technologies Ltd commentedComment #4
mikeker CreditAttribution: mikeker as a volunteer commented@Shreya Shetty, thank you for the patch. Can you explain the need of a composer.json file if there are no dependencies to include?
And my apologies for the delay getting to this issue.
Comment #5
dawehnerIMHO this patch would just be needed if bef would have some sort of dependency on another PHP library, or wouldn't be hosted on d.o. I think both conditions are wrong.
Comment #6
mikeker CreditAttribution: mikeker as a volunteer commentedSince BEF currently has no dependencies and the d.o packaging script builds a default
composer.json
file based on what's in your module'sinfo.yml
file, I'm going to close this as won't fix. Otherwise, we have to maintain things like the module description in two places instead of one.If someone can show me a use case where a
composer.json
is needed, please feel free to reopen this issue.Comment #7
Lukas von BlarerOk, maybe I don't understand the Composer workflow yet, but if I create a fork of a module, it will need a
composer.json
file since Github or any other Git hosting will not build acomposer.json
. So wouldn't it make sense if every module provided acomposer.json
by default?Comment #8
mikeker CreditAttribution: mikeker as a volunteer commented@Lukas von Blarer, wouldn't it be the responsibility of the fork to add the composer.json file if they're going to change hosting locations?
Honestly I don't really care one way or the other -- it's a pretty small addition after all -- I'm just concerned about adding things that leave me with multiple places to update information such as the project description.
I also saw a thread that raised the concern about too many composer.json files impacting Composer's performance, but I can no longer find it...
Comment #9
Lukas von BlarerI don't know about best practices how to handle this. I understand your concern about updating stuff in multiple places. Drupal core has a soft dependency on Composer, but it is needed in most cases. Does anyone know more about this?
When it comes to forking, it would be quite inconvenient having to add composer.json ass well since this would mess up pull requests. I've encountered a lot of modules without Composer dependencies that have one.
Comment #10
mansspams CreditAttribution: mansspams at Wunder commentedIf you do not add this file, we get "The requested package drupal/better_exposed_filters could not be found in any version, there may be a typo in the package name." when following https://www.drupal.org/docs/develop/using-composer/using-composer-to-man....
Comment #11
dawehner@mansspams
Are you sure you have the drupal.org bit in your composer.json file?
Comment #12
mikeker CreditAttribution: mikeker as a volunteer commentedI am able to run
composer require drupal/better_exposed_filters
and have it download the latest release of the module. The Drupal composer endpoints will create the composer.json if one doesn't exist (just pulls info from the module's .info.yml file).I'm guessing that either you were missing the Drupal composer endpoint as @dawehner mentioned in #11, or you have your min stability set too high (BEF only has an alpha release on D8).
Comment #13
allella CreditAttribution: allella as a volunteer commented@mikeker Interesting bit about the https://packages.drupal.org/8 endpoint generating a composer.json from a module's .info.yml information. However, there may be another reason to consider adding a composer.json.
Both drupal/drupal and drupal-composer/drupal-project require composer-installers, which can read a "type:" from each module's composer.json to allow for easily defining custom install paths.
I explained this in more detail to the entityqueue maintainer and he agreed and decided to add a composer.json.
Comment #14
allella CreditAttribution: allella as a volunteer commentedIt turns out the packages.drupal.org Composer endpoint will read .info.yaml files and create a composer.json with a type: drupal-module when contrib modules don't provide a composer.json.
This means it's not necessary to have a composer.json unless the module has 3rd party dependencies. However, there's no harm in having one since Composer is likely to be a bigger part of Drupal and PHP going forward. Also, this is dependent on an endpoint being smart enough to generate a file, which may not be a great long term expectation if endpoints change.
Comment #15
jeremyr CreditAttribution: jeremyr as a volunteer commentedBecause of the age of this issue and really no requirement to have a composer.json in the module I'm setting this to wont fix. Please reopen if anyone feels otherwise.