An extensible PHP port of the Linux Cowsay utility.
- Minimum: PHP 7.4+
- Recommended: PHP 8.1+
Official PHP supported versions: https://www.php.net/supported-versions.php
$ composer require Gipetto/CowSay
use CowSay\Cow;
$bessie = new Cow('Hello, Farm!');
// store the output in a variable
$output = $bessie->say();
echo $output;
// or just echo the object for direct output
echo $bessie;
Displays:
------------
< Hello, Farm! >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Run php demo.php
to see all the included cows and their traits.
Cows support a few traits. You can specify the Eyes, Tongue, Udder and, yes, you can specify Poop.
$bessie = new Cow('Hello, Farm!');
$bessie->setEyes('oO')
->setTongue('U')
->setPoop('@@@')
->setUdder('W');
echo $bessie;
Displays:
------------
< Hello, Farm! >
------------
\ ^__^
\ (oO)\_______
(__)\ )\/\
U ||----W |
|| || @@@
CowSay is easily extended to add new carcases for your custom needs. See the Carcasses tutorial for more information.
- Line length calculations are not fully understood for strings with longer byte length characters. ie: Chinese.
CowSay is licensed under The MIT License (MIT).