0

I am familiarizing with RESTful api (CRUD) with AngularJS and Slim PHP framework. I am following this tutorial : http://www.blog.iamaronbarbosa.com/building-a-basic-crud-application-using-angularjs-and-slim-php-framework-part-1/ . And when the application tried to GET data (file: angular-crud/slim/index.php),

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

I get the error code stating, Status Code: HTTP/1.1 404 Not Found

The url to GET the data is : http://localhost/angular-crud/slim/api/users.

EDIT

HOWEVER, if I apply the url as http://localhost/angular-crud/slim/api/index.php/users it returns the data fine. Is it a must to inlude the index.php? if not is there a workaround to retrieve data using with the url http://localhost/angular-crud/slim/api/users ?

I am very new to this area and I apologize if the question is vague. I tried checking the ports and ran tests using RESTClient but ended up empty handed. You expert advice on this matter is highly appreciated :)

2 Answers 2

2

The need to route via index.php is indicative of an issue with URL rewriting. From the documentation:

Slim will work without URL rewriting. In this scenario, you must include the name of the PHP file in which you instantiate and run the Slim application in the resource URI.

Please see the "Route URL Rewriting" section of the Slim documentation for details on how to properly route URL's in both Apache and nginx.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you sir for the answer. It was a rewrite issue :)
1

I imaginge that the there must be a .htaccess file in your project that rewrites the url from http:// localhost/angular-crud/slim/api/users to http:// localhost/angular-crud/slim/api/index.php/users. Check if your localhost allows .htaccess overrides

1 Comment

TThank you very much sir i will check on this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.