Installation problem - 405 status code

Hi, I’m very new to Slim. I installed the framework as the user guide said, and when I launched the site I got this output in the webbrowser:

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

Do you have any idea?

I’ve solved the problem finally.
(Just a notice, Slim 3 works properly, I had problem just with Slim 4)

It may help someone:
I have Wampserver, and I made the virtual host: D:/whatever…/slim-site, and after that I entered the public directory in the browser.
I replaced the virtual host path to D:/whatever…/slim-site/public and now it works fine.

I’ve solved the problem with:

$app->setBasePath("/yourproject/public");

after line: $app = AppFactory::create();

1 Like

it works for me too, thanks

I am having a similar problem.

When I use compose to create a new project and then run the PHP web server I get “Hello world!Hello world!”

Going thru the tutorial (NOTE: I am completely new to this) I added the following to the /Public/index.php

$app->get(’/hello’, function (Request $request, Response $response) {
$response->getBody()->write(“did I get to here!”);
return $response;
});

Then I got the 405 status code error, twice

I then added the line suggested by sschoeninger

app->setBasePath("/…/public");

The 405 goes away and I get two

statuscode: 404 “RESOURCE_NOT_FOUND”