Code Monkey home page Code Monkey logo

deployer-extended-wordpress-composer's Introduction

deployer-extended-wordpress-composer

This package provides deploy task for deploying WordPress with deployer (deployer.org) and additionally a tasks to synchronize database and media files.

The deployment is expected to be compatible with capistrano based for https://roots.io/bedrock/

This package depends on following packages:

  1. Install package with composer:

    composer require sourcebroker/deployer-extended-wordpress-composer
    
  2. If you are using deployer as phar then put following lines in your deploy.php:

    require __DIR__ . '/vendor/autoload.php';
    new \SourceBroker\DeployerExtendedWordpressComposer\Loader();
    
  3. Remove task "deploy" from your deploy.php. Otherwise you will overwrite deploy task defined in deployer/deploy/task/deploy.php

  4. Example deploy.php file:

    <?php
    
    namespace Deployer;
    
    require_once(__DIR__ . '/vendor/sourcebroker/deployer-loader/autoload.php');
    new \SourceBroker\DeployerExtendedWordpressComposer\Loader();
    
    set('repository', 'git@my-git:my-project.git');
    
    host('live')
        ->setHostname('111.111.111.111')->port(22)
        ->setRemoteUser('www-data')
        ->set('branch', 'master')
        ->set('public_urls', ['https://www.example.com/'])
        ->set('deploy_path', '/var/www/example.com.live');
    
    host('beta')
        ->setHostname('111.111.111.111')->port(22)
        ->setRemoteUser('www-data')
        ->set('branch', 'beta')
        ->set('public_urls', ['https://beta.example.com/'])
        ->set('deploy_path', '/var/www/example.com.beta');
    
    host('dev')
        ->set('public_urls', ['https://example-com.local/'])
        ->set('deploy_path', getcwd());
    

Mind the declaration of host('dev'); Its needed for database tasks to declare domain replacements, and path to store database dumps.

Database synchronization is done with sourcebroker/deployer-extended-database. Example of command for synchronizing database from live to local instance:

dep db:pull live

You can also copy database from live to beta instance like:

dep db:copy live --options=target:beta

The "post_command" task "db:import:post_command:wp_domains" will change domains declared in "public_urls". Domain replacement is done with cli command "search-replace" from wp-cli/wp-cli.

Please mind to have the same amount of "public_urls" for each of instances because replacement on domains is done for every pair of corresponding urls.

Look at following example to give you idea:

host('live')
    ->setHostname('111.111.111.111')
    ->setRemoteUser('www-data')
    ->set('public_urls', ['https://www.example.com', 'https://sub.example.com'])
    ->set('deploy_path', '/var/www/example.com.live');

host('beta')
    ->setHostname('111.111.111.111')
    ->setRemoteUser('www-data')
    ->set('public_urls', ['https://beta.example.com', 'https://beta-sub.example.com'])
    ->set('deploy_path', '/var/www/example.com.beta');

host('dev')
    ->set('public_urls', ['https://example-com.dev', 'https://sub-example-com.dev'])
    ->set('deploy_path', getcwd());

The if you will do:

dep db:pull live

the following commands will be done automatically after database import:

wp search-replace https://www.example.com https://example-com.dev
wp search-replace https://sub.example.com https://sub-example-com.dev

In sourcebroker/deployer-extended-wordpress the WordPress and third party plugins are installed manually. What you have in git is basically only your theme. The good thing is that in such case you can update WordPress and plugins automatically. This can be considered as preferable for low budget WordPress websites.

In sourcebroker/deployer-extended-wordpress-composer the WordPress and third party plugins are installed using composer. This way you gain more control over what is installed but at the same time to install new WordPress or new plugin version you need first to modify composer.json or do composer update (depending how big upgrade you do). Then you need to commit composer.json / composer.lock and do deploy which will install new version of WordPress and plugins. This is additional work that can not be easily automated. One of additional advantages of this solution is that you can easily cleanup infected WordPress/plugins files as with each deployment all php files are fresh (part from your git and part from composer repositories).

deployer-extended-wordpress-composer's People

Contributors

kszymukowicz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

deployer-extended-wordpress-composer's Issues

How does this differ from deployer-extended-wordpress?

I'm looking into using one of these but I'm trying to figure out which might be the right choice. I noticed in deployer-extended-wordpress that you have composer.json in the root file structure example.

I guess what I'm trying to ask is when do I want to use this one over deployer-extended-wordpress?

