Copy/Paste Detector (CPD) for PHP code.

2.0.4 2016-04-17 19:32 UTC


Latest Stable Version Build Status

phpcpd is a Copy/Paste Detector (CPD) for PHP code.


PHP Archive (PHAR)

The easiest way to obtain PHPCPD is to download a PHP Archive (PHAR) that has all required dependencies of PHPCPD bundled in a single file:

chmod +x phpcpd.phar
mv phpcpd.phar /usr/local/bin/phpcpd

You can also immediately use the PHAR after you have downloaded it, of course:

php phpcpd.phar


Simply add a dependency on sebastian/phpcpd to your project's composer.json file if you use Composer to manage the dependencies of your project. Here is a minimal example of a composer.json file that just defines a development-time dependency on PHPCPD:

    "require-dev": {
        "sebastian/phpcpd": "*"

For a system-wide installation via Composer, you can run:

composer global require "sebastian/phpcpd=*"

Make sure you have ~/.composer/vendor/bin/ in your path.

Usage Example

➜ ~ phpcpd /tmp/wordpress-3.8.1/wp-includes
phpcpd 2.0.1 by Sebastian Bergmann.

Found 34 exact clones with 1273 duplicated lines in 11 files:

  - /tmp/wordpress-3.8.1/wp-includes/class-snoopy.php:165-195


  - /tmp/wordpress-3.8.1/wp-includes/SimplePie/Misc.php:1769-1830

0.86% duplicated lines out of 147877 total lines of code.

Time: 24.67 seconds, Memory: 159.00Mb