gipetto / cowsay
An extensible PHP port of the Cowsay linux utility
Installs: 6 283
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 2
Forks: 2
Open Issues: 1
Requires
- php: >=8.0.2
- symfony/string: 6.0
Requires (Dev)
- phpunit/phpunit: ~10.2.0
README
An extensible PHP port of the Linux Cowsay utility.
Requirements
- Minimum: PHP 8.0.2+
- Recommended: PHP 8.2+
Official PHP supported versions: https://www.php.net/supported-versions.php
Install
$ composer require Gipetto/CowSay
Quickstart
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.
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 |
|| || @@@
Extending CowSay
Adding New Carcases
CowSay is easily extended to add new carcases for your custom needs. See the Carcasses tutorial for more information.
Adding New Traits
It is easy to add new Traits to CowSay. See the Custom Traits documentation for more information.
Known Issues
- Line length calculations are not fully understood for strings with longer byte length characters. ie: Chinese.
License
CowSay is licensed under The MIT License (MIT).