承接 digipolisgent/robo-digipolis-deploy 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

digipolisgent/robo-digipolis-deploy

Composer 安装命令:

composer require digipolisgent/robo-digipolis-deploy

包简介

Deploy tasks for Robo Task Runner

README 文档

README

Deploy tasks for Robo Task Runner

Latest Stable Version Latest Unstable Version Total Downloads License

Build Status Maintainability Test Coverage PHP 7 ready

Tasks in this package

PushPackage

$auth = new \DigipolisGent\Robo\Task\Deploy\Ssh\Auth\KeyFile('user', '/home/myuser/.ssh/id_dsa');
$result = $this->taskPushPackage('192.168.1.1', $auth)
    ->port(8022)
    ->timeout(15)
    ->destinationFolder('/folder/on/server')
    ->package('/path/to/local/package.tar.gz')
    ->run();

SFTP

$auth = new \DigipolisGent\Robo\Task\Deploy\Ssh\Auth\KeyFile('user', '/home/myuser/.ssh/id_dsa');
$result = $this->taskSFTP('192.168.1.1', $auth)
    ->port(8022)
    ->timeout(15)
    // Download file from server.
    ->get('/path/to/remote/file.txt', '/path/to/local/file.txt')
    // Upload file to server.
    ->put('/path/to/remote/file.txt', '/path/to/local/file.txt')
    ->run();

Ssh

$auth = new \DigipolisGent\Robo\Task\Deploy\Ssh\Auth\KeyFile('user', '/home/myuser/.ssh/id_dsa');
$result = $this->taskSsh('192.168.1.1', $auth)
    ->port(8022)
    ->timeout(15)
    // Set the remote directory to execute the commands in.
    ->remoteDirectory('/path/to/remote/dir')
    ->exec('composer install')
    ->run();

SymlinkFolderFileContents

$result = $this
    ->taskSymlinkFolderFileContents('/path/to/source', '/path/to/destination')
    ->run();

As this command will most likely be used to symlink config files on a server during deployment, this task should be used in a command that runs on the server. For example:

