Docker image for phplint

November 4, 2022 · View on GitHub

Tag License

lint build nightly

All #awesome-ci Docker images

ansible-lint ansible awesome-ci bandit black checkmake eslint file-lint gofmt goimports golint jsonlint kubeval linkcheck mypy php-cs-fixer phpcbf phpcs phplint pycodestyle pydocstyle pylint terraform-docs terragrunt-fmt terragrunt yamlfmt yamllint

View Dockerfiles on GitHub.

Available Architectures: amd64, i386, arm64, arm/v7, arm/v6

Tiny Alpine-based dockerized version of PHP[1], which defaults to linting mode and adds the option to ignore files and paths. The image is built nightly against multiple stable versions and pushed to Dockerhub.

:whale: Available Docker image versions

Docker

Rolling releaess

The following Docker image tags are rolling releases and are built and updated every night.

nightly

Docker TagGit RefPHPFlavourAvailable Architectures
latestmasterlatestdefaultamd64, i386, arm64, arm/v7, arm/v6
alpinemasterlatestAlpineamd64, i386, arm64, arm/v7, arm/v6
debianmasterlatestDebianamd64, i386, arm64, arm/v7, arm/v6
8.1master8.1.xdefaultamd64, i386, arm64, arm/v7, arm/v6
8.1-alpinemaster8.1.xAlpineamd64, i386, arm64, arm/v7, arm/v6
8.1-debianmaster8.1.xDebianamd64, i386, arm64, arm/v7, arm/v6
8.0master8.0.xdefaultamd64, i386, arm64, arm/v7, arm/v6
8.0-alpinemaster8.0.xAlpineamd64, i386, arm64, arm/v7, arm/v6
8.0-debianmaster8.0.xDebianamd64, i386, arm64, arm/v7, arm/v6
7.4master7.4.xdefaultamd64, i386, arm64, arm/v7, arm/v6
7.4-alpinemaster7.4.xAlpineamd64, i386, arm64, arm/v7, arm/v6
7.4-debianmaster7.4.xDebianamd64, i386, arm64, arm/v7, arm/v6
7.3master7.3.xdefaultamd64, i386, arm64, arm/v7, arm/v6
7.3-alpinemaster7.3.xAlpineamd64, i386, arm64, arm/v7, arm/v6
7.3-debianmaster7.3.xDebianamd64, i386, arm64, arm/v7, arm/v6
7.2master7.2.xdefaultamd64, i386, arm64, arm/v7, arm/v6
7.2-alpinemaster7.2.xAlpineamd64, i386, arm64, arm/v7, arm/v6
7.2-debianmaster7.2.xDebianamd64, i386, arm64, arm/v7, arm/v6
7.1master7.1.xdefaultamd64, i386, arm64, arm/v7, arm/v6
7.1-alpinemaster7.1.xAlpineamd64, i386, arm64, arm/v7, arm/v6
7.1-debianmaster7.1.xDebianamd64, i386, arm64, arm/v7, arm/v6
7.0master7.0.xdefaultamd64, i386, arm64, arm/v7, arm/v6
7.0-alpinemaster7.0.xAlpineamd64, i386, arm64, arm/v7, arm/v6
7.0-debianmaster7.0.xDebianamd64, i386, arm64, arm/v7, arm/v6
5.6master5.6.xdefaultamd64, i386, arm64, arm/v7, arm/v6
5.6-alpinemaster5.6.xAlpineamd64, i386, arm64, arm/v7, arm/v6
5.6-debianmaster5.6.xDebianamd64, i386, arm64, arm/v7, arm/v6

Point in time releases

The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date.

build

Docker TagGit RefPHPFlavourAvailable Architectures
latest-<tag>tag: <tag>latestdefaultamd64, i386, arm64, arm/v7, arm/v6
alpine-<tag>tag: <tag>latestAlpineamd64, i386, arm64, arm/v7, arm/v6
debian-<tag>tag: <tag>latestDebianamd64, i386, arm64, arm/v7, arm/v6
8.1-<tag>tag: <tag>8.1.xdefaultamd64, i386, arm64, arm/v7, arm/v6
8.1-alpine-<tag>tag: <tag>8.1.xAlpineamd64, i386, arm64, arm/v7, arm/v6
8.1-debian-<tag>tag: <tag>8.1.xDebianamd64, i386, arm64, arm/v7, arm/v6
8.0-<tag>tag: <tag>8.0.xdefaultamd64, i386, arm64, arm/v7, arm/v6
8.0-alpine-<tag>tag: <tag>8.0.xAlpineamd64, i386, arm64, arm/v7, arm/v6
8.0-debian-<tag>tag: <tag>8.0.xDebianamd64, i386, arm64, arm/v7, arm/v6
7.4-<tag>tag: <tag>7.4.xdefaultamd64, i386, arm64, arm/v7, arm/v6
7.4-alpine-<tag>tag: <tag>7.4.xAlpineamd64, i386, arm64, arm/v7, arm/v6
7.4-debian-<tag>tag: <tag>7.4.xDebianamd64, i386, arm64, arm/v7, arm/v6
7.3-<tag>tag: <tag>7.3.xdefaultamd64, i386, arm64, arm/v7, arm/v6
7.3-alpine-<tag>tag: <tag>7.3.xAlpineamd64, i386, arm64, arm/v7, arm/v6
7.3-debian-<tag>tag: <tag>7.3.xDebianamd64, i386, arm64, arm/v7, arm/v6
7.2-<tag>tag: <tag>7.2.xdefaultamd64, i386, arm64, arm/v7, arm/v6
7.2-alpine-<tag>tag: <tag>7.2.xAlpineamd64, i386, arm64, arm/v7, arm/v6
7.2-debian-<tag>tag: <tag>7.2.xDebianamd64, i386, arm64, arm/v7, arm/v6
7.1-<tag>tag: <tag>7.1.xdefaultamd64, i386, arm64, arm/v7, arm/v6
7.1-alpine-<tag>tag: <tag>7.1.xAlpineamd64, i386, arm64, arm/v7, arm/v6
7.1-debian-<tag>tag: <tag>7.1.xDebianamd64, i386, arm64, arm/v7, arm/v6
7.0-<tag>tag: <tag>7.0.xdefaultamd64, i386, arm64, arm/v7, arm/v6
7.0-alpine-<tag>tag: <tag>7.0.xAlpineamd64, i386, arm64, arm/v7, arm/v6
7.0-debian-<tag>tag: <tag>7.0.xDebianamd64, i386, arm64, arm/v7, arm/v6
5.6-<tag>tag: <tag>5.6.xdefaultamd64, i386, arm64, arm/v7, arm/v6
5.6-alpine-<tag>tag: <tag>5.6.xAlpineamd64, i386, arm64, arm/v7, arm/v6
5.6-debian-<tag>tag: <tag>5.6.xDebianamd64, i386, arm64, arm/v7, arm/v6

