Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

churn-php

> 开发工具
Open source

Discover files in need of refactoring.

1.4K stars0 likes2 views
WebsiteGitHub

About

Discover files in need of refactoring.

churn-php

Helps discover good candidates for refactoring.

Table of Contents

  • What Is it?
  • Compatibility
  • How to Install?
  • How to Use?
  • How to Configure?
  • Similar Packages
  • Contact
  • Contributing
  • License

What is it?

churn-php is a package that helps you identify php files in your project that could be good candidates for refactoring. It examines each PHP file in the path it is provided and:

  • Checks how many commits it has.
  • Calculates the cyclomatic complexity.
  • Creates a score based on these two values.

The results are displayed in a table:

A file that changes a lot and has a high complexity might be a better candidate for refactoring than a file that doesn't change a lot and has a low complexity.

churn-php only assists the developer to identify files for refactoring. It's best to use the results in addition to your own judgment to decide which files you may want to refactor.

Compatibility

  • PHP 7.1+
  • Composer 2.0+

How to Install?

Download the last release of churn.phar or install it with Phive:

bash
phive install churn

You can also install churn-php via Composer:

bash
composer require bmitch/churn-php --dev

How to Use?

bash
churn run <one or more paths to source code> ...
churn run src
churn run src tests

# the command name can be skipped if directoriesToScan is set in churn.yml
churn

How to Configure?

You may add an optional churn.yml file which can be used to configure churn-php. The location of this file can be customized using the --configuration option:

bash
# Default: "churn.yml" or "churn.yml.dist"
churn run --configuration=config-dir/ <path>
churn run --configuration=my-config.yml <path>

A sample churn.yml file looks like:

…

If a churn.yml file is omitted or an individual setting is omitted the default values above will be used.

Output formats

You can configure churn to output the result in different formats. The available formats are:

  • csv
  • json
  • markdown
  • text (default)

To use a different format use --format option. Example command for json:

bash
churn run --format json

Hooks

The hooks configuration allows you to customize churn.

A user-defined hook must implement at least one Hook interface:

Hook interface Corresponding event interface
AfterAnalysisHook AfterAnalysis
AfterFileAnalysisHook AfterFileAnalysis
BeforeAnalysisHook BeforeAnalysis

Similar Packages

  • https://github.com/danmayer/churn (Ruby)
  • https://github.com/chad/turbulence (Ruby)

Contact

Questions, comments, feedback? @bmitch2112

Contributing

  • Please run composer test on PHP 7.1 and ensure it passes.
  • If you don't have access to PHP 7.1 please make sure that CI build passes when you make pull request. If you are unable to get it to pass in the pull request please ping me and I can help.
  • Please see CONTRIBUTING.md

License

The MIT License (MIT). Please see License File for more information.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPclean-codecomplexitycontinuous-integrationidentify-files

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具