I am working in PHP and the Laravel framework.
I have a command I want to run when I am working locally.
exec("start chrome.exe http://127.0.0.1:8000");
I only need this command to run once when the server is started
I have tried placing it in a few spots, but when I run php artisan serve
google chrome opens new tabs until I stop the server.
Where is a safe place to place this command so it executes only once after the server has started?
You should override the ServeCommand
class (https://github.com/laravel/framework/blob/64fb6f745de496a2a114fdf896d3b60ab2119569/src/Illuminate/Foundation/Console/ServeCommand.php) and call your command in the handle
method.
I think I would create a bash script or something similar to handle this instead:
#!/bin/bash
# dev.sh
php artisan serve && chrome http://localhost:8000
Then you can just run dev.sh
in your console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With