WP-CLI and EasyEngine

EasyEngine v4 is built using WP-CLI codebase. This is a bit different than WP-CLI commands packages you see all over. We used WP-CLI as a framework as explained below.

WP-CLI as a CLI framework

Back when the development of EasyEngine v4 hadn’t started, we had already decided to move away from Python and towards PHP.

At that time, we were looking at how CLI apps were made in PHP and which framework to build v4 on. We evaluated many options like Symphony Console, Laravel, Lumen and wp-cli. Out of all these, the one that fit our needs best was wp-cli.

Here are things we liked about it:

  • Community familiarity 
  • Commands in separate repository
  • Managing documentation is easy
  • Extensible

Community familiarity

Most of the EasyEngine community are WordPress users and hence most of them are familiar with wp-cli. This will mean there will be less learning curve for existing and new EasyEngine users. Also, chances are, if someone has already contributed to wp-cli, they will easily be able to contribute to EasyEngine and vice-versa.

Commands in separate repository

All commands in wp-cli live in their own repositories. We really liked this way of separating concerns.

Managing documentation is easy

When you type ee help site, the help that you see is being generated from corrosponding class/function’s docblock! Hence whenever you make changes in code, to make changes in help/documentation, you don’t have to make changes in another directory or repository. You just have to change the docblock and the help text will change.

Further, all readme for all their repositories are generated via automation from docblocks. A setup like this would really ease the burden of maintaining documenetaiton.

Extensible

wp-cli is also extensible through custom packages. You can develop your own commands and add them to wp-cli easily!

Result

We decided to use WP-CLI as a base framework on top of which we’ll develop EasyEngine v4.

So on February 8, 2018, we started off EasyEngine v4 development from wp-cli v2.0.0-alpha at this commit.

Modifications

After using wp-cli as a base, there are only 3 major modifications that we did to the wp-cli core:

  1. Remove all WordPress specific code. Those codes were unrelated to EasyEngine’s capabilities around WordPress site management.
  2. Add support for routing of site types in a ee site command. This was required so that in future more site types support can be added easily.
  3. Add database wrapper and data migrations support so that EasyEngine can manage it’s own database & upgrades.

Apart from these numerous small modifications were made.

Current Status

Since the point we started developing v4, we haven’t been able to sync up much with wp-cli as our focus was on many things like finding the right architectute, developing commands.

We tried to get the changes from wp-cli 2.0 into EasyEngine but we realized it would take non-trivial effort to do it and so postponed it. Once v4 gets out and things settle down, we will try to keep EasyEngine in sync by periodically pulling changes from it.

We will also try our best to contribute back any improvements we make to wp-cli, if they make sense to the that project. 

Subpages