定制 florianmoser/bedrock-deployer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

florianmoser/bedrock-deployer

Composer 安装命令:

composer require florianmoser/bedrock-deployer

包简介

Deployer recipes for Roots Bedrock

README 文档

README

Deployer recipes for Roots Bedrock, also supports Roots Sage and Roots Trellis setups.

Trellis provides a powerful deployment with Ansible. But if you would like to deploy Bedrock only while running a custom process, Deployer is a quick and simple alternative.

Maybe you are even trying to deploy Bedrock to a shared hosting. Depending on your hosting environment, this may be possible. Check out florianmoser/plesk-deployer.

A word of caution: Make sure you have a backup of your local as well as your remote files, before experimenting with deployment recipes. Files might easily get overwritten when you provide wrong paths! You are solely responsible by using the recipes provided here.

Who needs this

PHP developers who would like to deploy their Bedrock applications using Deployer.

Installation

Use Composer:

$ composer require florianmoser/bedrock-deployer

Recipes

This package offers several recipes to help you with your Bedrock deployment. Require each package as needed.

These are the available recipes:

Bedrock DB

Provides tasks to export the database from the server and import it to your development machine and vice versa.

There is a recipe for Trellis / Vagrant as well as a recipe for Valet+ environments.

Trellis / Vagrant environment

Requirements:

  • Vagrant running on your local machine (or Trellis, of course)
  • WP CLI running on your Vagrant as well as on your remote machine

Load into your deploy.php file with:

require 'vendor/florianmoser/bedrock-deployer/recipe/bedrock_db.php';

Requires these Deployer environment variables to be set:

  • local_root: Absolute path to website root directory on local host machine
  • vagrant_dir: Absolute path to directory that contains .vagrantfile
  • vagrant_root: Absolute path to website inside Vagrant machine (should mirror local_root)

Example:

set( 'local_root', dirname( __FILE__ ) );
set( 'vagrant_dir', dirname( __FILE__ ) . '/../trellis' );
set( 'vagrant_root', '/srv/www/domain.com/current' );

Valet+ environment

Requirements:

Load into your deploy.php file with:

require 'vendor/florianmoser/bedrock-deployer/recipe/bedrock_valetplus_db.php';

Requires these Deployer environment variables to be set:

  • local_root: Absolute path to website root directory on local host machine

Example:

set( 'local_root', dirname( __FILE__ ) );

Task pull:db

Exports database on server and imports it into your local Vagrant database, while removing previous data. Creates a backup of the local database in the local_root directory, before importing the new data.

After the import, the WordPress URLs are converted from server URL to local URL, so your WordPress installation will continue to work right after the import.

Database credentials and URLs are read from remote and local .env file. So make sure, those files are up to date.

Task push:db

Exports database from local Vagrant database and imports it into your remote server, while removing previous data. Creates a backup of the remote database on the server in the current release directory, before importing the new data.

After the import, the WordPress URLs are converted from local URL to remote URL, so your WordPress installation will continue to work right after the import.

Database credentials and URLs are read from remote and local .env file. So make sure, those files are up to date.

Bedrock .env

Provides tasks to manage the .env file on the server.

Load into your deploy.php file with:

require 'vendor/florianmoser/bedrock-deployer/recipe/bedrock_env.php';

Requires no special Deployer environment variables to be set.

Task bedrock:env

Tries to copy the .env file from a previous release to current release. If there is no previous release or if no .env file is available, the .env file is created while prompting the user for credentials.

When creating a new .env file, this task also generates the WordPress salts.

Bedrock Miscellaneous

Provides miscellaneous Bedrock tasks.

Load into your deploy.php file with:

require 'vendor/florianmoser/bedrock-deployer/recipe/bedrock_misc.php';

Requires no special Deployer environment variables to be set.

Task bedrock:vendors

Runs composer install for Bedrock on your server.

Common

Provides common deployment tasks.

Requirements:

  • WP CLI running on your Vagrant as well as on your remote machine

Load into your deploy.php file with:

require 'vendor/florianmoser/bedrock-deployer/recipe/common.php';

Requires no special Deployer environment variables to be set.

Task activate:plugins

Activates all plugins on remote server.

Filetransfer

Provides tasks to upload/download files from/to synced directories.

Load into your deploy.php file with:

require 'vendor/florianmoser/bedrock-deployer/recipe/filetransfer.php';

Requires these Deployer environment variables to be set:

  • sync_dirs: Array of paths, that will be simultaneously updated with $absoluteLocalPath => $absoluteRemotePath. If a path has a trailing slash, only its content will be transferred, not the directory itself.

Example:

set( 'sync_dirs', [
    dirname( __FILE__ ) . '/web/app/uploads/' => '{{deploy_path}}/shared/web/app/uploads/',
] );

Task pull:files

Will pull all files from each $absoluteRemotePath to each $absoluteLocalPath. New files will be added, existing files will be updated, but files existing locally only will not be deleted.

To ensure no files are lost, each $absoluteLocalPath and its content are backed up in a zip file that will be added in the $absoluteLocalPath. Existing backups from previous pulls are not included in a new backup.

If you prefer to pull the files without making a backup, consider using the task pull:files-no-bak.

Task push:files

Will push all files from each $absoluteLocalPath to each $absoluteRemotePath. New files will be added, existing files will be updated, but files existing on remote server only will not be deleted.

To ensure no files are lost, each $absoluteRemotePath and its content are backed up in a zip file that will be added in the $absoluteRemotePath. Existing backups from previous pushes are not included in a new backup.

If you prefer to push the files without making a backup, consider using the task push:files-no-bak.

Sage

Provides tasks to deploy Roots Sage theme.

Requirements:

  • Roots Sage 10 (also supports Sage 9, see the included /examples/deploy.full-example.php on how to use with Sage 9)

Load into your deploy.php file with:

require 'vendor/florianmoser/bedrock-deployer/recipe/sage.php';

Requires these Deployer environment variables to be set:

  • theme_path: Path to theme, relative to release_path
  • local_root: Absolute path to website root directory on local host machine

Example:

set( 'local_root', dirname( __FILE__ ) );
set( 'theme_path', 'web/app/themes/theme-name' );

Task sage:vendors

Runs composer install inside Sage theme directory.

Task sage:assets

Compiles the Sage assets on the local machine and then uploads them to remote server in theme directory (overwriting previous assets!).

Trellis

You will not want to use these recipes to deploy Trellis. Trellis has its own and powerful deployment process. However you might use Trellis for developing and only use these recipes to deploy Bedrock.

The downside with this method is that you will have a /site as well as a /trellis directory in your repository. So both directories will be cloned to the server.

This task deals with this situation:

Task trellis:remove

Will delete the remote /trellis directory and move the content of /site to /. Use this task after deployment but before symlink changes.

florianmoser/bedrock-deployer 适用场景与选型建议

florianmoser/bedrock-deployer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.56k 次下载、GitHub Stars 达 54, 最近一次更新时间为 2017 年 06 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 florianmoser/bedrock-deployer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 54
  • Watchers: 2
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-23