Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpcpd Laravel Package

sebastian/phpcpd

PHPCPD is a copy/paste detector for PHP that finds duplicated code (clones) across files and reports duplicate lines and locations. Distributed as a PHAR and installable via Phive. Note: this project is unmaintained and archived.

View on GitHub
Deep Wiki
Context7

Getting Started

PHPCPD is an archived, no-longer-maintained CLI tool for detecting copy-paste duplicates in PHP code. To begin:

  1. Install via PHIVE: phive install phpcpdnever use Composer, per the author’s recommendation.
  2. Run a quick scan on your Laravel app’s app/ directory: ./tools/phpcpd app/
  3. Focus first on the summary metrics: % duplicated lines and Average size of duplication. Values >1–2% duplication or clones >50 lines are strong refactoring candidates.

Implementation Patterns

  • CI Gatekeeping: Integrate as a non-blocking pre-commit check or a soft CI step with --fail threshold only on new code (e.g., phpcpd --minimum-lines 15 app/ && php phpunit.xml --testdox), or use --dry-run to report without exit code impact.
  • Targeted scanning: Leverage --exclude to omit tests/, database/, and vendor/, and --suffixes .php to avoid non-PHP noise.
  • Team feedback loops: Generate XML via --log-pmd cpd.xml and feed into IDE plugins (e.g., PHPStorm’s built-in CPD viewer) or dashboards like SonarQube for recurring visibility.
  • Adoption ramp-up: Start by scanning new feature modules only; once patterns stabilize, expand gradually—avoid scanning legacy monoliths whole to prevent overwhelming teams.

Gotchas and Tips

  • Archived status = zero support: Since 2022, there are no updates for PHP 8.2/8.3 breaking changes. Always validate with php -v and consider maintaining a fork for critical fixes.
  • Memory hogs: Large apps (e.g., Laravel apps with 1000+ files) may hit limits; override with php -d memory_limit=2G ./tools/phpcpd app/.
  • Fuzzy ≠ smart: --fuzzy catches “almost identical” clones (e.g., changed variable names), but may flag legitimate factory patterns. Use --minimum-lines 20 to ignore small boilerplate snippets.
  • False confidence risk: A clean CPD scan ≠ no duplication; many patterns (e.g., Laravel macros, traits) intentionally duplicate behavior. Treat CPD as one signal among many—not a correctness oracle.
  • CLI friction: PHPCPD’s outdated sebastian/cli-parser can conflict with other CLI tools using symfony/console 6+. Run via isolated PHAR to avoid version skew in global toolchains.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport