Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AscentCreative's avatar

Concurrent Requests in Artisan

I have a long-running operation in my laravel app which needs to run synchronously for the user. However, I'd like to provide a progress bar while it's running.

For this, I need to be able to poll the server in javascript to get the status (which will be posted by the long process).

This is fine in production as the server can handle concurrent requests. However, in development on Artisan this isn't the case - the polling requests have to wait until the task finishes.

Before I look at setting up a full local server for this, can I check if I'm missing any startup commands for artisan which will allow it to handle concurrent requests?

0 likes
9 replies
bugsysha's avatar

If you are using php artisan serve then you are not missing anything. It is not built for concurrency.

tykus's avatar
tykus
Best Answer
Level 104

You can fork multiple workers by setting the PHP_CLI_SERVER_WORKERS environment variable; this gives you concurrency:

PHP_CLI_SERVER_WORKERS=4 php artisan serve

This is how you can do it; my personal preference (even in development) is an actual web server such as Apache or Nginx

3 likes
AscentCreative's avatar

@tykus Cool - thanks! I've tried this, but somehow it's still blocking the requests (even though it does show multiple workers running).

It feels like a proper local apache instance would be better all round, but thought I'd check.

bugsysha's avatar

I've tried this, but somehow it's still blocking the requests (even though it does show multiple workers running).

@AscentCreative damn it, you broke my dreams :D

I guess it was too good to be true.

1 like
bugsysha's avatar

I ended up switching to using the job queue, and writing a job monitoring package.

@AscentCreative that is what creates great devs. Great job.

tykus's avatar

@Eyad Mohammed Osama use a proper server in development.

Please or to participate in this conversation.