cstaelen/deployer-wp-recipes

Wordpress 部署配方

0.1.0 2017-03-22 13:40 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:36:42 UTC


README

记录在案,这些配方是使用基于Bedrock(感谢roots.io的出色团队)的个人WordPress堆栈编写的,并使用phpdotenv包。但它们可以在许多其他配置中使用。

##功能

  • 使用gulp编译文件部署仓库代码
  • 同步Wordpress上传
  • 拉取和推送Wordpress数据库
  • 清理一些文件

##要求

##安装

确保将配方文件包含在您的deploy.php

require 'vendor/cstaelen/deployer-wp-recipes/recipes/assets.php';
require 'vendor/cstaelen/deployer-wp-recipes/recipes/cleanup.php';
require 'vendor/cstaelen/deployer-wp-recipes/recipes/db.php';
require 'vendor/cstaelen/deployer-wp-recipes/recipes/uploads.php';

##配置

只需在您的deploy.php中添加以下行,并使用自己的值即可

set('wp-recipes', [
    'theme_name'        => 'Your WP theme folder name',
    'theme_dir'         => 'path/to/your/theme/folder',
    'theme_dist'        => 'theme_release', // Will be rename with theme_name
    'wwwroot_dir'       => 'web', //VHOST ROOT DIR
    'shared_dir'        => '{{deploy_path}}/shared', 
    'gulp_cmd'          => 'gulp build',
    'assets_dist'       => 'path/to/theme/folder/dist',
    'local_wp_url'      => 'http://local.dev',
    'remote_wp_url'     => 'http://mywebsite.com',
    'clean_after_deploy'=>  [
        'deploy.php',
        '.gitignore',
        '*.md'
    ]
]);

##可用任务

上传您的WP数据库:dep db:push prod 下载您的WP数据库:dep db:pull prod 使用rsync同步WP上传:dep uploads:sync prod

您还可以在您的deploy.php文件中使用以下规则来编译和部署资源,并在您的预发布/生产服务器上清理一些无用的文件

after('deploy', 'deploy:assets');
after('deploy', 'deploy:cleanup');

使用phpdotenv的WP配方

如果您像出色的Bedrock WordPress堆栈那样使用phpdotenv配置您的服务器,您可以使用以下任务规则来获取填充在您的.env文件中的WP_HOME值。

before('db:cmd:pull', 'env:uri');
before('db:cmd:push', 'env:uri');

为了做到这一点,我们假设您的本地.env文件位于根项目文件夹中,而远程的位于共享文件夹中。

确保留空这些配置值

set('wp-recipes', [
	...
    'local_wp_url'      => '',
    'remote_wp_url'     => ''
    ...
]);