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
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_SETevent fromvoral/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:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- 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/version-increment: The main package this extension integrates with.
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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 voral/vinc-file-version-regexp 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An extension to Semantic MediaWiki allowing to build breadcrumb links from an attributive property filter
Versioning behaviour for eloquent models
Minimal CSS Framework for semantic HTML.
Adds the EDTF data type to Wikibase
Converts SemVer version (like Composer packages) into integer version with operators. Helps managing versions: store, compare, sort and retrive by conditions.
Provide a way to secure accesses to all routes of an symfony application.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-22