我正在尝试使用Phalcon PHP创建一个简单的REST API。我使用wamp设置Phalcon并遵循本教程http://docs.phalconphp.com/pt/latest/reference/tutorial-rest.html for simple rest api但是我无法在http://localhost/my-rest-api/api/robots访问它(错误:在此服务器上找不到请求的URL / my-rest-api / api / robots。) 我的休息api在wamp的www目录中,任何人都可以指出我的错误吗?
如果我尝试访问http://localhost/my-rest-api/index.php 我得到了这两个错误
(!)致命错误:未捕获的异常'Phalcon \ Mvc \ Micro \ Exception',消息'未找到处理程序在C:\ wamp \ www \ my-rest-api中无法调用或未定义'第177行的index.php (!)Phalcon \ Mvc \ Micro \ Exception:Not-Found处理程序不可调用或未在第177行的C:\ wamp \ www \ my-rest-api \ index.php中定义
第177行代码行
$app->handle();
答案 0 :(得分:2)
我遇到了同样的问题。在我的情况下,这是由
修复的即,在index.php
底部附近的某处$app->notFound(function () use ($app) {
$app->response->setStatusCode(404, "Not Found")->sendHeaders();
echo 'This is crazy, but this page was not found!';
});
希望有所帮助
乔纳森
答案 1 :(得分:1)
1)您可能在index.php的同一文件夹中缺少.htaccess文件与Apache mod_rewrite on
2)您应该在路由器服务中声明Not Found
路由。这在index.php中声明。