Running Artisan commands

anand_aks

New member
Using ExeOutput for PHP 2021 with a Laravel app that requires both queue workers and websockets.
In local dev, I run:

php artisan queue:work
php artisan websockets:serve

Inside the compiled EXE, I can’t run these manually.
What’s the best way to have both commands start automatically when the EXE launches?
 
No Laravel expert here, but maybe this would work:

Hook into the onStartMainWindow event and execute a custom PHP script:
Code:
// onStartMainWindow HEScript
procedure OnStartMainWindow;
begin
  RunPHP('startup.php');
end;

Then in startup.php:
Code:
<?php
// Set up argv for Artisan
$_SERVER['argv'] = ['artisan', 'queue:work'];
include('artisan');

// Run websockets in parallel (if supported)
$_SERVER['argv'] = ['artisan', 'websockets:serve'];
include('artisan');
?>

Another option to try if above does not wrok for you is shell_exec:
Code:
<?php
shell_exec("start /B php artisan queue:work");
shell_exec("start /B php artisan websockets:serve");
?>

Again, no Laravel expert and just started learning Larvavel.
 
I tried the below code inside Application settings > scripting > User main
PHP:
procedure OnStartMainWindow;
begin
  RunPHP('startup.php');
end;

But getting Syntax error
Sorry about that. Not in my home office and no access to exeout. I provided the code from my memory and it appears my memory and code are wrong.

I will be back on Aug 14 and can take a better look. Hopefully @gdgsupport will checkin before that and assist you.
 
Thanks for the reply. @gdgsupport @oldteacher

But I am still having issues

Can you explain in more detail how to implement my requirement using the standalone artisan.exe you mentioned?


I am currently using ExeOutput 2021, but I think the standalone Artisan support is only available in ExeOutput 2024.


What I want is: when the user opens the main application, it should automatically run the Laravel queue:work command in the background.


How can I achieve this using the standalone Artisan?
 
Back
Top