forked from kevinlebrun/colors.php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
executable file
·43 lines (32 loc) · 959 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env php
<?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 styles
$c->setUserStyles(
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;