Where <tag> refers to the chosen git tag from this repository.

:open_file_folder: Docker mounts

The working directory inside the Docker container is /data/ and should be mounted locally.

:computer: Usage

Generic

$ docker run -it --rm cytopia/phplint --help
Usage: cytopia/phplint [-i] <PATH-TO-FILE>
       cytopia/phplint [-i] <GLOB-PATTERN>
       cytopia/phplint --version
       cytopia/phplint --help

 -i <GLOB-PATTERN>  Ignore glob pattern when using the GLOB-PATTERN for file search.
                    (e.g.: -i '\.test*.php')
 <PATH-TO-FILE>     Path to file to validate
 <GLOB-PATTERN>     Glob pattern for recursive scanning. (e.g.: *\.php)
                    Anything that "find . -name '<GLOB-PATTERN>'" will take is valid.

Lint PHP files

$ docker run -it --rm -v $(pwd):/data cytopia/phplint
find . -name "*.php" -type f -print0
php -d display_errors=1 -d error_reporting=-1 -l ./index.php
php -d display_errors=1 -d error_reporting=-1 -l ./config.php
php -d display_errors=1 -d error_reporting=-1 -l ./settings.php

Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ',' or ';' in ./settings.php on line 4

Example Makefile

You can add the following Makefile to your project for easy generation of PHP linting.

ifneq (,)
.error This Makefile requires GNU Make.
endif

.PHONY: lint _update-phplint
CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

VERSION = 7.3
IGNORES = ./vendor/*

lint: _update-phplint
	docker run -it --rm cytopia/phplint:${VERSION} -i ${IGNORES} '*.php'

_update-phplint:
	docker pull cytopia/phplint:${VERSION}

Travis CI integration

With the above Makefile in place, you can easily add a Travis CI rule to ensure the terraform-docs output is always up-to-date and will fail otherwise (due to git changes):

---
sudo: required
language: minimal
services:
  - docker
script:
  - make lint

Docker images

Save yourself from installing lot's of dependencies and pick a dockerized version of your favourite linter below for reproducible local or remote CI tests:

GitHubDockerHubTypeDescription
awesome-ciaci-hub-imgBasicTools for git, file and static source code analysis
file-lintflint-hub-imgBasicBaisc source code analysis
linkchecklinkcheck-hub-imgBasicSearch for URLs in files and validate their HTTP status code
ansibleansible-hub-imgAnsibleMultiple versions and flavours of Ansible
ansible-lintalint-hub-imgAnsibleLint Ansible
gofmtgfmt-hub-imgGoFormat Go source code [1]
goimportsgimp-hub-imgGoFormat Go source code [1]
golintglint-hub-imgGoLint Go code
eslintelint-hub-imgJavascriptLint Javascript code
jsonlintjlint-hub-imgJSONLint JSON files [1]
kubevalkubeval-hub-imgK8sLint Kubernetes files
checkmakecm-hub-imgMakeLint Makefiles
phpcbfpcbf-hub-imgPHPPHP Code Beautifier and Fixer
phpcspcs-hub-imgPHPPHP Code Sniffer
phplintplint-hub-imgPHPPHP Code Linter [1]
php-cs-fixerpcsf-hub-imgPHPPHP Coding Standards Fixer
banditbandit-hub-imgPythonA security linter from PyCQA
blackblack-hub-imgPythonThe uncompromising Python code formatter
mypymypy-hub-imgPythonStatic source code analysis
pycodestylepycs-hub-imgPythonPython style guide checker
pydocstylepyds-hub-imgPythonPython docstyle checker
pylintpylint-hub-imgPythonPython source code, bug and quality checker
terraform-docstfdocs-hub-imgTerraformTerraform doc generator (TF 0.12 ready) [1]
terragrunttg-hub-imgTerraformTerragrunt and Terraform
terragrunt-fmttgfmt-hub-imgTerraformterraform fmt for Terragrunt files [1]
yamlfmtyfmt-hub-imgYamlFormat Yaml files [1]
yamllintylint-hub-imgYamlLint Yaml files

[1] Uses a shell wrapper to add enhanced functionality not available by original project.

Makefiles

Visit cytopia/makefiles for dependency-less, seamless project integration and minimum required best-practice code linting for CI. The provided Makefiles will only require GNU Make and Docker itself removing the need to install anything else.

:page_facing_up: License

MIT License

Copyright (c) 2019 cytopia