How to run the PHP code asynchronous

前端 未结 5 1416
小蘑菇
小蘑菇 2020-11-27 06:55

How can I run PHP code asynchronously without waiting? I have a long run (almost infinite) that should run while server starts and should process asynchronously without wait

5条回答
  •  轮回少年
    2020-11-27 07:50

    This isn't really what PHP is designed for. You have to use the PECL threading library to spin off threads that run asynchronously, and I don't recommend it. The new hotness in the async department is node.js - I recommend you look into that and see if you can utilize it. It's designed for light weight, asynchronous network operations, and can be used to fire PHP scripts.

提交回复
热议问题