Modern WordPress Development Using Bedrock Roots Composer

Modern WordPress Development Using Bedrock Roots Composer


By Akash Soni Published in Wordpress

What Is Bedrock WordPress?

Bedrock structure

Standard WordPress structure

Bedrock: Understanding Key Files and Setup

  • Composer.json: This file handles all your themes and plugins, similar to how you use NPM for JavaScript projects. It’s a tool that manages these elements in PHP.
  • Config: This folder includes different settings files for various environments. For example, in a development setting, you can turn on debugging features to see errors directly on your site.
  • Vendor: This directory is part of the Composer setup and does not directly involve WordPress files.
  • Web -> app: Here, you’ll find folders for your roots theme wordpress, plugins, and any media uploads.
  • wp-config / index.php: These files are crucial for starting your WordPress site. They determine where WordPress should look for its core files and configurations.
  • Wp: This directory contains the core files of your WordPress installation.
  • Using Composer for Dependencies: Composer helps manage your site’s plugins and core features, making it easier to work on projects with others and keep your code organized.


How to Set Up WordPress with Bedrock Roots Composer?

1. Install Bedrock: You can use Composer to create a new Bedrock project.

2. Configuration: Bedrock uses environment variables for configuration. You can define these in a .env file in the project root.

Example ‘.env’ file:

3. WordPress Core: Bedrock separates the WordPress core files into their directory (‘web/wp’). You can install WordPress using Composer:

4. Theme and Plugins: roots bedrock uses Composer to manage themes and plugins. You can add them to the ‘composer.json’  file:

Then run composer update to install them

5. Environment Configuration: Roots bedrock uses different environment files (‘.env’, ‘.env.example’, ‘.env.testing’, etc.) to manage configuration for different environments (development, staging, production).

6. Security: Bedrock includes better security practices by default, like moving sensitive files out of the web root.

7. Deployment: Use tools such as Composer or Git to deploy Bedrock. You can create deployment scripts that handle things like updating the Composer dependencies and running database migrations.

What are the benefits of bedrock WordPress?

1. Improve Security

  • To increase security Bedrock Roots Composer uploads key files from the web root, such as wp-config.php and wp-content. As a result, attackers cannot directly access the files.
  • The system reduces the risk of inadvertent disclosure of sensitive data such as database credentials, API keys, and security keys by simplifying the management of environment variables.

2. Improve Security

  • Bedrock uses environment variables to manage different configurations for different environments such as development, staging, and production environments.
  • Developers can modify their environment without manually editing configuration files, making it easier to maintain the same setup in all environments.

3..Customizable Directory Structure

  • Bedrock’s custom directory structure separates WordPress core files from themes, plugins, and uploads, making projects easy to navigate.
  • WordPress developers can easily add new themes or plugins without changing the core directory, reducing conflicts and improving code organization.

4. Easy Deployment

  • Bedrock deployments use Composer for dependency management, and it provides scripts for common tasks, such as updating dependencies, migrating databases, and clearing caches.
  • Developers can release new features and improvements to the product faster and easier using this method.