Why Bedrock?
Standard WordPress installations mix core files with your custom code. Bedrock separates them, manages plugins via Composer, and uses `.env` files for configuration.
Key Concepts
- Composer: Manage plugins and themes as dependencies.
- Environment Variables: Keep secrets out of the codebase.
- Folder Structure: `web/app` instead of `wp-content`.
1. The Bedrock Structure
Unlike standard WP, Bedrock looks like a modern PHP app:
├── config/ # WP configuration
├── web/
│ ├── app/ # wp-content (themes, plugins)
│ └── wp/ # WP Core (Git ignored)
├── .env # Secrets
└── composer.json # Dependencies
2. Installing Bedrock
Start a new project:
composer create-project roots/bedrock my-project
3. Environment Variables
Configure your `.env` file for local development:
DB_NAME='my_db'
DB_USER='db_user'
DB_PASSWORD='db_password'
WP_HOME='http://my-project.test'
WP_SITEURL="${WP_HOME}/wp"
4. Managing Plugins with Composer
Install plugins from WordPress Packagist:
composer require wpackagist-plugin/wordpress-seo
composer require wpackagist-plugin/timber-library
5. Database: PostgreSQL via PG4WP
We are moving away from MySQL. Install the PG4WP driver:
- Download `pg4wp` and place it in `web/app/db.php`.
- Update `.env` to point to your PostgreSQL instance.
6. Redis Object Cache
Configure Redis for high-performance object caching:
composer require wpackagist-plugin/redis-cache
Add to `config/application.php`:
Config::define('WP_REDIS_HOST', env('REDIS_HOST'));
7. NocoDB Integration Setup
We will use NocoDB as an external data source. Install the HTTP client:
composer require guzzlehttp/guzzle
8. Custom Directory Structure
Understand where your code goes:
- Themes: `web/app/themes/`
- Plugins: `web/app/plugins/` (Git ignored if managed by Composer)
- Mu-Plugins: `web/app/mu-plugins/` (Autoloaded)
9. Security Hardening
Bedrock secures your site by default:
- Web Root: Only `web/` is exposed to the public.
- Passwords: Salt keys are defined in `.env`.
- Disallow File Edit: `DISALLOW_FILE_EDIT` is true by default.
10. Deployment Workflow
With Bedrock, you deploy the entire application artifact, not just theme files. This ensures consistency across environments.