RoboFile.php on the server (let's say 192.168.1.1 in folder /path/to/remote/dir):

<?php

class RoboFile extends \Robo\Tasks
{
    use \DigipolisGent\Robo\Task\Deploy\loadTasks;

    /**
     * Creates the symlinks.
     */
    public function symlinks($source, $dest)
    {
        $this
            ->taskSymlinkFolderFileContents($source, $dest)
            ->run();
    }
}

RoboFile.php on the build server / your local machine:

<?php

class RoboFile extends \Robo\Tasks
{
    use \DigipolisGent\Robo\Task\Deploy\loadTasks;

    /**
     * Creates the symlinks.
     */
    public function symlinks($source, $dest)
    {
        $auth = new \DigipolisGent\Robo\Task\Deploy\Ssh\Auth\KeyFile('user', '/home/myuser/.ssh/id_dsa');
        $this->taskSsh('192.168.1.1', $auth)
            ->port(8022)
            ->timeout(15)
            ->remoteDirectory('/path/to/remote/dir')
            ->exec('vendor/bin/robo symlink ' . $source . ' ' . $dest)
            ->run();
    }
}

DatabaseBackup

$filesystemConfig = [
    'local' => [
        'type' => 'Local',
        'root' => '/home/myuser/backups',
    ],
];

$dbConfig = [
    'development' => [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        'singleTransaction' => true,
        'ignoreTables' => [],
    ],
    'production' => [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        'ignoreTables' => [],
        'structureTables' => [],
        'tables' => [],
        'dataOnly' => false,
        'orderedDump' => false,
        'singleTransaction' => true,
        'extra' => '--opt',
    ],
];
// Store a backup of the development database in /home/myuser/backups/dev.sql.tar.gz.
$result = $this->taskDatabaseBackup($filesystemConfig, $dbConfig)
    ->database('development')
    ->destination('dev.sql')
    ->compression('tar')
    ->run();

DatabaseRestore

$filesystemConfig = [
    'local' => [
        'type' => 'Local',
        'root' => '/home/myuser/backups',
    ],
];

$dbConfig = [
    'development' => [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        'singleTransaction' => true,
        'ignoreTables' => [],
    ],
    'production' => [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        'ignoreTables' => [],
        'structureTables' => [],
        'tables' => [],
        'dataOnly' => false,
        'orderedDump' => false,
        'singleTransaction' => true,
        'extra' => '--opt',
    ],
];
// Restore a backup of the development database located at /home/myuser/backups/dev.sql.tar.gz.
$result = $this->taskDatabaseRestore($filesystemConfig, $dbConfig)
    ->database('development')
    ->source('dev.sql.tar.gz')
    ->compression('tar')
    ->run();

File system configuration options

More information on the configuration options for the file systems can be found at https://github.com/backup-manager/backup-manager.

Database configuration options

More information on the configuration options for the databases can be found at https://github.com/backup-manager/backup-manager. However, we provide our own MySql database handler. The configuration options are explained below:

$dbConfig = [
    'production' => [
        // Specify it's a mysql database.
        'type' => 'mysql',
        // Specify the database credentials.
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        // Tables to exclude from the export. This option will be ignored if the
        // 'tables' configuration option is set, because all tables will be
        // excluded except the ones specified in the 'tables' option. Therefore,
        // adding a table to the 'ignoreTables' would be the same as omitting it
        // from tbe 'tables' option if that option has a non-empty) value.
        'ignoreTables' => [],
        // Tables to only export the table structure for. A good example would
        // be a cache table, since most of the time you wouldn't want this
        // table's data in a backup. The structure of the tables specified here
        // will be exported even if the 'tables' configuration options has a
        // (non-empty) value and these tables are not in it.
        'structureTables' => [],
        // Tables to export. Leave empty to export all tables (except those
        // specified in the 'ignoreTables' configuration option).
        'tables' => [],
        // Export only data, not table structure.
        'dataOnly' => false,
        // Order by primary key and add line breaks for efficient diff in
        // revision control. Slows down the dump.
        'orderedDump' => false,
        // If singleTransaction is set to true, the --single-transcation flag
        // will be set. This is useful on transactional databases like InnoDB.
        // http://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_single-transaction
        'singleTransaction' => true,
        // Extra options to pass to mysqldump (e.g. '--opt --quick').
        'extra' => '--opt',

    ],
];

Commands in this package

This package provides default commands wich you can use in your RoboFile.php like so:

class RoboFile extends \Robo\Tasks
{
    use \DigipolisGent\Robo\Task\Deploy\Commands\loadCommands;
}

digipolis:database-backup

vendor/bin/robo digipolis:database-backup [DATABASE] [OPTIONS]

Use events for default configuration

Implement an on-event hook for the digipolis-db-config event to return the datbase config as specified above used by this command. For example:

/**
 * @hook on-event digipolis-db-config
 */
public function defaultDbConfig()
{
    $dbConfig = [];
    $dbConfig['default'] = [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => '$up3r$3cr3tP@$$w0rD',
        'database' => 'my_database',
        'structureTables' => [],
        'extra' => '--skip-add-locks --no-tablespaces',
    ];

    return $dbConfig;
}

Arguments

DATABASE

The database config key. See above for more details. In de given example, this argument would have to be 'production'. Defaults to 'default'.

Options

--file-system-config, -fsconf

Path to a PHP file containing filesystem config as documented at https://github.com/backup-manager/backup-manager. Defaults to the root directory of the local filesystem.

--database-config, -dbconf

Path to a PHP file containing database config as documented at https://github.com/backup-manager/backup-manager. Defaults to a database with the name of the current working directory as database name, on localhost port 3306, user root and an empty password.

--compression, -c

The compression to use for this backup. Defaults to tar.

--destination, -d

The destination file for this backup. Defaults to project.tar.gz in the current working directory.

--destination-type, -dtype

The destination type (e.g. local, dropbox, ftp). Defaults to local.

digipolis:database-restore

vendor/bin/robo digipolis:database-restore [DATABASE] [OPTIONS]

Use events for default configuration

Implement an on-event hook for the digipolis-db-config event to return the datbase config as specified above used by this command. For example:

/**
 * @hook on-event digipolis-db-config
 */
public function defaultDbConfig()
{
    $dbConfig = [];
    $dbConfig['default'] = [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => '$up3r$3cr3tP@$$w0rD',
        'database' => 'my_database',
        'structureTables' => [],
        'extra' => '--skip-add-locks --no-tablespaces',
    ];

    return $dbConfig;
}

Arguments

DATABASE

The database config key. See above for more details. In de given example, this argument would have to be 'production'. Defaults to 'default'.

Options

--file-system-config, -fsconf

Path to a PHP file containing filesystem config as documented at https://github.com/backup-manager/backup-manager. Defaults to the root directory of the local filesystem.

--database-config, -dbconf

Path to a PHP file containing database config as documented at https://github.com/backup-manager/backup-manager. Defaults to a database with the name of the current working directory as database name, on localhost port 3306, user root and an empty password.

--compression, -c

The compression of the given backup. Defaults to tar.

--source, -s

The source file to restore. Defaults to project.tar.gz in the current working directory.

--source-type, -stype

The source type (e.g. local, dropbox, ftp). Defaults to local.

digipolis:push-package

vendor/bin/robo digipolis:push-package USER HOST PACKAGE [DESTINATION] [OPTIONS]

Arguments

USER

The user to connect to the host.

HOST

The host to connect to.

PACKAGE

The package (tar-file) to push.

DESTINATION

The destination folder on the server. Defaults to the home directory of the user.

Options

--password

The password to connect to the host.

--key-file

The private key file to connect to the host.

--port

The port to connect on. Defaults to 22.

--timeout

The timeout for the connection in seconds. Defaults to 10.

digipolisgent/robo-digipolis-deploy 适用场景与选型建议

digipolisgent/robo-digipolis-deploy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 127.57k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2017 年 01 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 digipolisgent/robo-digipolis-deploy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 digipolisgent/robo-digipolis-deploy 我们能提供哪些服务?
定制开发 / 二次开发

基于 digipolisgent/robo-digipolis-deploy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 127.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 42
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-27