Slim PHP Framework Help

2019-04-14 09:03发布

问题:

I just added the Slim framework to my website in order to create a rest API. But I currently have a problem. I wrote this code as a test to check to see if a get request would work, but whenever I try calling the url, http://mysite.com/api/rest/hello/max, I get a website not found error. Please can you tell me what is going wrong?

Slim::init();

Slim::get('/hello/:name', 'hello');

function hello($name) {
    echo "Hello, $name!";
}

Slim::run();

回答1:

You have propably forgotten to put the .htaccess file provided with Slim in the same directory as your index.php.