Ilya  Gvozdev
Ilya Gvozdev

Reputation: 19

Which library is the best in php for making async requests

I have a lot of data, which I want to transfer to Logz.io.

Basically, the project is written in Laravel and I want to create an event manager which will do all the job of logging info to Logz.io. I need an advice about which library h is better to use , something like guzzle curl, which can help me to send logs info to logz.io in the background. I mean, I don't want to wait until the request with data for logz.io will finish.

Thank you.

Upvotes: 1

Views: 1002

Answers (2)

Diego Barrera
Diego Barrera

Reputation: 111

Well, as far as I know, there are two approaches that you could take:

1) Using Laravel's queue system to send your logs later. For this you'd have to enable a worker or a supervisor process to send them on the background.

2) There's this package by the people at spatie - spatie/async which is a wrapper around PHP's PCNTL extension and allows excecuting php code in separate threads.

I hope I could help you, even if a little.

Upvotes: 3

Leonardo Rossi
Leonardo Rossi

Reputation: 3022

PHP is not an async language. Laravel has a queue system that works out of the box.

Basically you put some jobs in a queue and another process (it can be also in another machine), run them. It will work well in your scenario because you don't need a real-time log collection but you can delegate it by few seconds.

Upvotes: 1

Related Questions