Sign inSign up

cytopia/phplint

By cytopia

•Updated over 3 years ago

Alpine-based version of PHP for linting and reproducible usage in CI

Image
2

100K+

cytopia/phplint repository overview

⁠Docker image for phplint

Tag License

lint build nightly

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-ci⁠aci-hub-imgBasicTools for git, file and static source code analysis
file-lint⁠flint-hub-imgBasicBaisc source code analysis
linkcheck⁠linkcheck-hub-imgBasicSearch for URLs in files and validate their HTTP status code
ansible⁠ansible-hub-imgAnsibleMultiple versions and flavours of Ansible
ansible-lint⁠alint-hub-imgAnsibleLint Ansible
gofmt⁠gfmt-hub-imgGoFormat Go source code [1]
goimports⁠gimp-hub-imgGoFormat Go source code [1]
golint⁠glint-hub-imgGoLint Go code
eslint⁠elint-hub-imgJavascriptLint Javascript code
jsonlint⁠jlint-hub-imgJSONLint JSON files [1]
kubeval⁠kubeval-hub-imgK8sLint Kubernetes files
checkmake⁠cm-hub-imgMakeLint Makefiles
phpcbf⁠pcbf-hub-imgPHPPHP Code Beautifier and Fixer
phpcs⁠pcs-hub-imgPHPPHP Code Sniffer
phplint⁠plint-hub-imgPHPPHP Code Linter [1]
php-cs-fixer⁠pcsf-hub-imgPHPPHP Coding Standards Fixer
bandit⁠bandit-hub-imgPythonA security linter from PyCQA
black⁠black-hub-imgPythonThe uncompromising Python code formatter
mypy⁠mypy-hub-imgPythonStatic source code analysis
pycodestyle⁠pycs-hub-imgPythonPython style guide checker
pydocstyle⁠pyds-hub-imgPythonPython docstyle checker
pylint⁠pylint-hub-imgPythonPython source code, bug and quality checker
terraform-docs⁠tfdocs-hub-imgTerraformTerraform doc generator (TF 0.12 ready) [1]
terragrunt⁠tg-hub-imgTerraformTerragrunt and Terraform
terragrunt-fmt⁠tgfmt-hub-imgTerraformterraform fmt for Terragrunt files [1]
yamlfmt⁠yfmt-hub-imgYamlFormat Yaml files [1]
yamllint⁠ylint-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⁠

Tag summary

Content type

Image

Digest

sha256:98976ea64…

Size

33.9 MB

Last updated

over 3 years ago

docker pull cytopia/phplint