Laravel 5: submit response first, then handle request in controller

I am working with the Classic Paypal API and before processing the request data I was faced with a response problem.

public function store() {
    // Send an empty HTTP 200 OK response to acknowledge receipt of the notification
    response("", 200);
    // Build the required acknowledgement message out of the notification just received
    // Once it hits this point, nothing is sent to the client.
}

      

I know that in order for the client to receive an HTTP 200 response, I will need to add the return keyword before it. However, if I return the response immediately, the request will not be processed. I've studied before and after intermediaries, but unfortunately they are not asynchronous. Is there a way to accomplish the submit process in Laravel 5?

+3


source to share


1 answer


I found a solution for this problem:



try {
    return response("", 200);
} finally {
    // Controller logic here
}

      

+2


source







All Articles