Php 无法使用restler库访问Json

Php 无法使用restler库访问Json,php,restler,Php,Restler,我用php usring restler libary创建了一个rest api,它在我的PC中运行良好,但当我将api上传到服务器时,问题开始出现。。 这个函数在我的api中 <?php class user { /** @url GET / */ public function getAllInfo(){ $link = new PDO('mysql:host=localhost;dbname=---;charset=utf8','---','-

我用php usring restler libary创建了一个rest api,它在我的PC中运行良好,但当我将api上传到服务器时,问题开始出现。。 这个函数在我的api中

<?php
class user {
/**
        @url GET /
*/
    public function getAllInfo(){
        $link = new PDO('mysql:host=localhost;dbname=---;charset=utf8','---','-----');
        $handle = $link->prepare('select * from user');
        $handle->execute();
        $result = $handle->fetchAll(PDO::FETCH_OBJ);

        if(empty($result)){
            $err = new stdClass();
            $err->error = "No user found";
            return $err;
        }
        else{
            return $result;
        }
}

require_once 'restler.php';

$r = new Restler(); 
$r->setSupportedFormats('JsonFormat'); 
$r->addAPIClass('user'); 
$r->handle();
?>
我不知道这是什么,也不知道我应该怎么打印json, 我的数据库充满了数据,如果我的查询没有restler,它将返回json,但我需要在代码中使用restler

Luracast\Restler\EventDispatcher Object ( [listeners:Luracast\Restler\EventDispatcher:private] => Array ( ) [events:protected] => Array ( ) )