I’m learning to develop in PHP for a while and as a field I’m trying to write something like a flight search system. So far, the system has only a couple of functions, several JSON string handlers and several cURL requests to the API. No more than 1000 lines of code. But the page with the script is loaded for 2-3 seconds, which at this stage is already unacceptable. Working with jQuery on the client, you can run the Network tab and see where the delay happens. Is it possible to do the same in PHP?

Closed due to the fact that the question is too general for the participants rjhdby , aleksandr barakin , HamSter , user207618, cheops 15 Oct '16 at 14:36 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • googlea -> "php profiler|профайлер" (and 80% for the fact that delays will be on the side of curl) - PinkTux
  • xhprof to help - Naumov
  • @PinkTux I manually determined the reason for the slow execution of the code. This is a recursive search in a multidimensional array (which is obtained from 2.3 mb of json data). - JamesJGoodwin

1 answer 1

As @ pink-tux said, delays on the CURL side, in particular, because requests are executed sequentially, which takes a lot of time. Alternatively, you can use a blank page load, and then, from a loaded page, using AJAX ( $.when() and $.get() from jQuery, for example), call the API (you will have to write it yourself), which will return data received from CURL, and display them on the page. Places into which data will be inserted can be temporarily, until the download itself, replaced by a spinner.