rimi-itk / remote-commands
通过 ssh 运行 Drupal 和 Symfony 命令行命令
1.8
2023-10-25 08:38 UTC
Requires
- php: ^8.0
- ext-json: *
- ext-posix: *
- psr/log: ^1.1
- symfony/console: ^5.4
- symfony/options-resolver: ^5.4
- symfony/process: ^5.4
Requires (Dev)
README
帮助:通过 ssh
访问远程主机运行命令
安装
composer global require rimi-itk/remote-commands
补全
eval "$(remote-drupal-drush --completion)"
辅助工具
@待办事项
使用方法
运行
bin/remote-command --help
配置
所有主机的配置都是在您的 OpenSSH 客户端配置文件 (~/.ssh/config
) 中完成的。
假设以下配置已在 ~/.ssh/config
中设置
# https://man.openbsd.org/ssh_config#IgnoreUnknown
IgnoreUnknown DRUPAL_*,SYMFONY_*
Host drupal.example.com
…
DRUPAL_DRUSH_ROOT /data/www/drupal/htdocs/web
DRUPAL_DRUSH_DRUSH ../vendor/bin/drush
DRUPAL_DRUSH_URI https://drupal.example.com
…
# Example with docker-compose
Host drupal.example.com
…
DRUPAL_DRUSH_DRUSH docker-compose --env-file .env.docker.local --file docker-compose.server.yml exec phpfpm vendor/bin/drush
# The directory to change to before running the drush command
DRUPAL_DRUSH_CWD /data/www/drupal/htdocs
# Drush root inside docker container
DRUPAL_DRUSH_ROOT /app
…
Host symfony.example.com
…
SYMFONY_CONSOLE_ROOT /data/www/symfony/htdocs
…
# Example with docker-compose
…
SYMFONY_CONSOLE_ROOT /data/www/symfony/htdocs
SYMFONY_CONSOLE_CONSOLE itkdev-docker-compose-server exec phpfpm bin/console
然后运行 remote-command drupal:drush drupal.example.com
将相当于运行 ssh -t drupal.example.com drush --root=/data/www/drupal/htdocs --uri=https://drupal.example.com
。
快捷方式
remote-drupal-drush
是remote-command drupal:drush
的快捷方式remote-symfony-console
是remote-command symfony:console
的快捷方式
将命令添加到您的 PATH
如果您正在使用 bash
shell,请运行
echo 'export PATH="'$(git rev-parse --show-toplevel)/bin:$PATH"' >> ~/.bashrc
以将命令添加到您的 PATH
。如果您正在运行 zsh
,请运行
echo 'export PATH="'$(git rev-parse --show-toplevel)/bin:$PATH"' >> ~/.zshrc