Code Monkey home page Code Monkey logo

phpco-docker's Introduction

phpco

An installation of PHP7 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 7.2 compatibility.

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

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 7.2 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.