Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

fortrabbit/phpco-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

phpco

⚠️ Unmaintained and archived!

An installation of PHP8 and PHP Compatibility in a small Alpine Linux Docker image.

PHPCompatibility

PHPCompatibility is built as a code standard for the phpcs command. It searches your code for patterns matching a long list of deprecated functions and use cases. It gives very direct instructions about what might be deprecated, wrong or risky with your code on any specified PHP version.

Motivations

Using PHPCompatibility requires you to first install PHP CodeSniffer globally and then configure PHPCompatibility as the code standard to use. We find that the easiest way to run it is with Docker, since that cleanly separates your local PHP setup from the tool.

Getting phpco-docker

The easiest way is to create a shell function for phpco. No need to clone this repository. First make sure you have Docker installed on your machine. Then execute this in your local terminal:

phpco() { docker run --init -v $PWD:/mnt/src:cached --rm -u "$(id -u):$(id -g)" frbit/phpco:latest $@; return $?; }

You can also add this snippet to your .bashrc or similar shell startup script. That way it will always be available whenever you open a new shell.

Running phpco-docker

Now you can directly use the tool. This command will do a full check of all your code in the current directory for PHP 8.0 compatibility.

phpco -p --colors --extensions=php --runtime-set testVersion 8.0 .

As it completes you will see a list of found warnings and errors in your code. If you are getting a lot of warnings, but only want to deal with the stuff that will actually break, add -n to only show errors.

If you have also updated all of your dependencies and are sure they support the PHP version you want to migrate to, you can exclude the vendor folder completely to only check your own code. Checking for PHP version 8.0 is the default so we can also remove that part.

phpco -p --colors --extensions=php . -n --ignore="vendor/"

Remember: Since this is running within a docker container, the paths to your source files will start with /mnt/src/ instead of the actual absolute path on your host computer.

Read more about available flags specific to PHP Compatibility and about the underlying options for PHP CodeSniffer.

Releases

No releases published

Packages

 
 
 

Contributors 3

  •  
  •  
  •