Download the PHP package totara/codesniffer without Composer

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

Totara Code Sniffer Standard

This project contains a Code Sniffer Standard for Totara Learn.

Prerequisites


Please note that the minimum PHP requirement has changed. You can now only install and run Codesniffer on PHP 7.4 or higher.

You can still analyse versions of Totara compatible only to version 5.6, as long as you run Codesniffer on 7.4 or higher.


Installation

Via Composer

In your project, require this package by running:

You may be prompted to allow the plugin dealerdirect/phpcodesniffer-composer-installer - if so answer yes. This will then install the package in the correct location.

Confirm the Totara standards are available by running ./vendor/bin/phpcs -i.

The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz, Zend, PHPCompatibility, PHPCSUtils and Totara

Manual Installation

Clone this repository into a folder of your choice.

In the root of the project run:

Optionally you can add phpcs to your path:

Usage

Console

To run Code Sniffer using the Totara Standard on the console

As some Sniffs can also check JavaScript files you might want to limit the extensions to one of the two.

Default phpcs.xml file

If your project includes a phpcs.xml or phpcs.xml.dist file you can run Code Sniffer from within your project without specifying the standard or any other configuration set in that file.

See PHP Code Sniffer's Advanced Usage docs for more details.

PHPStorm

To set up PHPStorm to automatically check your files and highlight coding style violations directly in the code

  1. Open "Preferences"
  2. Go to "Languages & Framework" => "PHP" => "Quality Tools" => "Code Sniffer"
  3. Make sure that in the Configuration the "PHP Code Snifffer path" points to the "vendor/bin/phpcs" file within this project
  4. "Validate" the selection and click "Apply"
  5. Go to "Editor" => "Inspections"
  6. In the big tree of Inspections find "PHP" => "Quality Tools" => "PHP Code Sniffer Validation"
  7. Activate the inspection
  8. In the right panel under "Options" choose "Custom" as Standard and click on the "..." button next to it
  9. Choose the ruleset.xml file from this project (src/Standards/Totara/ruleset.xml)
  10. Click "OK"

That's it. Now all violations should be marked directly within your code view.

PHPCompatibility

The Totara standard does include the PHPCompatibility standard as well to check for problems on specific versions.

By default the PHPCompatibility rules will check only the PHP version you are running the phpcs command on. To choose a specific version to check either set the version on the console

or have a "testVersion" configuration option in your phpcs.xml file.

See PHPCompatibility for more details.

Development

Sniffs

In the xml file src/Standards/Totara/ruleset.xml you find all rules used for this Coding Standard. It is a mixture of Sniffs from other Standards and our own Sniffs.

If you create or modify Sniffs within this project make sure you stick to the PSR-2 Coding Standard (to match the style of the original Code Sniffer library) and PSR-4 autoloading.

Testing

If you create or modify Sniffs within this project make sure you create or update unit tests for it.

To run the unit tests:

Git Hook

There is also a pre-commit hook for git to run Code Sniffer on commit.

Check out the instructions on how to use it.


All versions of codesniffer with dependencies

PHP Build Version
Package Version
Requires squizlabs/php_codesniffer Version ^4.0.1
exussum12/coverage-checker Version 1.1.1
phpcompatibility/php-compatibility Version 10.0.0-alpha2
php Version >=7.4
dealerdirect/phpcodesniffer-composer-installer Version ^1.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 totara/codesniffer contains the following files

Loading the files please wait ...