diff --git a/api/composer.json b/api/composer.json index 8666ffb..a4bb9eb 100644 --- a/api/composer.json +++ b/api/composer.json @@ -8,7 +8,7 @@ }, "autoload": { "psr-4": { - "my\\namespace\\" : "src" + "Davian\\apilabtemplate\\" : "src" } } } diff --git a/index.php b/index.php new file mode 100644 index 0000000..dc8a012 --- /dev/null +++ b/index.php @@ -0,0 +1,23 @@ +get('/hello/{name}', function (Request $request, Response $response, array $args) { + $name = $args['name']; + $response->getBody()->write("Hello, $name"); + return $response; +}); +//{name} in the url indicates what the argument will be called +//Line 9; adds the text "Hello, $name" to the response + +$container = $app->getContainer(); +$container['logger'] = function($c) { + $logger = new \Monolog\Logger('my_logger'); + $file_handler = new \Monolog\Handler\StreamHandler('../logs/app.log'); + $logger->pushHandler($file_handler); + return $logger; +}; //This creates a new directory 'logs' in the firstSlim directory +//Creates and writes to app.log file in that directory. +$app->run(); //This tells PHP to run the slim app