desarrolla2/download-bundle

此包提供 symfony2 的下载工具

安装次数: 22,557

依赖项: 0

建议者: 0

安全性: 0

星标: 4

关注者: 4

分支: 3

公开问题: 0

类型:symfony-bundle

1.10.0 2022-11-16 12:54 UTC

This package is auto-updated.

Last update: 2024-09-21 20:33:24 UTC


README

此包允许您从远程主机下载数据库和与项目相关的文件夹到本地机器。这是在开发环境中拥有相同生产数据的最简单方式。

该包通过 ssh 连接工作,因此您需要配置通过公钥连接。

免责声明:此包仅适用于具有 Linux 的环境。

安装

下载包。

composer require --dev "desarrolla2/download-bundle"

启用包

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        // enable it only for dev environment
        if (in_array($this->getEnvironment(), ['dev'], true)) {
            $bundles[] = new Desarrolla2\DownloadBundle\DownloadBundle();
        }

        // ...
    }

    // ...
}

配置

您需要在您的 config_dev.yml 中添加类似以下内容

download:
    user: 'deploy_user'
    host: 'production_host_or_ip'

    # optional parameter. use it if you want customize max proccess time
    timeout: 300

    database:
        # local directory to save databases
        directory: '%kernel.root_dir%/../var/data/databases'
        
        # optional parameter. use it for tables that you just want to download the structure, not data
        only_structure:
          - 'mail_history'

        remote:
            host: 'production_database_host'
            name: 'production_database_name'
            user: 'production_database_user'
            password: 'production_database_password'           

        local:
            host: '%database_host%'
            name: '%database_name%'
            user: '%database_user%'
            password: '%database_password%'

        # optional parameter. define max number of database files to keep on local directory
        max_local_db: 0

    # some directories that you want download.
    directories:
        web_uploads:
            remote: '/path/to/project/web/uploads'
            local: '%kernel.root_dir%/../web'
            # you can exclude some directories from there
            exclude:
                - 'cache'

        var_data:
            remote: '/path/to/project/var/data'
            local: '%kernel.root_dir%/../var'
            exclude:
                - 'spool'            
            

使用方法

下载

当您执行此命令时,数据库和目录将从远程环境下载。

php bin/console downloader:download

您将在命令行中看到以下内容。

screenshot

加载

也许您想将本地数据库恢复到之前的状态。此包会保存您每次下载的副本,因此回到这些状态非常简单。

php bin/console downloader:load

从可用日期中选择。

screenshot

您将在命令行中看到以下内容。

screenshot

删除旧数据库

从本地目录中删除旧数据库。您可以保留的最大文件数由 max_local_db 参数定义

php bin/console downloader:delete:old

联系

您可以通过 @desarrolla2 联系我。