Download the PHP package drupal/coder without Composer

On this page you can find all versions of the php package drupal/coder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package coder

Coder

Automated tests

Coder is a library for automated Drupal code reviews and coding standard fixes. It defines rules for PHP_CodeSniffer

Built-in support for:

Online documentation: https://www.drupal.org/node/1419980

Note that Javascript support has been removed. To check and fix Javascript files please use ESLint and see the Drupal ESLint documentation.

Global installation

First, make sure Composer is installed correctly:

which composer

If you get composer not found or similar, follow Composer's installation instructions.

Install Coder (8.3.x) in your global Composer directory in your home directory (~/.config/composer):

composer global require drupal/coder

To make the phpcs and phpcbf commands available globally, add the Composer bin path to your $PATH variable in ~/.profile, ~/.bashrc or ~/.zshrc:

export PATH="$PATH:$HOME/.config/composer/vendor/bin"

Usage

Check Drupal coding standards

phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /file/to/drupal/example_module

Check Drupal best practices

phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /file/to/drupal/example_module

Automatically fix coding standards

phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /file/to/drupal/example_module

Local installation in your Drupal project

For collaborating developer teams it makes sense to lock a Coder version with your other development dependencies locally. In your project where you have your composer.json file execute this:

composer require --dev drupal/coder

Then you can run Coder on your custom module code like this:

./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/custom

To simplify execution it is highly recommended to use a settings file, see below.

Store settings in a phpcs.xml.dist file

In order to save and commit your PHPCS settings to Git you can use a phpcs.xml.dist file in your project like this:

Then you can invoke phpcs without any options and it will read phpcs.xml.dist from the current directory. This can also be useful for Continuous Integration setups. Example:

./vendor/bin/phpcs -p

Working with Editors

Drupal Code Sniffer can be used with various editors.

Editors:

Automated Testing (PHPUnit + PHPCS + PHPStan)

Coder Sniffer comes with a PHPUnit test suite to make sure the sniffs work correctly. Use Composer to install the dependencies:

composer install

Then execute the tests:

./vendor/bin/phpunit

Then execute the coding standards checker on Coder itself:

./vendor/bin/phpcs

Then execute static analysis:

./vendor/bin/phpstan

Contributing

  1. Make sure an issue exists at https://www.drupal.org/project/issues/coder
  2. Create a Pull Request against https://github.com/pfrenssen/coder
  3. Post a link to the pull request to the issue on drupal.org and set the issue to "needs review"

Thank you!

Maintainers

[//]: # cspell:ignore Pieter Frenssen Welford

Credits

Greg Sherwood and Squiz Pty Ltd, many sniffs are modified copies of their original work on PHPCS.


All versions of coder with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
ext-mbstring Version *
dealerdirect/phpcodesniffer-composer-installer Version ^0.7.1 || ^1.0.0
sirbrillig/phpcs-variable-analysis Version ^2.11.7
slevomat/coding-standard Version ^8.11
squizlabs/php_codesniffer Version ^3.9.1
symfony/yaml Version >=3.4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package drupal/coder contains the following files

Loading the files please wait ....