GithubHelp home page GithubHelp logo

fortrabbit / phpco-docker Goto Github PK

View Code? Open in Web Editor NEW
56.0 7.0 13.0 11 KB

Simple docker build for running PHPCompatibility (https://github.com/PHPCompatibility/PHPCompatibility)

License: MIT License

Dockerfile 100.00%

phpco-docker's Introduction

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.

phpco-docker's People

Contributors

arkste avatar erinbit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpco-docker's Issues

Run out of memory

When running this instance on a huge project I'm getting a out of memory issue. Gonna provide PR for this.

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 16777224 bytes) in /usr/local/lib/php/PHP/CodeSniffer/src/Tokenizers/PHP.php on line 1449

Fatal error: Allowed memory size exhausted

Hi, how can I increase the memory limit?

phpco -p --colors --extensions=php --runtime-set testVersion 7.3 .             
............................................................   60 / 9997 (1%)
............................................................  120 / 9997 (1%)
............................................................  180 / 9997 (2%)
............................................................  240 / 9997 (2%)
............................................................  300 / 9997 (3%)
............................................................  360 / 9997 (4%)
............................................................  420 / 9997 (4%)
............................................................  480 / 9997 (5%)
............................................................  540 / 9997 (5%)
............................................................  600 / 9997 (6%)
............................................................  660 / 9997 (7%)
............................................................  720 / 9997 (7%)
............................................................  780 / 9997 (8%)
............................................................  840 / 9997 (8%)
.......................................W....................  900 / 9997 (9%)
............................................................  960 / 9997 (10%)
...................................................W........ 1020 / 9997 (10%)
...........................................W.............W.. 1080 / 9997 (11%)
..W......................................................... 1140 / 9997 (11%)
..W......................................................... 1200 / 9997 (12%)
............................................................ 1260 / 9997 (13%)
............................W............................... 1320 / 9997 (13%)
............................................................ 1380 / 9997 (14%)
............................................................ 1440 / 9997 (14%)
............................................................ 1500 / 9997 (15%)
............................................................ 1560 / 9997 (16%)
............................................................ 1620 / 9997 (16%)
............................................................ 1680 / 9997 (17%)
............................................................ 1740 / 9997 (17%)
............................................................ 1800 / 9997 (18%)
............................................................ 1860 / 9997 (19%)
............................................................ 1920 / 9997 (19%)
............................................................ 1980 / 9997 (20%)
............................................................ 2040 / 9997 (20%)
............................................................ 2100 / 9997 (21%)
............................................................ 2160 / 9997 (22%)
............................................................ 2220 / 9997 (22%)
............................................................ 2280 / 9997 (23%)
............................................................ 2340 / 9997 (23%)
............................................................ 2400 / 9997 (24%)
............................................................ 2460 / 9997 (25%)
............................................................ 2520 / 9997 (25%)
............................................................ 2580 / 9997 (26%)
................................................
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /usr/local/lib/php/PHP/CodeSniffer/src/Tokenizers/PHP.php on line 1326

Fatal error: Uncaught UnexpectedValueException: RecursiveDirectoryIterator

Hello,
I'm trying to use it but I have this error, do you have any idea of how to fix it please?
I'm under GNU/Linux Fedora 30.
I doesn't have recursive folders, I've also tested with an empty vendor/ folder.
I've tried to use the direct docker command too.
I've also tried the previous version 8.2.0

Regards,

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

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

Fatal error: Uncaught UnexpectedValueException: RecursiveDirectoryIterator::__construct(/mnt/src): failed to open dir: Permission denied in /usr/local/lib/php/PHP/CodeSniffer/src/Files/FileList.php:82
Stack trace:
#0 /usr/local/lib/php/PHP/CodeSniffer/src/Files/FileList.php(82): RecursiveDirectoryIterator->__construct('/mnt/src', 4608)
#1 /usr/local/lib/php/PHP/CodeSniffer/src/Runner.php(382): PHP_CodeSniffer\Files\FileList->__construct(Object(PHP_CodeSniffer\Config), Object(PHP_CodeSniffer\Ruleset))
#2 /usr/local/lib/php/PHP/CodeSniffer/src/Runner.php(114): PHP_CodeSniffer\Runner->run()
#3 /usr/local/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
#4 {main}
  thrown in /usr/local/lib/php/PHP/CodeSniffer/src/Files/FileList.php on line 82

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.