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.
Problem/Motivation
Composer package install for drupal/coder
could be more complete by configuring the PHP Code Sniffer installed paths and default standard. Simplifying install encourages more people to use the standards checking tools, thereby improving the overall quality of contributed Drupal code.
Proposed resolution
- Use existing Composer Installer Plugins to configure PHP CodeSniffer.
- Update the README.
Remaining tasks
- Update the Drupal Handbook and Project pages to reflect the change.
- Add an example CircleCI and Travis build configuration to the Handbook.
Comment | File | Size | Author |
---|
Comments
Comment #2
chOP CreditAttribution: chOP at Technocrat commentedI've raised a Pull Request against the Packagist source repository for
drupal/coder
. You can see that here:I can also paste the patch here for discussion. Not sure if you're using the Drupal/CVS workflow or Git/Github workflow.
Comment #3
chOP CreditAttribution: chOP at Technocrat commentedComment #4
chOP CreditAttribution: chOP at Technocrat commentedI've made some further changes to the initial patch, so refer to Github klausi/coder #22 for the up-to-date code.
Comment #5
chOP CreditAttribution: chOP at Technocrat commentedI've closed that Pull Request, opting instead to use existing Composer Installer Plugins for the job. We could support use of this:
https://github.com/DealerDirect/phpcodesniffer-composer-installer
The Plugin does the configuration after install by looking for packages with the type: "phpcodesniffer-standard"
Thoughts anyone? I'm using it now with this in my composer.json
Comment #6
chOP CreditAttribution: chOP at Technocrat commentedComment #7
klausiThanks for the suggestions, this is a complicated topic. Solution in Drupal core: http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Core/Composer/Com...
Of course that is a per project solution, so does not help for a global install.
Your composer plugin would require that we move directories around in Coder, right? That might break configured existing installations, so would be something for Coder 9.
Comment #8
chOP CreditAttribution: chOP at Technocrat commented@klausi I managed to find a Composer Installer Plugin that does not require any change to the directory structure of Coder. It's called dealerdirect/phpcodesniffer-composer-installer and is very well supported and maintained. Works a treat.
The maintainers helped me/us out by accepting my pull request to get it working with Drupal Coder. This plugin (like any Composer Installer Plugin) requires that Coder use a Composer package type that it will recognise.
Change required
Changing the package type from "library" to "phpcodesniffer-standard" is all we'd need to do. One line in the
composer.json
. I'll submit a pull request for your consideration.Changing the Composer package type for Coder should not affect users who aren't using an installer plugin.
Testing the change
Here's working examples to show how it works with the Coder package type changed. The custom repository is a clone of Drupal Coder, with the package type changed. Note the repositories additions below will not be required if the package type in Coder is changed as described above.
Project installs
To test for a project installation use a
composer.json
like this:Global installs
To test the global installer follow these steps:
~/.composer/config.json
file:Comment #9
chOP CreditAttribution: chOP at Technocrat commentedI've opened a pull request for the required change to Drupal Coder.
I'm now asking the dealerdirect/phpcodesniffer-composer-installer maintainers to bump a new release version so that the `dev-master` version constraint can be more like
^0.2.2
and to ensure the plugin can be used when Composer minimum stability is set to stable.Comment #10
klausiMakes sense, committed the PR to change the project type.
Now we should probably update our README?
Comment #12
chOP CreditAttribution: chOP at Technocrat commentedI'll provide a pull request with suggested updates to README.
Comment #13
chOP CreditAttribution: chOP at Technocrat commentedSee the following Pull Request for suggested updates to the README that document usage with Composer Installer Plugins.
Comment #14
chOP CreditAttribution: chOP at Technocrat commentedSee the following Pull Request for suggested updates to the README that document usage with Composer Installer Plugins.
Comment #17
pfrenssenThanks!
Comment #18
pfrenssenComment #19
pfrenssenNo idea how I can "uncredit" myself, this feature must be new :)