https://github.com/chrismou/php-irc-text-formatting
PHP library for adding color and styling to IRC text output
https://github.com/chrismou/php-irc-text-formatting
Last synced: about 1 month ago
JSON representation
PHP library for adding color and styling to IRC text output
- Host: GitHub
- URL: https://github.com/chrismou/php-irc-text-formatting
- Owner: chrismou
- License: bsd-2-clause
- Created: 2014-12-16T12:38:19.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-19T05:32:39.000Z (about 9 years ago)
- Last Synced: 2025-04-06T17:52:27.066Z (2 months ago)
- Language: PHP
- Homepage:
- Size: 42 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# IRC color/style library for PHP
PHP library for adding color and styling to IRC text output
[](https://travis-ci.org/chrismou/php-irc-text-formatting)
[](https://codeclimate.com/github/chrismou/php-irc-text-formatting/coverage)
[](https://codeclimate.com/github/chrismou/php-irc-text-formatting)
[](https://www.paypal.me/chrismou)## About
This plugin is designed to provide IRC script writers a simple way to add colors/styles to their output. It should be compatible with most major PHP IRC bots, such as
[Phergie](https://github.com/phergie/phergie-irc-bot-react).## Install
The recommended method of installation is [through composer](http://getcomposer.org).
```
composer require chrismou/php-irc-text-formatting
```## Configuration
To begin adding formatting to ouput text within your own applications, you'll need to include it in your project. The simplest way of doing this is as follows:
```php
protected $format;function __construct(array $config=array())
{
$this->format = new \Chrismou\Irc\TextFormatting\Format;
...
}
```Or, if you're only using it once, you can just include it directly in your method.
```php
public function foo
{
$format = new \Chrismou\Irc\TextFormatting\Format;
...
}
```## Usage
The 3 methods available are **color**, **style** and **rainbow**.
#### Color
This takes 3 parameters. First is the text, second is the text color, third is the background colour (optional).```php
$format = new \Chrismou\Irc\TextFormatting\Format;
$format->color("This text will be red", "red");
$format->color("This text will be blue on a green background", "blue", "green");
```**Available color codes:**
* white
* black
* blue
* green
* red
* brown
* purple
* orange
* yellow
* lightGreen
* teal
* cyan
* lightBlue
* pink
* grey
* lightGrey#### Style
This takes 2 parameters. First is the text, second is the style to use.```php
$format = new \Chrismou\Irc\TextFormatting\Format;
$format->style("This text will be underlined", "underline");
```**Available style codes:**
* bold
* underline
* reverse (switches foreground and background color)I've purposely excluded strikethrough and italic codes as support for them among IRC clients is fairly poor.
#### Rainbow
This takes a single parameter - the text - and gives the string a rainbow colouring.
```php
$format = new \Chrismou\Irc\TextFormatting\Format;
$format->rainbow("This text will be FABULOUS"); // produces rainbow coloured text
```## Tests
To run the unit test suite:
```
curl -s https://getcomposer.org/installer | php
php composer.phar install
./vendor/bin/phpunit
```Or to test on all supported versions, ensure docker is installed and running, then run:
```
curl -s https://getcomposer.org/installer | php
php composer.phar install
./vendor/bin/dunit
```## License
Released under the BSD License. See `LICENSE`.