简体   繁体   中英

Run two different PHP programs at the same time

Good afternoon!

I'm currently working on a small project. I try to make a simple REST api in PHP to control music. The idea is that a call to the api executes a server command with the exec function of PHP. This is already working :)

What I like to do know is to play multiple files after each other, like a playlist. My idea is two different programs. One program that manage a queue with files that must be played and a program that plays the first item in the queue, than the second, etc. While the song is playing the queue should be modified.

So may question is: is this even possible? I there a way to run these programs at the same time? Or is my way of thinking way to complex and is there a much better and simpler solution?

Thanks for thinking along with me :)
Niels

You could :

  1. Make 2 different API calls from your client, 1 for your queue and 1 for your player
  2. Create a bash script that launches both processes as daemon using the & char, and make your API call this script
  3. Trying some async threads in PHP (I did not test yet), doc here and here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM