kevinlebrun / colors.php
Colors for PHP CLI scripts
Installs: 5 751 267
Dependents: 61
Suggesters: 2
Security: 0
Stars: 341
Watchers: 17
Forks: 40
Open Issues: 4
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 3.7.*
- satooshi/php-coveralls: 1.0.*
- squizlabs/php_codesniffer: 1.*
README
Here is a preview of what you can achieve with the library:
Installation
Installation via composer is highly recommended.
{ "require": { "kevinlebrun/colors.php": "1.0.*" } }
Install composer.
$ php composer.phar install
Usage
<?php require_once __DIR__ . '/vendor/autoload.php'; use Colors\Color; $c = new Color(); // highlight('green') === bg('green') === bg_green() // white() === fg('white') echo $c('Hello World!')->white()->bold()->highlight('green') . PHP_EOL; // using some magic echo $c('Hello World!')->white->bold->bg_green . PHP_EOL; // create your own theme $c->setTheme( array( 'welcome' => array('white', 'bg_green'), 'bye' => 'blue', ) ); echo $c('Hello World!')->welcome->bold . PHP_EOL; echo $c('Bye!')->bye . PHP_EOL; // use style tags $text = <<<EOF 1 : <welcome>Hello <bold>World!</bold></welcome> 2 : <bye>Bye!</bye> EOF; echo $c($text)->colorize() . PHP_EOL; // center text $text = 'hello' . PHP_EOL . '✩' . PHP_EOL . 'world'; echo $c($text)->center() . PHP_EOL; // use standard API $message = $c->apply('bold', $c->white('Hello World!')); echo $message . PHP_EOL; echo $c->clean($message) . PHP_EOL;
Contributing
Install composer.
$ php composer.phar install --dev
All tests must pass:
$ bin/phpunit
Code style conventions must be followed:
$ bin/phpcs --standard=phpcs.xml -p .
Contributors
- Nate Good me@nategood.com
- Jérémy Derusse https://github.com/jeremy-derusse
- Cam Spiers camspiers@gmail.com
- Menthol https://github.com/menthol
- Shane Garelja https://github.com/shane-garelja
- Travis J. VanDame https://github.com/tvandame
- Markus Staab markus.staab@redaxo.de
- inquam danielliljeberg@spray.se
License
(The MIT License)
Copyright (c) 2018 Kevin Le Brun lebrun.k@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.