crypto_scythe/http_generator
Composer 安装命令:
composer require crypto_scythe/http_generator
包简介
HTTP header fields, media types and status codes
README 文档
README
This generator can be used to create PHP classes with constants for HTTP header fields, status codes and media types.
The data source is the JSON output from https://webconcepts.info which provides extensive information about the underlying concepts including links to specifications of all provided header fields, status codes and media types.
Installation with Composer
composer require crypto_scythe/http_generator --dev
Usage
./vendor/bin/http_generate.php "My\\Wanted\\Namespace" ./src/My/Wanted/Namespace
After running the command three files will be created:
HeaderFields.phpMediaTypes.phpStatusCodes.php
Every file contains constants which can be used for convenience and looking up the underlying concepts regarding them.
Example for AuthenticationSchemes.php
/** * Authentication scheme Basic * * The Basic authentication scheme is based on the model that the client needs to authenticate itself with a * user-id and a password for each protection space ("realm"). The realm value is a free-form string that can * only be compared for equality with other realms on that server. * * @see https://webconcepts.info/specs/IETF/RFC/7617 * @see https://datatracker.ietf.org/doc/html/rfc7617#section-2 */ public const BASIC = 'Basic';
Example for CacheDirectives.php
/** * Cache directive max-age * * The "max-age" request directive indicates that the client is unwilling to accept a response whose age is * greater than the specified number of seconds. Unless the max-stale request directive is also present, the * client is not willing to accept a stale response. The "max-age" response directive indicates that the * response is to be considered stale after its age is greater than the specified number of seconds. * * @see https://webconcepts.info/specs/IETF/RFC/7234 * @see https://datatracker.ietf.org/doc/html/rfc7234#section-5.2.1.1 */ public const MAX_AGE = 'max-age';
Example for ContentCodings.php
/** * Content coding gzip * * The "gzip" coding is an LZ77 coding with a 32-bit Cyclic Redundancy Check (CRC) that is commonly produced by * the gzip file compression program. A recipient SHOULD consider "x-gzip" to be equivalent to "gzip". * * @see https://webconcepts.info/specs/IETF/RFC/7230 * @see https://datatracker.ietf.org/doc/html/rfc7230#section-4.2.3 */ public const GZIP = 'gzip';
Example for ForwardedParameters.php
/** * Forwarded parameter for * * The "for" parameter is used to disclose information about the client that initiated the request and * subsequent proxies in a chain of proxies. * * @see https://webconcepts.info/specs/IETF/RFC/7239 * @see https://datatracker.ietf.org/doc/html/rfc7239#section-5.2 */ public const FOR = 'for';
Example for HeaderFields.php
/** * Header field Content-Type * * The "Content-Type" header field indicates the media type of the associated representation: either the * representation enclosed in the message payload or the selected representation, as determined by the message * semantics. The indicated media type defines both the data format and how that data is intended to be * processed by a recipient, within the scope of the received message semantics, after any content codings * indicated by Content-Encoding are decoded. * * @see https://webconcepts.info/specs/IETF/RFC/7231 * @see https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.5 */ public const CONTENT_TYPE = 'Content-Type';
Example for LinkRelations.php
/** * Link relation canonical * * The target (canonical) IRI MUST identify content that is either duplicative or a superset of the content at * the context (referring) IRI. * * @see https://webconcepts.info/specs/IETF/RFC/6596 * @see https://datatracker.ietf.org/doc/html/rfc6596#section-3 */ public const CANONICAL = 'canonical';
Example for MediaTypes.php
/** * Media type application/json * * JavaScript Object Notation (JSON) is a text format for the serialization of structured data. It is derived * from the object literals of JavaScript, as defined in the ECMAScript Programming Language Standard, Third * Edition. * * @see https://webconcepts.info/specs/IETF/I-D/ietf-jsonbis-rfc7159bis * @see https://datatracker.ietf.org/doc/html/draft-ietf-jsonbis-rfc7159bis#section-1 * * JavaScript Object Notation (JSON) is a text format for the serialization of structured data. It is derived * from the object literals of JavaScript, as defined in the ECMAScript Programming Language Standard, Third * Edition. JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured * types (objects and arrays). * * @see https://webconcepts.info/specs/IETF/RFC/8259 * @see https://datatracker.ietf.org/doc/html/rfc8259#section-1 */ public const APPLICATION_JSON = 'application/json';
Example for Preferences.php
/** * Preference wait * * The "wait" preference can be used to establish an upper bound on the length of time, in seconds, the client * expects it will take the server to process the request once it has been received. * * @see https://webconcepts.info/specs/IETF/RFC/7240 * @see https://datatracker.ietf.org/doc/html/rfc7240#section-4.3 */ public const WAIT = 'wait';
Example for RangeUnits.php
/** * Range unit bytes * * Since representation data is transferred in payloads as a sequence of octets, a byte range is a meaningful * substructure for any representation transferable over HTTP. The "bytes" range unit is defined for expressing * subranges of the data's octet sequence. * * @see https://webconcepts.info/specs/IETF/RFC/7233 * @see https://datatracker.ietf.org/doc/html/rfc7233#section-2.1 */ public const BYTES = 'bytes';
Example for RequestMethods.php
/** * Request method GET * * The GET method requests transfer of a current selected representation for the target resource. GET is the * primary mechanism of information retrieval and the focus of almost all performance optimizations. Hence, when * people speak of retrieving some identifiable information via HTTP, they are generally referring to making a * GET request. * * @see https://webconcepts.info/specs/IETF/RFC/7231 * @see https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.1 */ public const GET = 'GET';
Example for StatusCodes.php
/** * Status code 404 * * The 404 (Not Found) status code indicates that the origin server did not find a current representation for * the target resource or is not willing to disclose that one exists. A 404 status code does not indicate * whether this lack of representation is temporary or permanent; the 410 (Gone) status code is preferred over * 404 if the origin server knows, presumably through some configurable means, that the condition is likely to * be permanent. * * @see https://webconcepts.info/specs/IETF/RFC/7231 * @see https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4 */ public const STATUS_404 = 404; public const MESSAGE_404 = 'Not Found'; public const STATUS_NOT_FOUND = self::STATUS_404; public const MESSAGE_NOT_FOUND = self::MESSAGE_404;
Example for TransferCodings.php
/** * Transfer coding chunked * * The chunked transfer coding wraps the payload body in order to transfer it as a series of chunks, each with * its own size indicator, followed by an OPTIONAL trailer containing header fields. Chunked enables content * streams of unknown size to be transferred as a sequence of length-delimited buffers, which enables the sender * to retain connection persistence and the recipient to know when it has received the entire message. * * @see https://webconcepts.info/specs/IETF/RFC/7230 * @see https://datatracker.ietf.org/doc/html/rfc7230#section-4.1 */ public const CHUNKED = 'chunked';
crypto_scythe/http_generator 适用场景与选型建议
crypto_scythe/http_generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「media」 「http」 「code」 「type」 「headers」 「header」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 crypto_scythe/http_generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 crypto_scythe/http_generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 crypto_scythe/http_generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
repository php library
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
Laravel Media Popup to upload/view the files
Promotional Codes Generator for Laravel 5.1
Asset Manager Laravel package for Gigcodes UI Library
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-29