navisborealis/wonderwords-php
Composer 安装命令:
composer require navisborealis/wonderwords-php
包简介
Generate random words and sentences with ease in PHP.
README 文档
README
Wonderwords PHP
Generate random words, phrases and sentences with ease in PHP.
Installation
To install the package, run the following command:
composer require navisborealis/wonderwords-php
Usage
With this library you can generate:
- words - adjectives, nouns or verbs
- phrases - 1+ adjective and 1+ noun, like
Blushing Inspection - sentences - this feature is still in development
Phrases
Basic structure of the phrase is adjective noun. You can change:
- string separator, default
, - number of adjectives and nouns, default
1, - function used to modify the letters case, default
ucwords().
To use your own list of words see Changing default word list.
phrase( string $separator = ' ', int $numAdjectives = 1, int $numNouns = 1, callable $stringCaseFunction = null)
Generic, two word, space separated phrase
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator; echo WonderWordsGenerator::phrase(); // Output: Blushing Inspection
Custom separator
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator; echo WonderWordsGenerator::phrase('-'); // Output: Blushing-Inspection
Different number of adjectives and nouns
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator; echo WonderWordsGenerator::phrase(' ', 2, 3); // Output: Receptive Weary Disease Motive Vegetarian
Custom function to change letters casing
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator; echo WonderWordsGenerator::phrase(' ', 1, 1, 'strtoupper'); // Output: BLUSHING INSPECTION
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator; echo WonderWordsGenerator::phrase(' ', 1, 1, function ($phrase) { return ucfirst($phrase); }); // Output: Blushing inspection
Words
Generating words
From each category (Adjective, Noun, Verb) you can generate a single word:
use NavisBorealis\WonderwordsPhp\Words\Adjective; echo Adjective::randomWord(); // Output: various
or an array of words:
use NavisBorealis\WonderwordsPhp\Words\Adjective; $words = Adjective::randomWords(5); // ["innate", "noiseless", "screeching", "sloppy", "squeamish"]
Changing default word list
For each word category (Adjective, Noun, Verb) you can change the default word list:
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator; use NavisBorealis\WonderwordsPhp\Words\Adjective; Adjective::setWordList(['customadjective1', 'customadjective2']); echo WonderWordsGenerator::phrase(); // Output: Customadjective2 Inspection
also, you can reset word list to its defaults:
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator; use NavisBorealis\WonderwordsPhp\Words\Adjective; Adjective::setWordList(['customadjective1', 'customadjective2']); echo WonderWordsGenerator::phrase(); // Output: Customadjective2 Inspection Adjective::reset(); echo WonderWordsGenerator::phrase(); // Output: Scientific Inspection
Sentences
In development...
Credits
Wonderwords PHP is based on wonderwordsmodule python module and has been made possible thanks to the following works:
wonderwordsmodulefor python under the MIT Licenseprofanitylist.txtfrom RobertJGabriel/Google-profanity-words under the Apache-2.0 license- PhraseGenerator under the MIT License
- word-generator under the MIT license
navisborealis/wonderwords-php 适用场景与选型建议
navisborealis/wonderwords-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.06k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「word」 「phrase」 「noun」 「adjective」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 navisborealis/wonderwords-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 navisborealis/wonderwords-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 navisborealis/wonderwords-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Phrase Strings API Reference. Phrase Strings is a translation management platform for software projects. You can collaborate on language file translation with your team or order translations through our platform. The API allows you to import locale files, download locale files, tag keys or interact
Symfony Phrase Translation Provider Bridge
Laravel PhraseApp Package
Unofficial port of the Carbone API SDK to Saloon v3
Phalcon Model Generator
统计信息
- 总下载量: 1.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-07