fiunchinho / plumber
面向对象部署库
dev-master
2013-05-17 18:04 UTC
Requires
- php: >=5.3.2
- monolog/monolog: *
- symfony/console: *
- symfony/event-dispatcher: *
- symfony/yaml: *
This package is not auto-updated.
Last update: 2024-09-14 13:43:49 UTC
README
面向对象部署库。这个库深受Plum库的启发,但我尝试了不同的方法。
安装和配置
Plumber遵循PSR-0规范,因此可以使用Composer自动加载器。
// Options. Here you can define which unix commands you want to execute in the server
$options = array(
'dry_run' => true, // Optional: Default to false. If set to true, Rsync will run as dry-run mode, which only shows the output but doesn't deploy anything
'rsync_exclude' => 'excludes.txt', // Optional. File used by rsync to exclude files.
'rsync_options' => '-az', // Optional: Default to "-azC --force --delete --progress". You can overwrite the default rsync parameters and use your own arguments
'commands' => array( // Optional. Commands to execute in the server being deployed. The commands'll be executed in the path defined by the server
'php app/console doctrine:schema:create',
'php app/console cache:warmup'
)
);
// Set up
$deployer = new \Plumber\Deployer\RsyncDeployer();
$ssh_command_executer = new \Plumber\Server\SshCommandExecuter( new \Plumber\Server\SshConnection() );
$plumber = new \Plumber\Plumber( $deployer, $ssh_command_executer );
// Add your server
$plumber->addServer( 'production', new \Plumber\Server\Server( 'your_server_ip_or_hostname', 'username', '/path/to/my/website' ) );
$plumber->addServer( 'dev', new \Plumber\Server\Server( 'your_server_ip_or_hostname', 'username', '/path/to/my/website' ) );
// Let's go!
$plumber->deploy( 'production', $options );
$plumber->deploy( 'dev', $options );
如果您喜欢使用git pull来部署,而不是使用rsync,可以使用虚拟rsync部署器。以下代码将连接到您定义的服务器,并在那里执行三个命令。
// Options. Here you can define which unix commands you want to execute in the server
$options = array(
'commands' => array( // Commands to execute in the server being deployed
'git pull',
'rm -rf cache/',
'php app/console assetic:dump --env=prod --no-debug'
)
);
// Set up
$no_rsync_deployer = new \Plumber\Deployer\NoRsyncDeployer();
$ssh_command_executer = new \Plumber\Server\SshCommandExecuter( new \Plumber\Server\SshConnection() );
$plumber = new \Plumber\Plumber( $no_rsync_deployer, $ssh_command_executer );
// Add your server
$plumber->addServer( 'prod', new \Plumber\Server\Server( 'your_server_ip_or_hostname', 'username', '/path/to/my/website' ) );
// Let's go!
$plumber->deploy( 'prod', $options );