originphp/inflector
Composer 安装命令:
composer require originphp/inflector
包简介
OriginPHP Inflector
关键字:
README 文档
README
The Inflector class changes words from singular to plural or vice versa, and it also changes cases of words as well.
Installation
To install this package
$ composer require originphp/inflector
Converting Singular & Plural
To convert words to their singular or plural form
Converting
use Origin\Inflector\Inflector; $singular = Inflector::singular('apples'); // apple $plural = Inflector::plural('apple'); // apples
Rules
The Inflector comes with a some standard rules which cover most words and is a good starting point for a project, however occasionally you might need to add a custom rule.
In your bootstrap/configuration
use Origin\Inflector\Inflector; // regex or string Inflector::rules('singular',[ '/(quiz)zes$/i' => '\\1' ]); // regex or string Inflector::rules('plural',[ '/(quiz)$/i' => '\1zes' ]); // string only Inflector::rules('uncountable',['sheep']); // string only Inflector::rules('irregular',[ 'child' => 'children' ]);
Singular and plural rules can be both strings or regex expressions
use Origin\Inflector\Inflector; Inflector::rules('singular',['fezzes'=>'fez']); Inflector::rules('plural',['fez'=>'fezzes']);
Changing Cases
To change cases of words
use Origin\Inflector\Inflector; // change underscored words $studyCaps = Inflector::studlyCaps('big_tree') ; // BigTree $camelCase = Inflector::camelCase('big_tree') ; // bigTree $human = Inflector::human('big_tree'); // Big Tree // Change studly capped words $underscored = Inflector::underscored('BigTree'); // big_tree
The Inflector also has these two methods which OriginPHP also uses to do its magic.
// converts class name into into table name (plural underscored) $tableName = Inflector::tableName('BigTree'); // big_trees // converts table names (plural underscored) into a class name $className = Inflector::className('big_trees'); // BigTree
originphp/inflector 适用场景与选型建议
originphp/inflector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.33k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 10 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「underscore」 「inflector」 「inflection」 「camelcase」 「plural」 「singular」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 originphp/inflector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 originphp/inflector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 originphp/inflector 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Czech inflection library
GOintegro Inflector Lib
A functional programming library for PHP. Inspired by Underscore, Lodash, and Ramda.
Inflector Library
Manipulate arrays similar to Ruby.
A redacted port of Underscore.js for PHP
统计信息
- 总下载量: 12.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 24
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-15