egbosionu/lara-http-enums
Composer 安装命令:
composer require egbosionu/lara-http-enums
包简介
A collection of HTTP-related PHP enums for Laravel applications
README 文档
README
A Laravel package for managing HTTP status codes, methods and other related HTTP enums.
Description
LaraHttpEnums is a simple, easy-to-use package that provides a collection of HTTP status codes, methods and related enums to be used in your Laravel projects. This package helps streamline working with HTTP-related constants, improving readability and consistency in your code.
Installation
You can install the package via Composer:
composer require egbosionu/lara-http-enums
Usage
HTTP Status Codes
use Egbosionu\LaraHttpEnums\StatusCode; // Basic usage $status = StatusCode::OK; // 200 $status = StatusCode::NOT_FOUND; // 404 // Get reason phrase $phrase = StatusCode::OK->getReasonPhrase(); // "OK" // Check status type $status = StatusCode::NOT_FOUND; $status->isClientError(); // true $status->isError(); // true $status->isSuccessful(); // false // Convert from integer $status = StatusCode::fromInt(404); // StatusCode::NOT_FOUND $status = StatusCode::tryFromInt(404); // StatusCode::NOT_FOUND or null if invalid // Convert from name $status = StatusCode::fromName('NOT_FOUND'); // StatusCode::NOT_FOUND $status = StatusCode::tryFromName('NOT_FOUND'); // StatusCode::NOT_FOUND or null if invalid
HTTP Methods
use Egbosionu\LaraHttpEnums\Method; // Basic usage $method = Method::GET; $method = Method::POST; // Check method properties $method = Method::GET; $method->isSafe(); // true - doesn't modify resources $method->isIdempotent(); // true - multiple identical requests have same effect as single request // Convert from string $method = Method::fromName('GET'); // Method::GET $method = Method::tryFromName('GET'); // Method::GET or null if invalid
Reason Phrases
use Egbosionu\LaraHttpEnums\ReasonPhrase; use Egbosionu\LaraHttpEnums\StatusCode; // Get reason phrase from status code $phrase = ReasonPhrase::fromStatusCode(StatusCode::NOT_FOUND); // ReasonPhrase::NOT_FOUND $text = ReasonPhrase::fromStatusCode(StatusCode::NOT_FOUND)->value; // "Not Found" // Try to get reason phrase $phrase = ReasonPhrase::tryFromStatusCode(StatusCode::NOT_FOUND); // ReasonPhrase::NOT_FOUND or null if invalid
Features
-
Type-safe HTTP status codes with integer values
-
Type-safe HTTP methods with string values
-
Standard reason phrases for all status codes
-
Helper methods for checking status code categories
-
Helper methods for checking method properties
-
Case-insensitive method name parsing
-
Null-safe conversion methods
-
Full PSR-4 autoloading support
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you discover any security-related issues, please email oegbosionu@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
egbosionu/lara-http-enums 适用场景与选型建议
egbosionu/lara-http-enums 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 02 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「laravel」 「enums」 「status-codes」 「http-methods」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 egbosionu/lara-http-enums 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 egbosionu/lara-http-enums 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 egbosionu/lara-http-enums 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Enums for Laravel Enso
Shared backed enums classifying HTML elements by category (block, inline, list, table, void, metadata, root) for the UI Awesome ecosystem.
Helpers for handling enums and enum translations in Laravel
A Laravel package that adds extra power to your PHP enums, and lets you use them in your frontend with type definitions.
A shared set of open-source enums for frequently used domains, helping reduce duplication and improve consistency across software projects.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-02