PHP code example of navisborealis / wonderwords-php
1. Go to this page and download the library: Download navisborealis/wonderwords-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
navisborealis / wonderwords-php example snippets
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator;
use NavisBorealis\WonderwordsPhp\WonderWordsSentence;
// 1. Generate memorable usernames (e.g., AzureCheetah)
$username = ucfirst(WonderWordsGenerator::color()) . ucfirst(WonderWordsGenerator::animal());
// 2. Provide default names for new entities like projects or workspaces (e.g., "Blushing Inspection Project")
$projectName = WonderWordsGenerator::phrase() . ' Project';
// 3. Generate grammatically correct sentences (e.g., "A fluffy cake quickly plays golf.")
$sentence = WonderWordsSentence::simpleSentence();
// 4. Create random URL slugs (e.g., "blushing-inspection")
$slug = WonderWordsGenerator::phrase('-', 1, 1, 'strtolower');
public static function phrase(
string $separator = ' ',
int $numAdjectives = 1,
int $numNouns = 1,
?callable $stringCaseFunction = null
): string
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator;
echo WonderWordsGenerator::phrase(); // Output: Blushing Inspection
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator;
echo WonderWordsGenerator::phrase('-'); // Output: Blushing-Inspection
use NavisBorealis\WonderwordsPhp\WonderWordsGenerator;
use NavisBorealis\WonderwordsPhp\Words\Adjective;
Adjective::setWordList(['customadjective1', 'customadjective2']);
echo WonderWordsGenerator::phrase(); // Output: Customadjective2 Inspection
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
use NavisBorealis\WonderwordsPhp\Words\Noun;
// Generate a 5-letter noun starting with 'a' and ending with 'e'
echo Noun::randomWord([
'starts_with' => 'a',
'ends_with' => 'e',
'word_min_length' => 5,
'word_max_length' => 5
]); // Output: apple
// Generate 3 words matching a custom regex
$words = Noun::randomWords(3, [
'regex' => '/^b.*y$/'
]); // Output: ["blueberry", "butterfly", "balcony"]
use NavisBorealis\WonderwordsPhp\WonderWordsSentence;
// Example: "A fluffy cake quickly plays golf."
echo WonderWordsSentence::simpleSentence();
// Example: "A fluffy cat quickly runs."
echo WonderWordsSentence::bareBoneSentence();
// Generate a sentence where the nouns start with 'a' and the verb is exactly 3 letters long
echo WonderWordsSentence::simpleSentence(
['starts_with' => 'a'],
['word_min_length' => 3, 'word_max_length' => 3]
);
use NavisBorealis\WonderwordsPhp\Words\Profanity;
// Check a specific string
$isBad = Profanity::isProfanity("piss"); // true
// Filter an array of words
$cleanArray = Profanity::filterProfanity(['apple', 'orange', 'piss']);
// Output: ['apple', 'orange']
use Faker\Factory;
use NavisBorealis\WonderwordsPhp\Faker\WonderWordsProvider;
$faker = Factory::create();
$faker->addProvider(new WonderWordsProvider($faker));
// Generate words
echo $faker->wonderWordsAdjective(); // e.g., "blushing"
echo $faker->wonderWordsNoun(); // e.g., "inspection"
echo $faker->wonderWordsColor(); // e.g., "azure"
// Generate phrases and sentences
echo $faker->wonderWordsPhrase(); // e.g., "Blushing Inspection"
echo $faker->wonderWordsSimpleSentence(); // e.g., "A fluffy cake quickly plays golf."
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.