title: How to wait for a file to exist with php?
body: <p>I am using an asynchronous webservice which send me back a Job ID. The full response is then send by the webservice as an XML file (jobId.xml) to my server using a PUT request.</p>
  
  <hr>
  
  <blockquote>
    <p>After issuing the request to the webservice and getting the jobID, I
    would like to know what would be the best (most efficient) way to wait
    until the file is created into the PUT directory of my server?</p>
  </blockquote>
  
  <hr>
  
  <p>I am thinking of a loop of file_exist() with a usleep() between each execution and with a timeout.</p>
  
  <p>But I am sure that there is a better way.
  Something like a listener...</p>
  
  <p>The file can take less than a second to more than 1 minute to arrive.</p>
  
  <p>Thanks!</p>