Composer version 3.0.0 gives errors when installing.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for sourcebroker/deployer-extended-wordpress-composer ^3.0 -> satisfiable by sourcebroker/deployer-extended-wordpress-composer[3.0.0].
    - Conclusion: remove vlucas/phpdotenv v3.6.1
    - Conclusion: don't install vlucas/phpdotenv v3.6.1
    - sourcebroker/deployer-extended-wordpress-composer 3.0.0 requires sourcebroker/deployer-extended-database ^7.0.0 -> satisfiable by sourcebroker/deployer-extended-database[7.0.0, 7.0.1, 7.0.2].
    - sourcebroker/deployer-extended-database 7.0.0 requires vlucas/phpdotenv ^2.0 -> satisfiable by vlucas/phpdotenv[2.0.x-dev, 2.1.x-dev, 2.2.x-dev, 2.3.x-dev, 2.4.x-dev, 2.5.x-dev, 2.6.x-dev].
    - sourcebroker/deployer-extended-database 7.0.1 requires vlucas/phpdotenv ^2.0 -> satisfiable by vlucas/phpdotenv[2.0.x-dev, 2.1.x-dev, 2.2.x-dev, 2.3.x-dev, 2.4.x-dev, 2.5.x-dev, 2.6.x-dev].
    - sourcebroker/deployer-extended-database 7.0.2 requires vlucas/phpdotenv ^2.0 -> satisfiable by vlucas/phpdotenv[2.0.x-dev, 2.1.x-dev, 2.2.x-dev, 2.3.x-dev, 2.4.x-dev, 2.5.x-dev, 2.6.x-dev].
    - Can only install one of: vlucas/phpdotenv[2.0.x-dev, v3.6.1].
    - Can only install one of: vlucas/phpdotenv[2.1.x-dev, v3.6.1].
    - Can only install one of: vlucas/phpdotenv[2.2.x-dev, v3.6.1].
    - Can only install one of: vlucas/phpdotenv[2.3.x-dev, v3.6.1].
    - Can only install one of: vlucas/phpdotenv[2.4.x-dev, v3.6.1].
    - Can only install one of: vlucas/phpdotenv[2.5.x-dev, v3.6.1].
    - Can only install one of: vlucas/phpdotenv[2.6.x-dev, v3.6.1].
    - Installation request for vlucas/phpdotenv (locked at v3.6.1, required as ^3.4.0) -> satisfiable by vlucas/phpdotenv[v3.6.1].

It's conflicting with the new version of vlucas/phpdotenv.

Can you please publish the latest version on composer packagist.org registry? The master branch seems be ahead of 3.0.0 tag.

If I install the package directly from github repo, then this doesn't happen.

v4 - db:backup - Call to undefined function Deployer\server()

Hi @kszymukowicz ,

Thanks for the update to deployer v6, so great.

I have upgraded deploy config as mantinoned on doc, as server() became host(), everything seems ok until the db:backup task, the deploy failedwith the error Call to undefined function Deployer\server() .

Any idea why ? if I disable the db:backup and db:truncate tasks, everything deploy ok.

Thanks for your help, stay safe,
Sylvain

Composer version required: "sourcebroker/deployer-extended-wordpress-composer": "^4.0"

Full error log

The command "cd /xxx/app/wp/release && /usr/bin/php7.3 /xxx/app/wp/release/vendor/bin/dep db:export --options=dumpcode:backup_for_release_26_7c20c514aca137c251ae626c8951ae4  
  6 " failed.                                                                                                                                                                       
                                                                                                                                                                                    
  Exit Code: 1 (General error)                                                                                                                                                      
                                                                                                                                                                                    
  Host Name: staging                                                                                                                                                                
                                                                                                                                                                                    
  ================                                                                                                                                                                  
                                                                                                                                                                                    
   [Error] Call to undefined function Deployer\server()                                                                                                                             
                                                                                                                                                                                    
   #0                                                                                                                                                                               
   phar:///xxx/app/wp/releases/26/vendor/deployer/dist/dep/src/Deployer.php(388)                                                                                                  
   : require()                                                                                                                                                                      
   #1 [internal function]: Deployer\Deployer::Deployer\{closure}()                                                                                                                  
   #2                                                                                                                                                                               
   phar:///xxx/app/wp/releases/26/vendor/deployer/dist/dep/src/Deployer.php(396)                                                                                                  
   : call_user_func(Object(Closure))                                                                                                                                                
   #3                                                                                                                                                                               
   phar:///xxx/app/wp/releases/26/vendor/deployer/dist/dep/src/Deployer.php(322)                                                                                                  
   : Deployer\Deployer::loadRecipe('/xxx/app/wp/r...')                                                                                                                            
   #4 phar:///xxx/app/wp/releases/26/vendor/deployer/dist/dep/bin/dep(134):                                                                                                       
   Deployer\Deployer::run('6.6.0', '/xxx/app/wp/r...')                                                                                                                            
   #5 /xxx/app/wp/releases/26/vendor/deployer/dist/dep(4):                                                                                                                        
   require('phar:///xxx/a...')                                                                                                                                                    
   #6 {main}                                          

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.