PHPackages                             systemsdk/phpcpd - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. systemsdk/phpcpd

ActiveLibrary[Testing &amp; Quality](/categories/testing)

systemsdk/phpcpd
================

Copy/Paste Detector for PHP code

v9.0.0(2mo ago)734.4k↑53.7%4BSD-3-ClausePHPPHP &gt;=8.4CI passing

Since Jan 12Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/systemsdk/phpcpd)[ Packagist](https://packagist.org/packages/systemsdk/phpcpd)[ Docs](https://github.com/systemsdk/phpcpd)[ Fund](https://secure.wayforpay.com/button/b0b1af16db515)[ RSS](/packages/systemsdk-phpcpd/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (12)Used By (4)

PHP Copy/Paste Detector
=======================

[](#php-copypaste-detector)

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

This is modified version of [sebastianbergmann/phpcpd](https://github.com/sebastianbergmann/phpcpd) due to `sebastianbergmann/phpcpd` is abandoned and no longer maintained.

[![PHP Copy/Paste Detector](https://github.com/systemsdk/phpcpd/actions/workflows/ci.yml/badge.svg)](https://github.com/systemsdk/phpcpd/actions/workflows/ci.yml)[![Coverage Status](https://camo.githubusercontent.com/b0e94d1825ecb674b5401efb9259d24e66d48d41000e5c909b6d7ceedb1b3aa6/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f73797374656d73646b2f7068706370642f62616467652e737667)](https://coveralls.io/github/systemsdk/phpcpd)[![MIT licensed](https://camo.githubusercontent.com/2b599ab1ace97388d4375b87919f92781a1a61d016fe640a5c4d15fc365deed1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253442d626c75652e737667)](LICENSE)

[Source code](https://github.com/systemsdk/phpcpd.git)

Requirements
------------

[](#requirements)

- PHP version 8.4 or later

Installation
------------

[](#installation)

### Using composer

[](#using-composer)

If you have installed composer, you can use the next cmd command:

```
composer require systemsdk/phpcpd --dev
```

### Manual installation

[](#manual-installation)

If you are not using composer, you have a possibility to download this tool.

Download the latest version [here](releases/) and put phar archive into your project.

Note: This tool is distributed as a [PHP Archive (PHAR)](https://php.net/phar).

Usage example
-------------

[](#usage-example)

```
$ php ./vendor/bin/phpcpd --fuzzy --verbose src tests
Copy/Paste Detector 9.0.0
14/14 [==============================>] 100% Loading & Processing
Found 1 code clones with 17 duplicated lines in 1 files:

  - /var/www/html/tests/Application/ApiKey/Transport/Controller/Api/v1/ApiKeyControllerTest.php:128-145 (17 lines)
    /var/www/html/tests/Application/ApiKey/Transport/Controller/Api/v1/ApiKeyControllerTest.php:153-170

    public function testThatFindOneActionForRootUserReturnsSuccessResponse(): void
    {
        $client = $this->getTestClient('john-root', 'password-root');

        $resource = static::getContainer()->get(ApiKeyResource::class);
        $apiKeyEntity = $resource->findOneBy([
            'description' => 'ApiKey Description: api',
        ]);
        self::assertInstanceOf(ApiKey::class, $apiKeyEntity);

        $client->request('GET', static::$baseUrl . '/' . $apiKeyEntity->getId());
        $response = $client->getResponse();
        $content = $response->getContent();
        self::assertNotFalse($content);
        self::assertSame(Response::HTTP_OK, $response->getStatusCode(), "Response:\n" . $response);
        $responseData = JSON::decode($content, true);
        $this->checkBasicFieldsInResponse($responseData);

0.05% duplicated lines out of 31339 total lines of code.
Average code clone size is 17 lines, the largest code clone has 17 lines

Time: 00:00.100, Memory: 10.00 MB

```

Note: If you are not using composer and have manual installation, you can use:

```
php phpcpd.phar --fuzzy --verbose src tests

```

Html report
-----------

[](#html-report)

You are able to generate html report, but you need to have installed [Xalan](https://xalan.apache.org) tool locally or inside your Docker container.

Please find more details how to generate/use it [here](https://github.com/systemsdk/phpcpd/blob/master/docs/report.md).

Suppressing False Positives
---------------------------

[](#suppressing-false-positives)

You can tell PHPCPD to ignore specific parts of your code using the `#[SuppressCpd]` attribute. This is particularly useful for generated code, large arrays, or boilerplate methods where duplication is intentional or unavoidable.

To use it, simply add the `#[SuppressCpd]` attribute directly above the class, method, or function you want to exclude from the analysis.

```
use Systemsdk\PhpCPD\Attributes\SuppressCpd;

#[SuppressCpd]
class LegacyDataFixtures
{
    // All methods and properties inside this class will be ignored
    // ...
}

#[SuppressCpd]
function globalHelperFunction() {
    // ...
}
```

Command-Line Options
--------------------

[](#command-line-options)

You can customize the behavior of PHPCPD using the following command-line options.

```
Options for selecting files:
--suffix    Include files with names ending on  (default: .php; can be given multiple times)
--exclude     Exclude files with  in their path (can be given multiple times)

Options for analysing files:
--algorithm   Select which algorithm to use ('rabin-karp' (default) or 'suffix-tree')
--fuzzy             Fuzz variable names
--min-lines      Minimum number of identical lines (default: 5)
--min-tokens     Minimum number of identical tokens (default: 70)
--edit-distance  Distance in number of edits between two clones (only for suffix-tree; default: 0)
--head-equality  Minimum equality at start of clone (only for suffix-tree; default 10)
--verbose           Print results details
--ignore-no-files   To return a success exit code if no files were found

Options for report generation:
--log-pmd     Write log in PMD-CPD XML format to

General options:
--version           Display version
--help              Display help
```

Requirements for the support team
---------------------------------

[](#requirements-for-the-support-team)

- Docker Engine version 23.0 or later
- Docker Compose version 2.0 or later
- An editor or IDE

Note: OS recommendation - Linux Ubuntu based.

Components for the support team
-------------------------------

[](#components-for-the-support-team)

1. PHP 8.5 fpm
2. Composer 2
3. Phive 0.16
4. Phing 3.1
5. Xalan 1.12

Setting up Docker and docker compose for the support team
---------------------------------------------------------

[](#setting-up-docker-and-docker-compose-for-the-support-team)

For installing Docker Engine with docker compose please follow steps mentioned on page [Docker Engine](https://docs.docker.com/engine/install/).

Note 1: Please run next cmd after above step if you are using Linux OS: `sudo usermod -aG docker $USER`

Note 2: If you are using Docker Desktop for MacOS 12.2 or later - please enable [virtiofs](https://www.docker.com/blog/speed-boost-achievement-unlocked-on-docker-desktop-4-6-for-mac/) for performance (enabled by default since Docker Desktop v4.22).

Setting up DEV environment for the support team
-----------------------------------------------

[](#setting-up-dev-environment-for-the-support-team)

1.Clone this repository from GitHub.

2.Edit and set `XDEBUG_CONFIG=` inside `.env` file (optional, by default `XDEBUG_CONFIG=main`).

3.Configure `/docker/dev/xdebug-main.ini` (Linux/Windows) or `/docker/dev/xdebug-osx.ini` (MacOS) (optional).

4.Build, start and install the docker images from your terminal:

```
make build-dev
make start
make setup
```

Getting shell to container for the support team
-----------------------------------------------

[](#getting-shell-to-container-for-the-support-team)

After application will start (`make start`) and in order to get shell access inside php container you can run the following command:

```
make ssh
```

Note: Please use `exit` command in order to return from container's shell to local shell.

Building container
------------------

[](#building-container)

In case you edited Dockerfile or other environment configuration, you'll need to build container again using next commands:

```
make down
make build-dev
make start
```

Start and stop environment containers for the support team
----------------------------------------------------------

[](#start-and-stop-environment-containers-for-the-support-team)

Please use next make commands in order to start and stop environment:

```
make start
make stop
```

Stop and remove environment containers, networks for the support team
---------------------------------------------------------------------

[](#stop-and-remove-environment-containers-networks-for-the-support-team)

Please use next make commands in order to stop and remove environment containers, networks:

```
make down
```

Additional main command available for the support team
------------------------------------------------------

[](#additional-main-command-available-for-the-support-team)

```
make build-dev

make start

make stop

make down

make restart

make ssh
make ssh-root

make setup

make update

make composer-audit

make info
make help

make phar
make signed-phar

make phpunit
make phpcs
make ecs
make ecs-fix
make phpstan

make phpcpd-run
make phpcpd-html-report

make logs

etc....
```

Notes: Please see more commands in Makefile

Architecture &amp; packages
---------------------------

[](#architecture--packages)

- [cli-parser](https://packagist.org/packages/sebastian/cli-parser)
- [version](https://packagist.org/packages/sebastian/version)
- [php-file-iterator](https://packagist.org/packages/phpunit/php-file-iterator)
- [php-timer](https://packagist.org/packages/phpunit/php-timer)
- [phpunit](https://packagist.org/packages/phpunit/phpunit)
- [composer-bin-plugin](https://packagist.org/packages/bamarni/composer-bin-plugin)
- [security-advisories](https://packagist.org/packages/roave/security-advisories)
- [easy-coding-standard](https://packagist.org/packages/symplify/easy-coding-standard)
- [phpstan](https://packagist.org/packages/phpstan/phpstan)
- [php-coveralls](https://github.com/php-coveralls/php-coveralls)

Guidelines for the support team
-------------------------------

[](#guidelines-for-the-support-team)

- [Report](https://github.com/systemsdk/phpcpd/blob/master/docs/report.md)
- [Schema](https://github.com/systemsdk/phpcpd/blob/master/docs/schema.md)
- [Phive](https://github.com/phar-io/phive)
- [Phing](https://www.phing.info)
- [Xalan](https://xalan.apache.org)

Working on the project for the support team
-------------------------------------------

[](#working-on-the-project-for-the-support-team)

1. For new feature development, fork `develop` branch into a new branch with one of the two patterns:
    - `feature/{ticketNo}`
2. Commit often and write descriptive commit messages, so it's easier to follow steps taken when reviewing.
3. Push this branch to the repo and create pull request into `develop` to get feedback, with the format `feature/{ticketNo}` - "Short descriptive title of Jira task".
4. Iterate as needed.
5. Make sure that "All checks have passed" on CircleCI(or another one in case you are not using CircleCI) and status is green.
6. When PR is approved, it will be squashed &amp; merged, into `develop` and later merged into `release/{No}` for deployment.

Note: You can find git flow detail example [here](https://danielkummer.github.io/git-flow-cheatsheet).

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance87

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 82.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~78 days

Recently: every ~73 days

Total

11

Last Release

71d ago

Major Versions

v7.0.1 → v8.0.02024-12-30

v8.3.0 → v9.0.02026-03-08

PHP version history (3 changes)v7.0.1PHP &gt;=8.1

v8.0.0PHP &gt;=8.3

v9.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/33e0fb1bc5cd58d4a1d671f46cd90d2d922ec5392f91b87ea346dcb82716b637?d=identicon)[dimadeush](/maintainers/dimadeush)

---

Top Contributors

[![sebastianbergmann](https://avatars.githubusercontent.com/u/25218?v=4)](https://github.com/sebastianbergmann "sebastianbergmann (416 commits)")[![olleharstedt](https://avatars.githubusercontent.com/u/607341?v=4)](https://github.com/olleharstedt "olleharstedt (29 commits)")[![aboks](https://avatars.githubusercontent.com/u/815524?v=4)](https://github.com/aboks "aboks (9 commits)")[![alexshadow007](https://avatars.githubusercontent.com/u/647552?v=4)](https://github.com/alexshadow007 "alexshadow007 (7 commits)")[![Ocramius](https://avatars.githubusercontent.com/u/154256?v=4)](https://github.com/Ocramius "Ocramius (6 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (6 commits)")[![edorian](https://avatars.githubusercontent.com/u/247397?v=4)](https://github.com/edorian "edorian (4 commits)")[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (3 commits)")[![kukulich](https://avatars.githubusercontent.com/u/260445?v=4)](https://github.com/kukulich "kukulich (2 commits)")[![globin](https://avatars.githubusercontent.com/u/1447245?v=4)](https://github.com/globin "globin (2 commits)")[![mrenrcert](https://avatars.githubusercontent.com/u/65898230?v=4)](https://github.com/mrenrcert "mrenrcert (2 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (2 commits)")[![SergeyZ](https://avatars.githubusercontent.com/u/92912310?v=4)](https://github.com/SergeyZ "SergeyZ (2 commits)")[![svemir](https://avatars.githubusercontent.com/u/154453?v=4)](https://github.com/svemir "svemir (2 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (1 commits)")[![lsv](https://avatars.githubusercontent.com/u/20708?v=4)](https://github.com/lsv "lsv (1 commits)")[![ajardin](https://avatars.githubusercontent.com/u/3305232?v=4)](https://github.com/ajardin "ajardin (1 commits)")[![oallain](https://avatars.githubusercontent.com/u/6593252?v=4)](https://github.com/oallain "oallain (1 commits)")[![gooh](https://avatars.githubusercontent.com/u/370948?v=4)](https://github.com/gooh "gooh (1 commits)")[![g-g](https://avatars.githubusercontent.com/u/765134?v=4)](https://github.com/g-g "g-g (1 commits)")

---

Tags

phpphpcpdPhp code quality toolCopy paste detector

### Embed Badge

![Health badge](/badges/systemsdk-phpcpd/health.svg)

```
[![Health](https://phpackages.com/badges/systemsdk-phpcpd/health.svg)](https://phpackages.com/packages/systemsdk-phpcpd)
```

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[phpunit/phpcov

CLI frontend for php-code-coverage

23721.1M583](/packages/phpunit-phpcov)[peridot-php/peridot

Event driven BDD test framework for PHP 7.1+

326194.6k128](/packages/peridot-php-peridot)[yegor256/phprack

Light framework for automation of integration tests

254.7k](/packages/yegor256-phprack)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
