美元http.Get (index.php中函数的url)在调用我的瘦PHP函数时返回404错误


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

当我使用$http.get从我的后端API获取用户列表时,我得到404响应,这是使用Slim构建的。

这是我的AngularJS调用 的方法
function ListCtrl($scope, $http) {
  $http.get('api/getuser.php/getUser').success(function(data) {
    $scope.users = data;
  });
}

这是我的Slim路线,位于getuser.php:

 $app = new Slim();
 $app->get('/getUser', 'getUser');
 $app->run();
 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() .'"}}'; 
        }
    }

感谢您的提前回复:)

你不需要注册一个函数而不是字符串吗?

试题:

$app->get('/getUser', getUser);
http://docs.slimframework.com/routing/get/