FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
php-cli/examples/table.php at dynamicLogLevel · splitbrain/php-cli · GitHub
splitbrain
/
php-cli
Public
Notifications
You must be signed in to change notification settings
Fork
40
Star
179
Code
Issues
1
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
php-cli
/
examples
/
table.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
62 lines (52 loc) · 1.5 KB
Breadcrumbs
php-cli
/
examples
/
table.php
Copy path
File metadata and controls
executable file
·
62 lines (52 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/php
<?php
namespace
splitbrain
\
phpcli
\
examples
;
require
__DIR__
.
'
/../vendor/autoload.php
'
;
use
splitbrain
\
phpcli
\
CLI
;
use
splitbrain
\
phpcli
\
Colors
;
use
splitbrain
\
phpcli
\
Options
;
use
splitbrain
\
phpcli
\
TableFormatter
;
class
Table
extends
CLI
{
/**
* Register options and arguments on the given $options object
*
* @param Options $options
* @return void
*/
protected
function
setup
(
Options
$
options
)
{
$
options
->
setHelp
(
'
This shows how the table formatter works by printing the current php.ini values
'
);
}
/**
* Your main program
*
* Arguments and options have been parsed when this is run
*
* @param Options $options
* @return void
*/
protected
function
main
(
Options
$
options
)
{
$
tf
=
new
TableFormatter
(
$
this
->
colors
);
$
tf
->
setBorder
(
'
|
'
);
// nice border between colmns
// show a header
echo
$
tf
->
format
(
array
(
'
*
'
,
'
30%
'
,
'
30%
'
),
array
(
'
ini setting
'
,
'
global
'
,
'
local
'
)
);
// a line across the whole width
echo
str_pad
(
''
,
$
tf
->
getMaxWidth
(),
'
-
'
) .
"\n"
;
// colored columns
$
ini
=
ini_get_all
();
foreach
(
$
ini
as
$
val
=>
$
opts
) {
echo
$
tf
->
format
(
array
(
'
*
'
,
'
30%
'
,
'
30%
'
),
array
(
$
val
,
$
opts
[
'
global_value
'
],
$
opts
[
'
local_value
'
]),
array
(Colors::
C_CYAN
, Colors::
C_RED
, Colors::
C_GREEN
)
);
}
}
}
$
cli
=
new
Table
();
$
cli
->
run
();
Back
|
FazBrowse Home
|
New Git URL