Download the PHP package navisborealis/wonderwords-php without Composer
On this page you can find all versions of the php package navisborealis/wonderwords-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download navisborealis/wonderwords-php
More information about navisborealis/wonderwords-php
Files in navisborealis/wonderwords-php
Package wonderwords-php
Short Description Generate random words, phrases, and grammatically correct sentences in PHP. Perfect for seeding databases with realistic test data.
License MIT
Homepage https://github.com/navisborealis/wonderwords-php
Informations about the package wonderwords-php
Wonderwords PHP
Generate random words, phrases, and grammatically correct english sentences in PHP. Perfect for seeding databases with realistic test data, generating memorable usernames, providing default names or URL slugs for new entities (projects, workspaces, groups), or building randomized bots.
Table of Contents
- Quick Start
- Installation
- Usage
- Phrases
- Words
- Sentences
- Profanity Filtering
- FakerPHP Integration
- Contributing
- Credits
- License
Installation
To install the package, run the following command:
Quick Start
Usage
Generate:
- words - adjectives, nouns, verbs, adverbs, animals, colors, names, and tech terms
- phrases - 1+ adjective and 1+ noun, like
Blushing Inspection - sentences - grammatically correct simple and bare-bone sentences
Phrases
The phrase structure 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 custom words, see Changing default word list.
Two-word phrase
Custom separator
Change adjective and noun count
Custom casing function
Words
Generating words
Generate random words using the WonderWordsGenerator helper methods, or by interacting with the specific dictionary classes directly:
Username Generation
Combining specific categories like Colors and Animals is perfect for generating memorable, anonymous usernames or default avatars:
Generating multiple words
To generate an array of multiple words, use the underlying dictionary classes:
Changing default word list
Change the default word list per category:
Reset the word list:
Advanced Filtering
Filter words by length, starting/ending letters, or regex. Pass an options array to randomWord() or randomWords():
Sentences
Use WonderWordsSentence to generate grammatically sound sentences containing randomly generated adjectives, nouns, adverbs, and verbs.
You can also pass filtering options (just like randomWord) directly into sentence generators:
Profanity Filtering
Check strings for profanity or filter out profane words from arrays:
FakerPHP Integration
If you use FakerPHP, you can register WonderWords as a custom provider to generate words, phrases, and sentences directly from your $faker instance.
Available methods:
wonderWordsAdjective(array $options = [])wonderWordsAdverb(array $options = [])wonderWordsAnimal(array $options = [])wonderWordsColor(array $options = [])wonderWordsName(array $options = [])wonderWordsFirstName(array $options = [])wonderWordsLastName(array $options = [])wonderWordsNoun(array $options = [])wonderWordsProfanity(array $options = [])wonderWordsTechTerm(array $options = [])wonderWordsVerb(array $options = [])wonderWordsPhrase(string $separator = ' ', int $numAdjectives = 1, int $numNouns = 1, ?callable $stringCaseFunction = null)wonderWordsBareBoneSentence(array $nounOptions = [], array $verbOptions = [], array $adjectiveOptions = [], array $adverbOptions = [])wonderWordsSimpleSentence(array $nounOptions = [], array $verbOptions = [], array $adjectiveOptions = [], array $adverbOptions = [])
Credits
Wonderwords PHP ports the Python wonderwordsmodule and uses these projects:
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
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
See CONTRIBUTING.md for details on running the test suite and code style fixer.