diff --git a/frameworks/PHP/slim/benchmark_config.json b/frameworks/PHP/slim/benchmark_config.json index 475b3b9f21ae..e2f0bc19e350 100644 --- a/frameworks/PHP/slim/benchmark_config.json +++ b/frameworks/PHP/slim/benchmark_config.json @@ -8,6 +8,7 @@ "query_url": "/queries?queries=", "plaintext_url": "/plaintext", "update_url": "/updates?queries", + "fortune_url": "/fortunes", "port": 8080, "approach": "Realistic", "classification": "Micro", diff --git a/frameworks/PHP/slim/index.php b/frameworks/PHP/slim/index.php index e41466fb5020..86bfae97cd3b 100755 --- a/frameworks/PHP/slim/index.php +++ b/frameworks/PHP/slim/index.php @@ -60,6 +60,28 @@ } ); +// Test 4: Fortunes +$app->get('/fortunes', function ($request, $response) { + $sth = $this->db->query('SELECT * FROM fortune'); + + $arr = $sth->fetch(PDO::FETCH_KEY_PAIR); + $arr[0] = 'Additional fortune added at request time.'; + asort($arr); + + ob_start(); + include __DIR__.'/index.tpl.phtml'; + $html = ob_get_contents(); + ob_end_clean(); + + $body = $response->getBody(); + $body->write($html); + + return $response + ->withBody($body) + ->withHeader('Content-Type', 'text/html'); + } +); + // Test 5: Database updates $app->get('/updates', function ($request, $response) { $sth = $this->db->prepare('SELECT * FROM world WHERE id = ?'); diff --git a/frameworks/PHP/slim/index.tpl.phtml b/frameworks/PHP/slim/index.tpl.phtml new file mode 100644 index 000000000000..c83f22dc39af --- /dev/null +++ b/frameworks/PHP/slim/index.tpl.phtml @@ -0,0 +1,12 @@ + + +Fortunes + + + + $message): ?> + + +
idmessage
+ +