example.php
1006 Bytes
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
<?php
$loader = require_once __DIR__ . '/vendor/autoload.php';
$consoleColor = new JakubOnderka\PhpConsoleColor\ConsoleColor();
echo "Colors are supported: " . ($consoleColor->isSupported() ? 'Yes' : 'No') . "\n";
echo "256 colors are supported: " . ($consoleColor->are256ColorsSupported() ? 'Yes' : 'No') . "\n\n";
if ($consoleColor->isSupported()) {
foreach ($consoleColor->getPossibleStyles() as $style) {
echo $consoleColor->apply($style, $style) . "\n";
}
}
echo "\n";
if ($consoleColor->are256ColorsSupported()) {
echo "Foreground colors:\n";
for ($i = 1; $i <= 255; $i++) {
echo $consoleColor->apply("color_$i", str_pad($i, 6, ' ', STR_PAD_BOTH));
if ($i % 15 === 0) {
echo "\n";
}
}
echo "\nBackground colors:\n";
for ($i = 1; $i <= 255; $i++) {
echo $consoleColor->apply("bg_color_$i", str_pad($i, 6, ' ', STR_PAD_BOTH));
if ($i % 15 === 0) {
echo "\n";
}
}
echo "\n";
}