oihana/php-enums 问题修复 & 功能扩展

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

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

oihana/php-enums

最新稳定版本:1.0.0

Composer 安装命令:

composer require oihana/php-enums

包简介

A collection of strongly-typed constant enumerations for PHP

README 文档

README

Oihana Php Core

A collection of strongly-typed constant enumerations for PHP.

Latest Version
Total Downloads
License

Oihana PHP Enums is a lightweight PHP library providing a set of well-structured enumerations implemented as constant classes. Each enumeration groups related symbolic values to replace hardcoded strings or numbers, improving readability, consistency, and typo safety across your codebase.

This package is designed to be framework-agnostic, fully compatible with PHP 8.4+, and works seamlessly with the ConstantsTrait for reflection and dynamic constant access.

📚 Documentation

Full documentation: https://bcommebois.github.io/oihana-php-enums

📦 Installation

Requires PHP 8.4+. Install via Composer:

composer require oihana/php-enums

✨ What you can do

  • 📦 Multiple enumerations for different domains (e.g. Boolean, Char, IniOptions, and more).
  • 🔍 Reflection-ready with ConstantsTrait for listing or validating values.
  • 🛡️ Reduces “magic strings” and improves semantic clarity.
  • 🧩 Easily reusable in any PHP application or framework.
  • ⚡ No external dependencies except Oihana’s reflection utilities.

🚀 Quick Start

use oihana\enums\Boolean;
use oihana\enums\Char;
use oihana\enums\IniOptions;

// Boolean values as strings
$enabled = Boolean::TRUE; // 'true'

// Character constants
echo 'A' . Char::DOT . 'B'; // Outputs: A.B

// Ini options
ini_set(IniOptions::DISPLAY_ERRORS, '1');

✅ Running Unit Tests

To run all tests:

$ composer test

To run a specific test file:

$ composer test tests/oihana/enums/BooleanTest.php

🧾 License

This project is licensed under the Mozilla Public License 2.0 (MPL-2.0).

👤 About the author

🔗 Related packages

  • oihana/php-core – core helpers and utilities used by this library: https://github.com/BcommeBois/oihana-php-core
  • oihana/php-reflect – reflection and hydration utilities: https://github.com/BcommeBois/oihana-php-reflect

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MPL-2.0
  • 更新时间: 2025-08-13