Bedrock Modern WordPress Stack

Bedrock Modern WordPress Stack is a package that helps you set up a WordPress environment at lighning speed with Ansible and Vagrant to work on a site locally or on a server. It setups a better folder structure, makes loading plugins easier, takes care of deployment and puts your WordPress credentials in a safer place.

Features of Bedrock Modern WordPress Stack

Bedrock Modern WordPress Stack is modern because it is using the latest techniques out there to make WordPress development professional fast and easy. I will go though the main features now here below.

Composer

In the case of Roots Bedrock it uses composer for the installation of WordPress, phpdotenv and the management of all plugins. Composer is a dependency manager like NPM or bundler for Ruby and helps you manage PHP packages. You can read more about Composer working together with WordPress here, but the  magic of it in Roots projects is that it will automagically install WordPress for you and the earlier mentioned php packages that have been included in the json file. It also allows you to update your installation with easse and add plugins to your setup that will be maintained by composer as well as long as you add the plugin to the json file.

PHP dotenv

PHP dotenv is a setup in which environmental variables are loaded from a .env file. As the author states: “You should never store sensitive credentials in your code. Storing configuration in the environment is one of the tenets of a twelve-factor app.” So basically this is a safer way to store your WordPress configuration data instead of the storing it in a .php file

Folder Structure

It uses a better folder structure.

bedrock site tree

In their wiki Roots explains why the structure is better. Let me summarize it for you:

  • All required files are moved into web and all others are put into separate folders that do not have to be exposed in the webroots
  • wp-content is renamed to make clearer what is in there.
  • wp-config.php does stay in the web folder  because that is a requirement by WordPress, but the actual configuration files have been moved as explained earlier
  • vendor is where all composer dependencies are stored and that is where the WordPress core files live too. They are files you need for your app whether it is your plugin or theme.

MU Plugin Auto Loader

Bedrock has an option that allows standard plugins to be required and installed via Composer. Foxaii explains the benefits of this at Roots Discourse:

It enables must-use plugins to be installed via composer and it enables you to declare standard plugins as must-use (meaning that they don’t need to be activated manually and cannot be deactivated from the dashboard).

WP CLI

WP CLI is also included and it is a great command line tool to manipulate WordPress. You can do almost anything you would normally do from the Dashboard with WordPress Core tools or plugins, but with simple commands and less overhead. A few examples:

  • wp plugin install hello-dolly
  • wp import /path/to/file – to import wxr file into WordPress with all content or whatever the WXR package contains
  • wp any-ipsum – with plugin installed
  • wp backupbuddy backup 2 – do a full BackupBuddy backup
  • wp acf status – provides a list of found field-groups in the current database of your WordPress project.

Bedrock Ansible

Bedrock-Ansible is basically an extension of Bedrock and helps you with easing the deployment of sites and management of sites locally, on staging and production environments. With the awesome use of Roots’ Ansible Playbook you can setup a WordPress environment locally with the entire Bedrock structure, put together a Vagrant Box that runs NGINX, PHP 5.6, MariaDB and WordPress with a database by just filling in a few variables. To me this is what truly makes Bedrock awesome.

To quote from the Bedrock Ansible github page:

Bedrock-ansible will configure a server with the following and more:

  • Ubuntu 14.04 Trusty LTS
  • Nginx (with optional FastCGI caching)
  • PHP 5.6 (or HHVM)
  • MariaDB as a drop-in MySQL replacement (but better)
  • sSMTP (mail delivery)
  • Memcached
  • Composer
  • WP-CLI
  • Fail2ban
  • ferm
  • SSL support

And this my friends is truly awesome.

Deployment

Not only does this get setup locally, but options can be added to push all this to a staging server and or production server. Ansible has var files in which you add your WordPress Dashboard user details, database details, url and so on. This can be done for the local, staging and production server. And you get to add connection details too so you can push all to the server using a shell script.

More on Bedrock Ansible in a soon to be published post. Here is the WordPress LEMP Stack Management with Trellis Post

Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.