xavierleune/php-changelog-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xavierleune/php-changelog-generator

Composer 安装命令:

composer require xavierleune/php-changelog-generator

包简介

PHP tool to detect API changes and generate changelog with SemVer compliance

README 文档

README

A PHP tool to automatically detect API changes between two versions of a PHP project and generate a changelog following SemVer principles.

Features

  • ✅ Analysis of public elements only (classes, interfaces, methods, functions, constants)
  • ✅ Support for native PHP signatures and PHPDoc
  • ✅ Detection of compatible/incompatible changes
  • ✅ Automatic SemVer recommendations (major/minor/patch)
  • ✅ Markdown changelog generation
  • ✅ Support for exclusion patterns
  • ✅ Compatible with PHP 7.4+ for analysis, PHP 8.3+ for execution

Installation

composer install

Usage

Basic command

./bin/changelog-generator /path/to/old/version /path/to/new/version

Available options

./bin/changelog-generator old-path new-path [options]

Arguments:
  old-path              Path to the old version of the codebase
  new-path              Path to the new version of the codebase

Options:
  -o, --output=OUTPUT            Output file for the changelog [default: "CHANGELOG.md"]
  -c, --current-version=VERSION  Current version number [default: "1.0.0"]
  -i, --ignore=IGNORE            Patterns to ignore (supports wildcards) [default: ["*/vendor/*", "*/tests/*", "*/test/*"]] (multiple values allowed)
  -f, --format=FORMAT            Output format (markdown, json) [default: "markdown"]
      --dry-run                  Show changes without writing to file
      --strict-semver            Use strict SemVer rules (breaking changes = major even for pre-1.0.0)
  -q, --quiet                    Shows only recommended version and/or errors

Examples

# Generate a basic changelog
./bin/changelog-generator ./v1.0.0 ./v1.1.0

# Specify current version and output file
./bin/changelog-generator ./v1.0.0 ./v1.1.0 -v 1.0.0 -o CHANGELOG.md

# Ignore specific folders
./bin/changelog-generator ./v1.0.0 ./v1.1.0 -i "*/vendor/*" -i "*/tests/*" -i "*/examples/*"

# Generate a JSON report
./bin/changelog-generator ./v1.0.0 ./v1.1.0 -f json -o report.json

# Preview without writing to file
./bin/changelog-generator ./v1.0.0 ./v1.1.0 --dry-run

# Use strict SemVer for pre-1.0.0 versions
./bin/changelog-generator ./v0.1.0 ./v0.2.0 --current-version 0.1.0 --strict-semver

SemVer Rules

Major Changes (Breaking Changes)

  • Removed methods/functions
  • Incompatible signatures (required parameters added, types changed)
  • Removed classes/interfaces
  • Modified/removed constants
  • Restrictive visibility changes

Minor Changes (Backward Compatible)

  • New methods/functions/classes
  • Optional parameters added
  • New implemented interfaces
  • New constants

Patch Changes

  • PHPDoc modifications without signature impact
  • Internal changes without public API impact

Pre-1.0.0 SemVer Behavior

By default, for versions before 1.0.0 (e.g., 0.x.y), this tool follows a relaxed SemVer approach:

  • Breaking changes (normally major) are treated as minor changes
  • New features remain minor changes
  • Bug fixes remain patch changes

This reflects the common practice that pre-1.0.0 versions are in development and breaking changes are expected.

Strict SemVer Mode

Use the --strict-semver flag to enforce standard SemVer rules even for pre-1.0.0 versions:

# Relaxed mode (default): 0.1.0 + breaking changes = 0.2.0
./bin/changelog-generator ./v0.1.0 ./v0.2.0 --current-version 0.1.0

# Strict mode: 0.1.0 + breaking changes = 1.0.0
./bin/changelog-generator ./v0.1.0 ./v0.2.0 --current-version 0.1.0 --strict-semver

PHPDoc Analysis

The tool prioritizes native PHP signature analysis but uses PHPDoc as fallback:

  • If PHP signature is typed → uses the signature
  • If only PHPDoc is typed → uses PHPDoc
  • In case of conflict → logs a warning and uses the signature

Architecture

src/
├── Model/          # Data models (ApiElement, ApiChange, etc.)
├── Parser/         # PHP parser (nikic/php-parser + PHPDoc)
├── Differ/         # Version comparator
├── Analyzer/       # SemVer analysis
├── Generator/      # Changelog generator
└── Console/        # CLI interface

Development

Tests

composer test

Code standards

composer cs-check  # Check
composer cs-fix    # Fix

Static analysis

composer phpstan

License

MIT

xavierleune/php-changelog-generator 适用场景与选型建议

xavierleune/php-changelog-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 xavierleune/php-changelog-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 xavierleune/php-changelog-generator 我们能提供哪些服务?
定制开发 / 二次开发

基于 xavierleune/php-changelog-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 26
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-21