diff --git a/composer.json b/composer.json index 0cca148f9..68f0ca603 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "slim/psr7": "^1.3.0", "monolog/monolog": "^3.0", "twig/twig": "^3.0", - "slim/twig-view": "^3.0" + "slim/twig-view": "^3.0", + "alrik11es/cowsayphp": "^1.2" }, "require-dev": { "heroku/heroku-buildpack-php": "*" diff --git a/composer.lock b/composer.lock index 85cccad59..b7e1172df 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,66 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0aa7148272c380d8d4d48317eb390443", + "content-hash": "64ddf7a335147fbd677355bc9b70c2d6", "packages": [ + { + "name": "alrik11es/cowsayphp", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/alrik11es/cowsayphp.git", + "reference": "080dc10c8f5420fef35163569293601f17124eeb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alrik11es/cowsayphp/zipball/080dc10c8f5420fef35163569293601f17124eeb", + "reference": "080dc10c8f5420fef35163569293601f17124eeb", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "5.*", + "scrutinizer/ocular": "~1.1" + }, + "bin": [ + "bin/cowsayphp" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Cowsayphp\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marcos Sigueros", + "email": "alrik11es@gmail.com", + "homepage": "https://github.com/alrik11es", + "role": "Developer" + } + ], + "description": "Cowsay port in PHP", + "homepage": "https://github.com/alrik11es/cowsayphp", + "keywords": [ + "cowsay" + ], + "support": { + "issues": "https://github.com/alrik11es/cowsayphp/issues", + "source": "https://github.com/alrik11es/cowsayphp/tree/master" + }, + "time": "2016-08-25T07:53:44+00:00" + }, { "name": "fig/http-message-util", "version": "1.1.5", diff --git a/web/index.php b/web/index.php index c1a82e533..656058c1f 100755 --- a/web/index.php +++ b/web/index.php @@ -25,6 +25,10 @@ $logger->pushHandler(new StreamHandler('php://stderr'), Level::Debug); return $logger; }); +// Add Cowsay to Container +$container->set(\Cowsayphp\AnimalInterface::class, function() { + return \Cowsayphp\Farm::create(\Cowsayphp\Farm\Cow::class); +}); // Create main Slim app $app = Bridge::create($container); @@ -35,5 +39,10 @@ $logger->debug('logging output.'); return $twig->render($response, 'index.twig'); }); +$app->get('/coolbeans', function(Request $request, Response $response, LoggerInterface $logger, \Cowsayphp\AnimalInterface $animal) { + $logger->debug('letting the Cowsay library write something cool.'); + $response->getBody()->write("
".$animal->say("Cool beans")."
"); + return $response; +}); $app->run();