定制 voral/vinc-file-version-regexp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

voral/vinc-file-version-regexp

Composer 安装命令:

composer require voral/vinc-file-version-regexp

包简介

An extension for voral/version-increment to update version strings in custom files using regular expressions.

README 文档

README

RU

PHP Tests Code Coverage Scrutinizer Code Quality

An extension for voral/version-increment to update version strings in custom files using regular expressions.

This tool allows you to automatically update version numbers in arbitrary files (e.g., PHP, JSON, XML) during the versioning process. It integrates seamlessly with the voral/version-increment package and listens to the BEFORE_VERSION_SET event to perform replacements based on a provided regular expression.

Key Features

  • Custom File Support: Update version strings in any file format using flexible regular expressions.
  • Event-Based Integration: Listens to the BEFORE_VERSION_SET event from voral/version-increment.
  • Error Handling with Unique Codes: Prevents conflicts between multiple extensions by supporting error code deltas.
  • Flexible Configuration: Define custom regular expressions to match version strings in various formats.
  • Extensibility: Easily integrate into existing workflows with minimal configuration.

Installation

Install the package via Composer:

composer require --dev voral/vinc-file-version-regexp

Usage

To use this extension, configure it in your .vs-version-increment.php file by adding a listener for the BEFORE_VERSION_SET event. Here's an example:

use Vasoft\VersionIncrement\Config;
use Vasoft\VersionIncrement\Events\EventType;
use Vasoft\VersionIncrement\Extension\RegexpFileModifier;

$config = (new Config());
$config->getEventBus()->addListener(
        EventType::BEFORE_VERSION_SET,
        new RegexpFileModifier(
            './src/version.php',
            '#(\$version\s*=\s*\'|"v)\d+\.\d+\.\d+(\'|";)#s'
        )
    );


return $config;

Explanation:

  • File Path: Specify the path to the file where the version string should be updated (e.g., ./src/version.php).
  • Regular Expression: Provide a regex pattern to locate the version string. The pattern must include:
    • Group 1: The part of the string before the version.
    • Group 2: The part of the string after the version.
  • Error Code Delta: Optionally, specify a delta value to ensure unique error codes when using multiple extensions.

Example Use Cases

1. Updating a PHP File

If your project contains a version.php file like this:

<?php $version = "Version 1.0.0"; ?>

The extension will update it to:

<?php $version = "Version 2.0.0"; ?>

2. Updating a JSON File

For a config.json file:

{
  "version": "1.0.0"
}

The extension can update it to:

{
  "version": "2.0.0"
}

Error Handling

The extension provides detailed error messages and unique error codes to help diagnose issues:

  • FileNotFoundException: Thrown if the specified file does not exist.
  • FileNotWritableException: Thrown if the file is not writable.
  • PatternNotFoundException: Thrown if the regular expression does not match any part of the file content.

Error codes are offset by a configurable errorCodeDelta to avoid conflicts with other extensions.

Configuration Options

You can customize the behavior of the extension by adjusting its parameters:

Parameter Description
filePath The path to the file where the version will be updated.
regexp The regular expression used to locate the version string.
errorCodeDelta Optional delta value to ensure unique error codes across multiple modules.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a clear description of your changes.

Ensure that your code adheres to the project's coding standards and includes appropriate tests.

Testing

Run the following commands to test the package:

composer test

Generate a code coverage report:

composer coverage

Perform static analysis:

composer stan

Check coding standards:

composer fixer

Run all checks at once:

composer check

License

This package is licensed under the MIT License. See the LICENSE file for details.

Useful Links

voral/vinc-file-version-regexp 适用场景与选型建议

voral/vinc-file-version-regexp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「version control」 「semantic versioning」 「PHP Library」 「commit analysis」 「version management」 「php tool」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 voral/vinc-file-version-regexp 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-22