marcj / php-rest-service

Php-Rest-Service is a very simple and fast PHP class for server-side RESTful JSON APIs.
MIT License
216 stars 74 forks source link

production enviroment problem #33

Closed espekkaya closed 7 years ago

espekkaya commented 7 years ago

Hello,

I have a little problem in production. I call sample methods in local, there is no problem. But when I call sample methods in production, I can not recieve data. Always get errors. "{ "status": 400, "error": "RouteNotFoundException", "message": "There is no route for ''." }"

http://yeni.hayatatatkat.com/restApi/test

Thank you for helping me.

Sincerely.

marcj commented 7 years ago

Looks like your apache/nginx configuration is different to your local.

espekkaya commented 7 years ago

Hello,

I found the problem. In client.php __construct methods has a $_SERVER['PATH_INFO'] variable. And in my server this variable is empty. But in local, we get value.

Anyway I'm gonna fix this problem via workaround. But I do not understand why path_info variable is empty.

        $_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : '');
        if (isset($_SERVER['PATH_INFO']))
            $this->setUrl($_SERVER['PATH_INFO']);

Thank you.