{ "statusCode": 405, "error": { "type": "NOT_ALLOWED", "description": "Method not allowed. Must be one of: OPTIONS" } }

Viewed 1181

Trying to create rest Api using Slim Framework getting this error when I type in browser

http://localhost/filename/public/hello/name

index.php file

<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

require '../vendor/autoload.php';

$app = new \Slim\App;

$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
    $name = $args['name'];
    $response->getBody()->write("Hello, $name");
    return $response;
});

$app->run();
0 Answers
Related