2014-09-05 109 views
0

我熟悉RESTful API(CRUD)与AngularJSSlim PHP框架。我正在学习本教程:http://www.blog.iamaronbarbosa.com/building-a-basic-crud-application-using-angularjs-and-slim-php-framework-part-1/。而当应用程序试图GET数据(文件:angular-crud/slim/index.php),CRUD与AngularJS和Slim PHP 404未找到

function ListCtrl($scope, $http) { 
    $http.get('api/users').success(function(data) { 
     $scope.users = data; 
    }); 
} 

我得到的错误代码,说明, Status Code: HTTP/1.1 404 Not Found

的URL得到的数据是:http://localhost/angular-crud/slim/api/users

编辑

但是,如果我申请了网址为http://localhost/angular-crud/slim/api/index.php/users它返回的数据的罚款。是否必须包括index.php?如果没有,是否有解决方法检索使用url http://localhost/angular-crud/slim/api/users的数据?

我对这个领域很新,如果问题很模糊,我很抱歉。我试着检查端口,并使用RESTClient运行测试,但最终空手。您对此问题的专家建议非常感谢:)

回答

2

需要通过index.php进行路由指示URL重写有问题。从文档:

瘦身将工作没有URL重写。在这种情况下,您必须在 中包含您在其中实例化并在资源URI中运行Slim应用程序的PHP文件的名称。

请参阅“Route URL Rewriting”修身文件的详细信息,如何正确路线的URL在Apache和Nginx的部分。

+0

谢谢您的主席先生的答案。这是一个重写问题:) – 2014-09-05 17:27:18

1

我想你的项目中必须有一个.htaccess文件,用于将URL重写为http:// localhost/angular-crud/slim/api/users。 http:// localhost/angular-crud/slim/api/index.php/users。检查您的本地主机是否允许.htaccess覆盖

+0

非常感谢您先生,我会检查这个 – 2014-09-05 17:26:19