Anastasie Laurent
Anastasie Laurent

Reputation: 915

laravel how to debug a RESTful controller

I have this controller

class APIV1CustomerController extends BaseController{
    public function getIndex(){
        return "super new look";
    }

    public function postRegister(){
        return "you have entered "+Input::get('fullName')+" as fullName parameter and "+Input::get('mobileNumber')+" as mobileNumber parameter";
    }
}

I am trying to call the register function from IOS, I have some problems with the returing data. Thus, I need to debug that function.

when I return just simple test like return "test", it works well from IOS. but when I return the code I showed to you, some problem accrues, I can solve the problem myself from the IOS side but I need to debug the postRegister to check some issues.

when I was using J2EE web service, I can simple print some data to the console in my eClipse that is why I am asking if there is any way to do that in laravel.

Thanks

I am using php storm IDE

Upvotes: 1

Views: 6465

Answers (2)

user101289
user101289

Reputation: 10422

This might be useful: https://github.com/mlanin/laravel-api-debugger

It's a laravel package specifically built for assisting with APIs.

Upvotes: 3

windmaomao
windmaomao

Reputation: 7670

this might be irrelevant, but i learned a lot from this article when debugging api and jquery back then. http://www.openlogic.com/wazi/bid/188084/jQuery-and-Ajax-Error-Detection-and-Handling.

the first step is to see if there's any functions in your IOS which will notify you when you have an error after the http call, so that you know you actually are getting an error, ex. 404, 500 etc. Because if you are getting 200, most likely you don't need more advanced debug tool other than print.

server log is another friend which is very helpful in these white screen case, it'll tell you the exact error when 500 error happens. Ex. last error I got on my server was telling me a class name is not found, although it runs fine in my local.

Upvotes: 0

Related Questions