Skip to content


GitHub stars GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

phplint documentation

phplint - GitHub

Configuration in MegaLinter

Variable Description Default value
PHP_PHPLINT_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
PHP_PHPLINT_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
PHP_PHPLINT_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
PHP_PHPLINT_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- list_of_files: Call the linter with the list of files as argument
- project: Call the linter from the root of the project
PHP_PHPLINT_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
PHP_PHPLINT_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
PHP_PHPLINT_PRE_COMMANDS List of bash commands to run before the linter None
PHP_PHPLINT_POST_COMMANDS List of bash commands to run after the linter None
PHP_PHPLINT_CONFIG_FILE phplint configuration file name
Use LINTER_DEFAULT to let the linter find it
PHP_PHPLINT_RULES_PATH Path where to find linter configuration file Workspace folder, then MegaLinter default rules
PHP_PHPLINT_DISABLE_ERRORS Run linter but consider errors as warnings false
PHP_PHPLINT_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 112 Docker Image Size (tag) Docker Pulls
cupcake MegaLinter for the most commonly used languages 80 Docker Image Size (tag) Docker Pulls
php Optimized for PHP based projects 50 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: .php

How the linting is performed

  • phplint is called once with the list of files as arguments (list_of_files CLI lint mode)

Example calls

phplint myfile.php
phplint mydir
phplint mydir myfile.php
phplint mydir -vvv

Help content

  Lint something

  phplint [options] [--] [<path>...]

  path                               Path to file or directory to lint.

      --exclude=EXCLUDE              Path to file or directory to exclude from linting (multiple values allowed)
      --extensions=EXTENSIONS        Check only files with selected extensions (default: php)
  -j, --jobs=JOBS                    Number of parraled jobs to run (default: 5)
  -c, --configuration=CONFIGURATION  Read configuration from config file (default: ./.phplint.yml).
      --no-configuration             Ignore default configuration file (default: ./.phplint.yml).
      --no-cache                     Ignore cached data.
      --cache=CACHE                  Path to the cache file.
      --no-progress                  Hide the progress output.
      --json[=JSON]                  Path to store JSON results.
      --xml[=XML]                    Path to store JUnit XML results.
  -w, --warning                      Also show warnings.
  -q, --quiet                        Do not output any message
      --no-files-exit-code           Throw error if no files processed.
  -h, --help                         Display help for the given command. When no command is given display help for the list command
  -V, --version                      Display this application version
      --ansi|--no-ansi               Force (or disable --no-ansi) ANSI output
  -n, --no-interaction               Do not ask any interactive question
  -v|vv|vvv, --verbose               Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Installation on mega-linter Docker image

  • Dockerfile commands :
# Parent descriptor install
RUN wget --tries=5 -q -O phive.phar \
    && wget --tries=5 -q -O phive.phar.asc \
    && PHAR_KEY_ID="0x9D8A98B29B2D5D79" \
    && ( gpg --keyserver --recv-keys "$PHAR_KEY_ID" \
        || gpg --keyserver --recv-keys "$PHAR_KEY_ID" \
        || gpg --keyserver --recv-keys "$PHAR_KEY_ID" \
        || gpg --keyserver hkps:// --recv-keys "$PHAR_KEY_ID" ) \
    && gpg --verify phive.phar.asc phive.phar \
    && chmod +x phive.phar \
    && mv phive.phar /usr/local/bin/phive \
    && rm phive.phar.asc \
    && update-alternatives --install /usr/bin/php php /usr/bin/php81 110

ENV PATH="/root/.composer/vendor/bin:$PATH"
# Linter install
RUN composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
    && composer global config bin-dir --absolute