Laravel Remote is a package by Spatie that provides a command to execute Artisan commands on a remote server.
Here are some examples of remote commands from the documentation:
1php artisan remote cache:clear 2 3# Raw ls command on the server 4php artisan remote ls --raw 5 6# Raw ls with flags 7php artisan remote --raw "ls -a" 8 9 10# Defining which host configuration to use11php artisan remote cache:clear --host=my-other-host
At the heart of the package's configuration, you define hosts for remote servers that you want to interact with. In order to execute a command on a given host, you can use the --host
flag for the desired configuration:
1return [ 2 'hosts' => [ 3 'default' => [ 4 'host' => env('REMOTE_HOST'), 5 'port' => env('REMOTE_PORT', 22), 6 'user' => env('REMOTE_USER'), 7 'path' => env('REMOTE_PATH'), 8 ], 9 'example2' => [10 'host' => env('EXAMPLE2_REMOTE_HOST'),11 'port' => env('EXAMPLE2_REMOTE_PORT', 22),12 'user' => env('EXAMPLE2_REMOTE_USER'),13 'path' => env('EXAMPLE2_REMOTE_PATH'),14 ],15 ],16];
Under the hood, this package uses Spatie's ssh package, a lightweight PHP library to execute commands over SSH.
If you'd like to follow the author Freek Van der Herten to see how to build this package, he live-streamed it on YouTube. Learn practical examples from one of the most prolific Laravel package developers, where he shows you tips on how to build Laravel packages from scratch:
0 comments:
Post a Comment
Thanks