### Create New Bedrock Project with Composer Source: https://context7.com/roots/bedrock/llms.txt Use this command to initialize a new Bedrock project. It installs the boilerplate, WordPress core, and dependencies. ```bash composer create-project roots/bedrock my-wordpress-site ``` ```bash cd my-wordpress-site ``` ```bash cp .env.example .env ``` ```bash composer install ``` -------------------------------- ### Docker Compose Setup for Bedrock Source: https://context7.com/roots/bedrock/llms.txt Defines services for the application, web server (Nginx), and database (MariaDB) within a Docker environment. Ensures the database is healthy before the app starts. ```yaml # .devcontainer/docker-compose.yml services: app: build: context: . dockerfile: Dockerfile volumes: - ..:/roots/app - ./config/php.ini:/usr/local/etc/php/conf.d/bedrock.ini networks: - bedrock depends_on: database: condition: service_healthy environment: WP_CLI_ALLOW_ROOT: 1 web: image: nginx:alpine ports: - '8080:80' volumes: - ..:/roots/app:ro - ./config/nginx.conf:/etc/nginx/conf.d/default.conf:ro depends_on: - app networks: - bedrock database: image: mariadb:12 environment: MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: password MYSQL_ROOT_PASSWORD: password networks: - bedrock healthcheck: test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] timeout: 20s retries: 10 networks: bedrock: driver: bridge ``` -------------------------------- ### DevContainer Start Command Source: https://context7.com/roots/bedrock/llms.txt Instructions for starting the DevContainer in VS Code. Access WordPress via the specified localhost URL. ```bash # Start DevContainer (VS Code) # Open project folder, then: Ctrl+Shift+P -> "Dev Containers: Reopen in Container" # Access WordPress at http://localhost:8080 # WordPress admin at http://localhost:8080/wp/wp-admin ``` -------------------------------- ### Write Feature Tests with Pest Source: https://context7.com/roots/bedrock/llms.txt Example of a basic feature test using Pest for PHP. Demonstrates testing a simple assertion and checking for defined WordPress constants and configurations. ```php toBeTrue(); }); test('wordpress constants are defined', function () { expect(defined('WP_ENV'))->toBeTrue(); expect(WP_ENV)->toBeIn(['development', 'staging', 'production']); }); test('content directory is configured', function () { expect(defined('CONTENT_DIR'))->toBeTrue(); expect(CONTENT_DIR)->toBe('/app'); }); ``` -------------------------------- ### Configure Database URL Source: https://context7.com/roots/bedrock/llms.txt Configure database connection using a single DATABASE_URL environment variable. Supports standard DSN format and examples for various platforms like local Docker, AWS RDS, and PlanetScale. ```bash # .env - Using DATABASE_URL instead of individual variables # Standard DSN format DATABASE_URL='mysql://username:password@hostname:3306/database_name' # Examples for various platforms # Local Docker DATABASE_URL='mysql://wordpress:password@database:3306/wordpress' # AWS RDS DATABASE_URL='mysql://admin:secretpass@mydb.123456789.us-east-1.rds.amazonaws.com:3306/production' # PlanetScale DATABASE_URL='mysql://user:pscale_pw_xxx@aws.connect.psdb.cloud/mydb?sslaccept=strict' ``` -------------------------------- ### Composer Commands for Plugin and Theme Management Source: https://context7.com/roots/bedrock/llms.txt Installs, updates, and manages WordPress plugins and themes using Composer. Use `composer update` to fetch the latest versions. ```bash # Install plugins from WordPress Packagist composer require wpackagist-plugin/advanced-custom-fields composer require wpackagist-plugin/wordpress-seo # Install themes composer require wpackagist-theme/flavor # Update WordPress core composer update roots/wordpress # Update all dependencies composer update ``` ```bash # Install a plugin as mu-plugin (always active) composer require wpackagist-plugin/redis-cache --dev ``` -------------------------------- ### Composer Configuration for WordPress Dependencies Source: https://context7.com/roots/bedrock/llms.txt Manages WordPress core, plugins, and themes as Composer dependencies. Configure installer paths for correct placement. ```json { "name": "my-company/wordpress-site", "repositories": [ { "type": "composer", "url": "https://wpackagist.org" }, { "type": "composer", "url": "https://repo.wp-packages.org" } ], "require": { "php": ">=8.3", "roots/bedrock-autoloader": "^1.0", "roots/wordpress": "6.9.4", "wpackagist-plugin/advanced-custom-fields": "^6.0", "wpackagist-plugin/wordpress-seo": "^22.0", "wpackagist-theme/flavor": "^1.0" }, "extra": { "installer-paths": { "web/app/mu-plugins/{$name}/": ``` ```json "type:wordpress-muplugin", "wpackagist-plugin/my-critical-plugin" ] } } } ``` ```json "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"], "web/app/plugins/{$name}/": ["type:wordpress-plugin"], "web/app/themes/{$name}/": ["type:wordpress-theme"] }, "wordpress-install-dir": "web/wp" } } ``` -------------------------------- ### DevContainer Configuration for Local Development Source: https://context7.com/roots/bedrock/llms.txt Sets up a development environment using Docker Compose. The `postCreateCommand` copies the `.env.example` to `.env`. ```json // .devcontainer/devcontainer.json { "name": "Bedrock Development", "dockerComposeFile": ["docker-compose.yml"], "service": "app", "workspaceFolder": "/roots/app", "forwardPorts": [8080], "remoteEnv": { "WP_ENV": "development" }, "postCreateCommand": "cp -n /roots/app/.devcontainer/.env.example /roots/app/.env" } ``` -------------------------------- ### Configure Bedrock Environment Variables Source: https://context7.com/roots/bedrock/llms.txt Edit the `.env` file to set database credentials, environment type, site URLs, and security keys. Sensitive information should be stored here. ```dotenv # .env file configuration # Database credentials (required) DB_NAME='my_database' DB_USER='my_user' DB_PASSWORD='secure_password' DB_HOST='localhost' DB_PREFIX='wp_' # Alternative: Use DATABASE_URL (replaces individual DB_* variables) # DATABASE_URL='mysql://user:password@host:3306/database_name' # Environment and URLs (required) WP_ENV='development' # Options: development, staging, production WP_HOME='https://example.com' WP_SITEURL="${WP_HOME}/wp" # Security keys (generate at https://roots.io/salts.html) AUTH_KEY='unique-random-string' SECURE_AUTH_KEY='unique-random-string' LOGGED_IN_KEY='unique-random-string' NONCE_KEY='unique-random-string' AUTH_SALT='unique-random-string' SECURE_AUTH_SALT='unique-random-string' LOGGED_IN_SALT='unique-random-string' NONCE_SALT='unique-random-string' # Optional settings # WP_DEBUG_LOG='/path/to/debug.log' # DISABLE_WP_CRON=true # WP_POST_REVISIONS=5 ``` -------------------------------- ### Staging Environment Configuration Source: https://context7.com/roots/bedrock/llms.txt Sets up configuration for the staging environment, keeping it close to production with indexing disabled. Debugging can be optionally enabled. ```php path, 1)); Config::define('DB_USER', $dsn->user); Config::define('DB_PASSWORD', isset($dsn->pass) ? $dsn->pass : null); Config::define('DB_HOST', isset($dsn->port) ? "{$dsn->host}:{$dsn->port}" : $dsn->host); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.