forked from digitalocean/sample-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
36 lines (28 loc) · 963 Bytes
/
index.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
<?php
require __DIR__ . '/vendor/autoload.php';
use Cowsayphp\Farm;
use Cowsayphp\Farm\Cow;
use Monolog\Formatter\JsonFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Processor\IntrospectionProcessor;
use Monolog\Processor\WebProcessor;
header('Content-Type: text/plain');
$text = "Set a message by adding ?message=<message here> to the URL";
if(isset($_GET['message']) && $_GET['message'] != '') {
$text = htmlspecialchars($_GET['message']);
}
$cow = Farm::create(Cow::class);
echo $cow->say($text);
// create a log channel
$log = new Logger('name');
$handler = new StreamHandler('php://stdout', Logger::DEBUG);
$formatter = new JsonFormatter();
$handler->setFormatter($formatter);
$log->pushHandler($handler);
$log->pushProcessor(new WebProcessor());
$log->pushProcessor(new IntrospectionProcessor());
// add records to the log
$log->warning('hello ' . time(),$_ENV);
$log->error('you ' . time(),$_SERVER);
echo "\n\nOK!";