File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/php
2+ <?php
3+ require __DIR__ . '/../vendor/autoload.php ' ;
4+
5+ use splitbrain \phpcli \CLI ;
6+ use splitbrain \phpcli \Options ;
7+
8+ class logging extends CLI // you may want to extend from PSR3CLI instead
9+ {
10+ // override the default log level
11+ protected $ logdefault = 'debug ' ;
12+
13+ // register options and arguments
14+ protected function setup (Options $ options )
15+ {
16+ $ options ->setHelp ('A very minimal example that demos the logging ' );
17+ }
18+
19+ // implement your code
20+ protected function main (Options $ options )
21+ {
22+ $ this ->debug ('This is a debug message ' );
23+ $ this ->info ('This is a info message ' );
24+ $ this ->notice ('This is a notice message ' );
25+ $ this ->success ('This is a success message ' );
26+ $ this ->warning ('This is a warning message ' );
27+ $ this ->error ('This is a error message ' );
28+ $ this ->critical ('This is a critical message ' );
29+ $ this ->alert ('This is a alert message ' );
30+ $ this ->emergency ('This is a emergency message ' );
31+ throw new \Exception ('Exception will be caught, too ' );
32+ }
33+ }
34+
35+ // execute it
36+ $ cli = new logging ();
37+ $ cli ->run ();
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments