Skip to content

Docker container to check your application with PHPStan without require via composer.

Notifications You must be signed in to change notification settings

mablae/docker-image

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker image for PHPStan - PHP Static Analysis Tool

Build Status Docker Automated build Docker Stars Docker Pulls

The image is based on Alpine Linux and built daily.

Supported tags

How to use this image

Install

Install the container:

docker pull phpstan/phpstan

Alternatively, pull a specific version:

docker pull phpstan/phpstan:0.6

Usage

We are recommend to use the images as an shell alias to access via short-command. To use simply phpstan everywhere on CLI add this line to your ~/.zshrc, ~/.bashrc or ~/.profile.

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]

For example:

docker run --rm -v /path/to/app:/app phpstan/phpstan analyse /app/src

Customizing

Further PHP extension support

Sometimes your codebase requires some additional PHP extensions like "intl" or maybe "soap".

Therefore you need to know that our Docker image extends the official PHP 7.1 Docker image and so only a subset of configured extensions are available. Also because PHPStan needs no further extensions to run itself.

But to solve this issue you can extend our Docker image in an own Dockerfile like this, for example to add "soap" and "intl":

FROM phpstan/phpstan:latest
RUN apk add --no-cache --virtual .persistent-deps icu-dev libxml2-dev \
    && docker-php-ext-configure intl --enable-intl \
    && docker-php-ext-configure soap --enable-soap \
    && docker-php-ext-install intl \
    && docker-php-ext-install soap

Missing classes like "PHPUnit_Framework_TestCase"

Often you use PHAR files like PHPUnit in your projects. These PHAR files provide sometimes own classes where your project classes extends from. But these cannot be found in the vendor directory and so cannot be autoloaded. So you see error messages like this: "Fatal error: Class 'PHPUnit_Framework_TestCase' not found"

To solve this issue you need an own configuration file, like "phpstan.neon". This file can look like this:

parameters:
	autoload_files:
		- path/to/phpunit.phar

After creating this file in your project root you can run PHPStan for example via

docker run -v $PWD:/app --rm phpstan/phpstan -c phpstan.neon --level=4

and now the required classes are loaded. Please take also a look in the relevant part at the PHPStan documentation.

About

Docker container to check your application with PHPStan without require via composer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Makefile 100.0%