Maybe not a complete solution for managing WordPress as a nerd but close to it 🤓
This repo is intended to be used as a starter point when developing a new site but also easy enough to convert an existing project to this workflow.
What this project tries to achieve is to give you a way to be sure that you have as much as possible under control when managing WordPress sites from the developer's perspective.
[TODO] I'll make a micro site to explain the whys and hows of this project. For now basic usage instructions will be given in this readme file to use it.
This setup might not be suitable for all kinds of environments or may need some adjustments to work properly with your either local or production server.
Pull requests are welcome as long as they are addressing compatibility issues, fixing bugs or adding features that will make it more flexible. Any PR that just changes stuff to make it work with a specific environment will be rejected, instead find a proper way to provide compatibility with that environment without breaking others.
- Clone this repository
git clone REPO_LINK my-project
- Run
composer install
- Rename
.env.example
andwp-cli.yml.example
to.env
andwp-cli.yml
- Create your database if you haven't already
- Fill in the details in
.env
andwp-cli.yml
for the environment you're working on - Point your web root to the
/public
directory - Now visit the website and follow install instructions or import your database
- Optionally, you can import the official WPTRT dummy data to have something to work with
Bonus: To fix weird behaviours with WP-ClirRename wp-cli.yml.example
to wp-cli.yml
and edit contents accordingly.
[TODO]
[TODO]
For the deploying process we opted for Deployer because of its ease of use, the built-in atomic deployments (aka zero downtime deployments) and it's free!
Deployer is required dev dependency.
- You have SSH access to the server
- You have an SSH key on the server linked to your GitHub account/repository for the pulls. (I'll make a tuto on this one)
Note: If you're running on production copy local-config.sample.php
to production-config.php
.
Deployer will help you with the deployment of the site (just the files for now).
Basically the way Deployer works is:
- It connects via SSH to your server
- Clones your repository on the server
- Installs dependencies
- Symlinks the
current
folder to the latest release
That means you need to trigger the deploy manually, it will not pull the repo whenever you push to master/production/whatever-branch-you-set (aka Push To Deploy).
First of all open a terminal, cd into your project if you haven't already and check that you have access to the tool by typing dep test localhost
.
You should be getting this output:
$ dep test localhost
➤ Executing task test
Hello world! 🤓
✔ Ok
If you don't have deployer installed globally use vendor/bin/dep test localhost
instead. Same output should be produced.
Once you get that output we know Deployer is reachable and ready to get instructions.
Now rename hosts.yml.example
to hosts.yml
and fill in the server details.
If you want more info about the available options and how it works read the Deployer docs.
In this file you store all the info that Deployer needs to deploy your site on your server. The info provided is for just one server but you can extend it to have multiple server or even multiple stages on same or different servers.
You can read more about the inventory file here.
Check that your webroot on the server is pointing to …/current/public
because that's the folder where our current release is going to be loaded.
Once again check that you've got your hosts.yml
details in and you filled the # Deploy Settings
block of the .env
file and then 🔥
$ dep deploy production
or
$ vendor/bin/dep deploy production
If everything went well you should see the entire process going on your terminal.
If it doesn't.. read the errors, fix them and try again, still not working? Re-read the errors fix them and try again. Still not 🤬 working? Open an issue and I will try to help.
Let's asume your deployment was correct, now if you visit the website you will see an error about the .env file, that's fine.
As a one time operation you'll have to manually upload a .env file (with the correct settings for production) to the same folder we are deploying to (see hosts.yml).
Now you have two options.. you can import a database (not going to explain this as it's out of the scope) or proceed installing from scratch by visiting http(s)://yourdomain.com/wp
This project as many others is based and inspired on others work and we want to thank them for their contribution to the open source community.
- @markjaquith and his WordPress-Skeleton
- @gilbitron and his wordpress-skeleton and his article Managing Your WordPress Site With Git And Composer which made me start building my own solution.
- @laravel and their awesome framework
- @deployphp and his Deployment Tool
- And many others I can't remember.. if you are one of them please Fork and PR with your name.