spatie / laravel-remote
在远程服务器上执行 Artisan 命令
1.4.0
2024-02-27 15:21 UTC
Requires
- php: ^8.0
- illuminate/contracts: ^8.0|^9.0|^10.0|^11.0
- spatie/laravel-package-tools: ^1.9
- spatie/ssh: ^1.5
Requires (Dev)
- orchestra/testbench: ^6.23|^7.0|^8.0|^9.0
- pestphp/pest-plugin-laravel: ^1.3|^2.3
- phpunit/phpunit: ^9.4|^10.5
- spatie/laravel-ray: ^1.9
- spatie/pest-plugin-snapshots: ^1.1|^2.1
- spatie/phpunit-snapshot-assertions: ^4.2|^5.1
- spatie/ray: ^1.21
README
此包提供了一个命令,用于在远程服务器上执行 Artisan 命令。
以下是一个示例,用于在远程服务器上清除缓存。
php artisan remote cache:clear
支持我们
我们在创建一流的开源包上投入了大量的资源。您可以通过购买我们的付费产品之一来支持我们。
我们非常感谢您从家乡寄给我们一张明信片,说明您正在使用我们的哪个包。您可以在我们的联系页面上找到我们的地址。我们将所有收到的明信片发布在我们的虚拟明信片墙上。
安装
您可以通过 composer 安装此包
composer require spatie/laravel-remote
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="remote-config"
这是已发布配置文件的内容
return [ /* * This host will be used if none is specified * when executing the `remote` command. */ 'default_host' => 'default', /* * When set to true, A confirmation prompt will be shown before executing the `remote` command. */ 'needs_confirmation' => env('REMOTE_NEEDS_CONFIRMATION', false), /* * Here you can define the hosts where the commands should be executed. */ 'hosts' => [ 'default' => [ 'host' => env('REMOTE_HOST'), 'port' => env('REMOTE_PORT', 22), 'user' => env('REMOTE_USER'), /* * The package will cd to the given path before executing the given command. */ 'path' => env('REMOTE_PATH'), /* * Optional. Path to the private key on your computer if your remote server requires it. */ 'privateKeyPath' => env('REMOTE_PRIVATE_KEY_PATH'), /* * Optional. Path to the php binary on your remote server. */ 'phpPath' => env('REMOTE_PHP_PATH', 'php'), ] ], ];
用法
要在远程服务器上执行命令,请使用 remote
Artisan 命令。您可以传递任何要在服务器上执行的 artisan 命令。
以下是一个清除缓存的示例。
php artisan remote cache:clear
执行原始命令
如果您想执行 bash 命令,请使用 --raw
选项。
这里我们将获取服务器上的文件列表。
php artisan remote ls --raw
使用其他主机
您可以在配置文件中定义主机。默认情况下,使用 default
主机。要使用其他主机执行命令,请使用 --host
选项。
php artisan remote cache:clear --host=my-other-host
在远程命令中使用选项
如果您需要在要执行的命令中使用标志或选项,您可以整个命令用引号括起来
php artisan remote --raw "ls -a"
测试
composer test
更新日志
请参阅更新日志以获取有关最近更改的更多信息。
贡献
请参阅贡献指南以获取详细信息。
安全漏洞
请参阅我们的安全策略以了解如何报告安全漏洞。
鸣谢
许可
MIT 许可证(MIT)。请参阅许可文件以获取更多信息。