madalynn/plum-bundle

一个基于 Symfony2 的部署包。

安装数: 9,681

依赖者: 0

建议者: 0

安全性: 0

星标: 26

关注者: 4

分支: 6

类型:symfony-bundle

dev-master 2012-04-10 14:25 UTC

This package is not auto-updated.

Last update: 2024-09-22 02:26:52 UTC


README

PlumBundle 是一个使用多个部署者的部署包。

安装和配置

如果你使用 deps 文件,只需添加

[plum]
    git=https://github.com/aerialls/Plum.git

[MadalynnPlumBundle]
    git=https://github.com/aerialls/MadalynnPlumBundle.git
    target=bundles/Madalynn/Bundle/PlumBundle

或者通过 Git

git clone https://github.com/aerialls/MadalynnPlumBundle.git vendor/bundles/Madalynn/Bundle/PlumBundle
git clone https://github.com/aerialls/Plum.git vendor/plum

或者通过 Composer

"require": {
    "madalynn/plum-bundle": "dev-master"
},

你需要在你的 autoload.php 中添加(如果你使用 Composer 则不是必需的):

// app/autoload.php
$loader->registerNamespaces(array(
    // ...
    'Madalynn' => __DIR__.'/../vendor/bundles',
    'Plum'     => __DIR__.'/../vendor/plum/src'
));

并且将 MadalynnPlumBundle 添加到你的 Kernel 中(仅针对开发/测试环境)。

// app/AppKernel.php
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
    // ...
    $bundles[] = new Madalynn\Bundle\PlumBundle\MadalynnPlumBundle();
}

部署者

默认情况下,Plum 提供了 2 个提供者: Plum\Deployer\RsyncDeployerPlum\Deployer\SshDeployer。以下是每个提供者的选项

  • Plum\Deployer\RsyncDeployer
  • dry_run
  • rsync_exclude
  • Plum\Deployer\SshDeployer
  • dry_run
  • commands

你可以通过使用 Plum\Deployer\DeployerInterface 接口添加自己的部署者。

配置示例

# app/config/config_dev.yml
madalynn_plum:
    options: # Global options
        dry_run: false
        rsync_exclude: "%kernel.root_dir%/config/rsync_exclude.txt"
        commands:
            - 'php app/console cache:clear --env=prod --no-debug'
    deployers:
        - Plum\Deployer\RsyncDeployer
        - Plum\Deployer\SshDeployer
        - Acme\Deployer\MyCustomDeployer
    servers_file: "%kernel.root_dir%/config/deployment.yml"

这里的目的是将服务器配置与其它部分分离。这样就可以将 deployment.yml 添加到排除文件中。

# app/config/deployment.yml
servers:
    production:
        host: prod.mywebsite.com
        user: webuser
        dir: /var/www/mywebsite
        port: 2321 # Optional, default 22
        password: myPaSsWoRd # Just for the SSH deployer
        options: # Server options, override the globals
            dry_run: %kernel.debug%
    dev:
        host: dev.mywebsite.com
        user: webuser
        dir: /var/www/mywebsite2

开始部署

php app/console plum:deploy production --no-debug

你可以通过额外的参数指定自定义的部署者。

php app/console plum:deploy production rsync,ssh