定制 danilovl/helper-utils 二次开发

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

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

danilovl/helper-utils

Composer 安装命令:

composer require danilovl/helper-utils

包简介

Universal collection of helper utilities: dates, strings, arrays, files, network, reflection, hashing, colors and more.

README 文档

README

phpunit downloads latest Stable Version license

🛠️ Helper Utils

Universal collection of PHP 8.5+ helper utilities — dates, strings, arrays, files, network, reflection, hashing, colors, validation and more.

This is a standalone library, not a Symfony bundle. It does not require any framework configuration. Helpers that depend on the current time, timezone, or other side-effects either accept those as explicit method parameters (for static helpers) or are injected via constructor (for service helpers).

🚀 Key Features

  • Modern PHP: Strictly typed for PHP 8.5+.
  • Zero Configuration: Works out of the box in any project.
  • Framework Agnostic: Core logic is pure PHP, with optional integrations for Symfony components.
  • Testable: Design focuses on mockability and explicit state management.
  • Developer Experience: Consistent naming, clean API, and comprehensive documentation.

📦 Installation

composer require danilovl/helper-utils

🛠️ Included Helpers

Static Helpers

All helper classes are final with private constructors.

Group Classes Description
Array ArrayHelper, ArrayMapHelper, CollectionHelper Operations with arrays, mapping, filtering, and grouping.
Color ColorHelper Color manipulation and conversions (HEX, RGB).
Compare CompareHelper, VersionHelper Value and semantic version comparison utilities.
Date DateHelper, DatePeriodHelper, BusinessDayHelper Powerful date parsing, manipulation, and period calculations.
File FileHelper, PathHelper Filesystem operations, path handling, and metadata.
Form FormValidationMessageHelper Symfony Form error extraction and management.
Hash HashHelper, TokenHelper Secure hash generation and token utilities.
Json JsonHelper Safe JSON encoding and decoding.
Locale LocaleHelper, CountryHelper Geographic and linguistic data, country codes.
Network IpHelper, UrlHelper IP manipulation (anonymization, ranges) and URL handling.
Number NumberHelper, MoneyHelper Formatting numbers, currency, and byte sizes.
Object CloneHelper, ObjectHelper Deep cloning and dynamic property access.
Reflection ReflectionHelper, AttributeHelper, EnumHelper Advanced reflection for classes, attributes, and Enums.
String StringHelper, HtmlHelper, TextHelper String manipulation, slugging, masking, and HTML cleaning.
Validator ValidatorHelper Helpers for Symfony validation component.
Misc RetryHelper Miscellaneous utilities like retry logic.

Service Helpers

DI-injectable, final readonly where stateless.

  • ClockAwareDateHelper: Time-sensitive operations using PSR-20 Clock.
  • DoctrineHelper: Doctrine ORM metadata and entity manager shortcuts.
  • MemoryHelper: Real-time memory usage tracking and formatting.
  • RequestHelper: Convenient wrapper for Symfony's Request objects.
  • TimerHelper: Precise code execution timing and measurement.

Enums

  • ByteUnit: Constants for data size units (B, KB, MB, etc.).
  • ComparisonOperator: Common comparison operators for flexible logic.
  • DateFormat: Standardized date and time format strings.

💡 Quick Examples

Static Helpers

use Danilovl\HelperUtils\Helper\Date\DateHelper;
use Danilovl\HelperUtils\Helper\String\StringHelper;
use Danilovl\HelperUtils\Helper\Network\IpHelper;

// Dates — explicit "now" for testability
$age  = DateHelper::calculateAge(new DateTimeImmutable('1990-04-25'));
$past = DateHelper::isPast($someDate, $now);

// Strings
$slug = StringHelper::slugify('Привет, мир!');           // "privet-mir"
$mask = StringHelper::maskEmail('john.doe@example.com'); // "j******e@example.com"

// IP Utilities
$ok   = IpHelper::isIpInRange('192.168.1.5', '192.168.1.0/24');
$anon = IpHelper::anonymize('192.168.1.123');             // "192.168.1.0"

Services (Dependency Injection)

use Danilovl\HelperUtils\Service\RequestHelper;
use Danilovl\HelperUtils\Service\ClockAwareDateHelper;

public function __construct(
    private RequestHelper $requestHelper,
    private ClockAwareDateHelper $clock,
) {}

$ip  = $this->requestHelper->getClientIp();
$now = $this->clock->now(); // Easily mockable

🧪 Quality Assurance

We maintain high testing standards to ensure reliability.

composer tests

The package currently includes 397 unit tests and 766 assertions.

Test Coverage

Group Status
Array, Color, Compare, Date, File, Hash, Json, Locale, Network, Number, Object, Reflection, String, Validator, Misc ✅ Full
Service (Request, Clock, Doctrine, Memory, Timer) ✅ Full

📜 Design Principles

  • Immutability: Preference for \DateTimeImmutable.
  • Explicitness: "Now"-dependent methods accept an explicit timestamp.
  • Safety: Methods follow the doSomething (throws) / trySomething (returns null) pattern.
  • Non-Invasive: Wraps powerful libraries (Symfony, Doctrine) rather than reinventing wheels.
  • Finality: Classes are final to prevent fragile inheritance.

📄 License

The HelperUtils is open-sourced software licensed under the MIT license.

danilovl/helper-utils 适用场景与选型建议

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

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

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

围绕 danilovl/helper-utils 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-25