Interested in mastering your PHP craft and getting the most out of PHPStan? Ondřej Mirtes (the creator of PHPStan) will hold a 3-hour interactive workshop as part of the online Dutch PHP Conference on June 25th 2020.
You'll learn how to install, configure, and run PHPStan, receive tips on how to write code so that PHPStan can be as powerful as possible, and you will also be able to write your own PHPStan rules once the workshop is over.Buy a ticket and secure your place! »
The image is based on Alpine Linux and updated automatically.
Supported tags #
docker pull phpstan/phpstan
Alternatively, pull a specific version:
docker pull phpstan/phpstan:0.12
We recommend to use the images as a shell alias shortcut.
phpstan everywhere in the CLI add this line to your
alias phpstan='docker run -v $PWD:/app --rm phpstan/phpstan'
If you don’t have set the alias, use this command to run the container:
docker run --rm -v /path/to/app:/app phpstan/phpstan [some arguments for PHPStan]
docker run --rm -v /path/to/app:/app phpstan/phpstan analyse /app/src
Install PHPStan extensions #
If you need a PHPStan extension, for example phpstan/phpstan-phpunit, you can simply extend an existing image and add the relevant extension via Composer. In some cases you also need some additional PHP extensions like DOM. (see section below)
Here is an example Dockerfile for
RUN composer global require phpstan/phpstan-phpunit
You can update the
phpstan.neon file in order to use the extension:
Install PHP extensions #
Sometimes your codebase requires some additional PHP extensions like
intl or maybe
Therefore you need to know that our Docker image extends the official php:cli-alpine Docker image. So only the default built-in extensions are available (see below).
To solve this issue you can extend our Docker image in a custom Dockerfile like this, for example to add
RUN apk --update --progress --no-cache add icu-dev libxml2-dev \
&& docker-php-ext-install intl soap
Default built-in PHP extensions #
You can use the following command to determine which PHP extensions are already installed in the base image:
docker run --rm php:cli-alpine -m
This should give you an output like this: