Download the PHP package wearerequired/coding-standards without Composer

On this page you can find all versions of the php package wearerequired/coding-standards. 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 coding-standards

required Coding Standards

eslint-config version phpcodesniffer version stylelint-config version

The required coding standards represent the best practices for enabling a consistent code style across the team. The standards do not only contain stylistic rules. They are also defined to prevent potential security vulnerabilities or to leverage more modern syntax for enhanced performance.
This project is inspired by the Human Made Coding Standards project.

For the JavaScript coding standard head over to @wearerequired/eslint-config.
For the (S)CSS coding standard head over to @wearerequired/stylelint-config.

For team members: Please contact our internal handbook if you need help with setting up the coding standards in your environment.

required PHP Coding Standard

Setup

  1. composer require --dev dealerdirect/phpcodesniffer-composer-installer wearerequired/coding-standards
  2. Run the standards checks using the following command:

The final . here specifies the files you want to test; this is typically the current directory (.), but you can also selectively check files or directories by specifying them instead.

You can add this to your Travis CI configuration as a test:

Bonus: To make things easier, you can add something as follows to your composer.json file:

After that, run composer lint to run the standards checks and composer format to try auto-fixing of errors and warnings.

Excluding Files

This standard includes special support for a .phpcsignore file (in the future, this should be built into phpcs itself). You can place a .phpcsignore file in your root directory (wherever you're going to run phpcs from).

The format of this file is similar to .gitignore and similar files: one pattern per line, comment lines should start with a #, and whitespace-only lines are ignored:

Note that the patterns should match the PHP_CodeSniffer style: * is translated to .* for convenience, but all other characters work like a regular expression.

Patterns are relative to the directory that the .phpcsignore file lives in. On load, they are translated to absolute patterns: e.g. */tests/* in /your/dir/.phpcsignore will become /your/dir/.*/tests/.* as a regular expression. This differs from the regular PHP_CodeSniffer practice.

Advanced/Extending

You can create your own custom standard file (e.g. phpcs.xml.dist) if you want to extend these coding standards:

You can then reference this file when running phpcs:

An example for a custom rule is to validate the text domain:

or to ensure the correct prefix is used:

If the project is a WordPress theme you have to set the following rule:

Included Checks

The phpcs standard is based upon the WordPress-Core, WordPress-Docs, and WordPress-Extra rules from the WordPress Coding Standards. It also uses VariableAnalysis for problematic variable use and some SlevomatCodingStandard rules from the Slevomat Coding Standard. Most of the sniffs are also providing automatic errors fixing for phpcbf.

EditorConfig

The EditorConfig standard helps developers define and maintain consistent coding styles between different editors and IDEs. This way it's easier to follow the given coding standards in a project, without the need to fiddle with IDE settings.

The recommended .editorconfig file for a WordPress project looks like this:


a required open source product - let's get in touch


All versions of coding-standards with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.0
phpcompatibility/phpcompatibility-wp Version 2.1.4
sirbrillig/phpcs-variable-analysis Version 2.11.17
slevomat/coding-standard Version 8.14.1
wp-coding-standards/wpcs Version 3.0.1
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 wearerequired/coding-standards contains the following files

Loading the files please wait ....