Varshaan Varshaan - 2 months ago 8
PHP Question

$http.get(url for my function in index.php) returns 404 error when callin my slim php function

I am getting a 404 response when I use

to fetch the list of users from my backend API, which is built using Slim.

This is my AngularJS method to call

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

This is my Slim route, located in

$app = new Slim();
$app->get('/getUser', 'getUser');

function getUser() {
$sql = "select * FROM employees ORDER BY id";
try {
$db = getConnection();
$stmt = $db->query($sql);
$wines = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
echo json_encode($wines);
} catch(PDOException $e) {
echo '{"error":{"text":"'. $e->getMessage() .'"}}';

Thanks for replies in advance:)


Don't you need to register a function instead of a string?


$app->get('/getUser', getUser);