Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 982929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:46:32+00:00 2026-05-16T04:46:32+00:00

I have created an API that is used on several sites. The client sites

  • 0

I have created an API that is used on several sites. The client sites call the server with either file_get_contents or curl and accesses a url of ours like “http://www.myserver.com/api/record.php?some=thing“. The client makes the call and then waits for the API to respond before processing the rest of the page. However, some of the time no output from the API is needed by the client.

I’m wondering if there’s a way for the server to output something so that the client doesn’t wait for it while the server process is executing what it needs to do. Something like ‘page done’, so the client doesn’t wait for it to load anymore, but the server script is still running for a second while it inserts database entries.

I’ve read that the process control functions are for CLI use only and should not be used in a web server environment, so spawning a new process is out of the question.

Any suggestions? I know making the call asynchronously with javascript would work, but we’ve found PHP accesses to be must more reliable than JS.

Thanks so much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:46:32+00:00Added an answer on May 16, 2026 at 4:46 am

    The connection between your script and your api is the tricky thing; you must terminate it for the curl or file_get_contents to return. (you may look into the asynchronous curl_multi_* functions or do your own socket handling like artefacto suggested)

    One option would be to put the backend handling in a backgrounded process, like so:

    $desc = array(); // fd descriptors
    $proc = proc_open("/bin/sleep 60 &",$desc,$pipes);
    

    where sleep is just for the proof of concept. It lives happily on, after the connection is finished. The downside is that if you have any fd’s connected, the child process will die with the parent, so you must shove the data in through commandline or $env (5th arg to proc_open)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a Rest API that requires client certificate authentication. The API is used
I have created a PHP-script to update a web server that is live inside
I'm helping implement a SQL Server 2008 database and I have several columns that
I have created an API in AS3 that uses Flex bindings. The API is
I have a need to create a transactional process using an external API that
I have a program that creates a Windows user account using the NetUserAdd() API
I have created a minidump using win32 api [DllImport(DbgHelp.dll, SetLastError = true)] private static
I have created a UserControl that has a ListView in it. The ListView is
I have created a few small flash widgets that stream .mp3 audio from an
I have recently become aware that our code has several implementations of a version

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.