### Install Sage using Composer Source: https://github.com/roots/docs/blob/docs/sage/installation.md Run this command in your WordPress themes directory to install the stable version of Sage. ```shell $ composer create-project roots/sage your-theme-name ``` -------------------------------- ### Install Livewire with Composer Source: https://github.com/roots/docs/blob/docs/acorn/using-livewire-with-wordpress.md Install the Livewire package using Composer. This is the first step to integrating Livewire into your project. ```bash composer require livewire/livewire ``` -------------------------------- ### Basic Controller Example Source: https://github.com/roots/docs/blob/docs/acorn/controllers-middleware-kernel.md An example of a basic controller demonstrating methods for fetching posts, showing a single post, and creating a new post with validation. ```APIDOC ## Basic controller example ```php latest('ID') ->take(10) ->get(); return response()->json($posts); } public function show(int $id): JsonResponse { $post = Post::findOrFail($id); return response()->json($post); } public function store(Request $request): JsonResponse { $validated = $request->validate([ 'title' => 'required|max:255', 'content' => 'required', 'status' => 'in:draft,publish' ]); $post = Post::create([ 'post_title' => $validated['title'], 'post_content' => $validated['content'], 'post_status' => $validated['status'] ?? 'draft', 'post_type' => 'post', 'post_author' => get_current_user_id() ?: 1, ]); return response()->json($post, 201); } } ``` ``` -------------------------------- ### Install Acorn with Composer Source: https://github.com/roots/docs/blob/docs/acorn/installation.md Run this command in your WordPress project root to install Acorn. This requires a Composer-based WordPress setup. ```bash composer require roots/acorn ``` -------------------------------- ### Working with WordPress Data Controller Example Source: https://github.com/roots/docs/blob/docs/acorn/controllers-middleware-kernel.md An example controller demonstrating how to interact with WordPress functions like `wp_insert_post` to create posts programmatically. ```APIDOC ## Working with WordPress data ```php validate([ 'title' => 'required|max:255', 'content' => 'required', ]); $post_id = wp_insert_post([ 'post_title' => $validated['title'], 'post_content' => $validated['content'], 'post_status' => 'publish', 'post_type' => 'post', ]); return response()->json(['id' => $post_id], 201); } } ``` ``` -------------------------------- ### Install Linting Dependencies Source: https://github.com/roots/docs/blob/docs/sage/adding-linting.md Install the necessary Bud extensions and ESLint configuration as development dependencies. ```bash yarn add @roots/bud-eslint -D yarn add @roots/bud-prettier -D yarn add @roots/bud-stylelint -D yarn add @roots/eslint-config -D ``` -------------------------------- ### Install Latest Development Version of Sage Source: https://github.com/roots/docs/blob/docs/sage/installation.md To install the latest development version, append `dev-main` to the Composer create-project command. ```shell $ composer create-project roots/sage your-theme-name dev-main ``` -------------------------------- ### Install WordPress Core Source: https://github.com/roots/docs/blob/docs/trellis/install-wordpress-language-files.md This command installs WordPress core, which is a prerequisite for installing language files on a non-transferred site during the initial deploy. It handles both single-site and multisite installations. ```yaml - name: Install WP (required for installing languages on non-transferred site) command: wp core {{ project.multisite.enabled | default(false) | ternary('multisite-install', 'install') }} --allow-root --url="{{ site_env.wp_home }}" {% if project.multisite.enabled | default(false) %} --base="{{ project.multisite.base_path | default('/') }}" --subdomains="{{ project.multisite.subdomains | default('false') }}" {% endif %} --title="{{ project.site_title | default(site) }}" --admin_user="{{ project.admin_user | default('admin') }}" --admin_password="{{ vault_wordpress_sites[site].admin_password }}" --admin_email="{{ project.admin_email }}" args: chdir: "{{ deploy_helper.current_path }}" register: wp_install changed_when: "'WordPress is already installed.' not in wp_install.stdout and 'The network already exists.' not in wp_install.stdout" ``` -------------------------------- ### Configure Bedrock Environment Variables Source: https://github.com/roots/docs/blob/docs/bedrock/bedrock-with-local.md Copy the example environment file and update it with Local's database credentials and the site's home URL. ```shell cp .env.example .env ``` ```plaintext DB_NAME='local' DB_USER='root' DB_PASSWORD='root' WP_HOME='https://bedrock.local' ``` -------------------------------- ### Install Valet WP-CLI Command Source: https://github.com/roots/docs/blob/docs/bedrock/bedrock-with-valet.md Install the Valet WP-CLI command to manage Bedrock sites with Valet. ```shell wp package install aaemnnosttv/wp-cli-valet-command:@stable ``` -------------------------------- ### Install Bootstrap and Popper.js Source: https://github.com/roots/docs/blob/docs/sage/bootstrap.md Install Bootstrap and its required Popper.js dependency using npm. Ensure Sass is set up first. ```shell $ npm install --save bootstrap @popperjs/core ``` -------------------------------- ### Install Migrations Table Source: https://github.com/roots/docs/blob/docs/acorn/creating-and-running-laravel-migrations.md If you encounter an error indicating the migrations table does not exist, run `wp acorn migrate:install` to create it. ```bash $ wp acorn migrate:install ``` -------------------------------- ### Advanced Acorn Booting Configuration Source: https://github.com/roots/docs/blob/docs/acorn/installation.md A comprehensive example of advanced Acorn booting, including service providers, HTTP middleware, exception handling, and routing configuration. ```php add_action('after_setup_theme', function () { Application::configure() ->withProviders([ // Register your service providers App\Providers\ThemeServiceProvider::class, ]) ->withMiddleware(function (Middleware $middleware) { // Configure HTTP middleware for WordPress requests $middleware->wordpress([ Illuminate\Cookie\Middleware\EncryptCookies::class, Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, Illuminate\Session\Middleware\StartSession::class, Illuminate\View\Middleware\ShareErrorsFromSession::class, Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class, Illuminate\Routing\Middleware\SubstituteBindings::class, ]); // You can also configure middleware for web and API routes // $middleware->web([...]); // $middleware->api([...]); }) ->withExceptions(function (Exceptions $exceptions) { // Configure exception handling // $exceptions->reportable(function (\Throwable $e) { // Log::error($e->getMessage()); // }); }) ->withRouting( // Configure routing with named parameters web: base_path('routes/web.php'), // Laravel-style web routes api: base_path('routes/api.php'), // API routes wordpress: true, // Enable WordPress request handling ) ->boot(); }, 0); ``` -------------------------------- ### Install Trellis CLI via Homebrew Source: https://github.com/roots/docs/blob/docs/trellis/cli.md Use this command to quickly install the Trellis CLI on macOS or Linux systems that have Homebrew installed. ```shell $ brew install roots/tap/trellis-cli ``` -------------------------------- ### Install Plugin and Theme Languages Source: https://github.com/roots/docs/blob/docs/trellis/install-wordpress-language-files.md Installs all available languages for plugins and themes. The `--all` flag ensures all plugins/themes are processed. ```yaml - name: Install plugins languages en_GB de_DE de_DE_formal command: wp language plugin install --all en_GB de_DE de_DE_formal args: chdir: "{{ deploy_helper.current_path }}" ``` ```yaml - name: Install themes languages en_GB de_DE de_DE_formal command: wp language theme install --all en_GB de_DE de_DE_formal args: chdir: "{{ deploy_helper.current_path }}" ``` -------------------------------- ### Command Signature Syntax Examples Source: https://github.com/roots/docs/blob/docs/acorn/creating-wp-cli-commands-with-artisan-console.md Define command names, arguments, and options using the `$signature` property. Examples show basic commands, commands with required arguments, and commands with optional flags. ```php // Basic command protected $signature = 'newsletter:send'; ``` ```php // With arguments protected $signature = 'user:create {name} {email}'; ``` ```php // With options protected $signature = 'seo:audit {--post-type=post}'; ``` -------------------------------- ### Start Trellis VM Source: https://github.com/roots/docs/blob/docs/trellis/local-development.md Creates or starts a Lima virtual machine for development. This command can be run without customization for default use cases. ```shell trellis vm start ``` -------------------------------- ### Authentication Middleware Example Source: https://github.com/roots/docs/blob/docs/acorn/controllers-middleware-kernel.md An example of an authentication middleware that checks if a user is logged in and has the necessary administrative capabilities. ```APIDOC ## Authentication middleware example ```php json([ 'message' => 'Authentication required' ], 401); } if (!current_user_can('manage_options')) { return response()->json([ 'message' => 'Admin access required' ], 403); } return $next($request); } } ``` ``` -------------------------------- ### Install WordPress Multisite via WP-CLI Source: https://github.com/roots/docs/blob/docs/trellis/multisite.md After provisioning and deploying, SSH into your server and run this WP-CLI command in the site's current directory to complete the multisite installation. Replace placeholders with your desired values. ```shell $ wp core multisite-install --title="site title" --admin_user="username" --admin_password="password" --admin_email="you@example.com" ``` -------------------------------- ### Install Bedrock with Composer Source: https://github.com/roots/docs/blob/docs/bedrock/bedrock-with-local.md Use Composer to create a new Bedrock project in the current directory, or clone an existing Bedrock repository. ```shell composer create-project roots/bedrock . ``` -------------------------------- ### Install Acorn with Composer Source: https://github.com/roots/docs/blob/docs/acorn/installation.md Use Composer to install the Acorn package. This is the primary method for adding Acorn to your project. ```shell $ composer require roots/acorn ``` -------------------------------- ### Start Trellis Development Environment Source: https://github.com/roots/docs/blob/docs/trellis/installation.md This command starts the Lima virtual environment and provisions the server for local development. Access your site at the URL specified during project creation. ```shell $ trellis vm start ``` -------------------------------- ### Install Trellis CLI via Script Source: https://github.com/roots/docs/blob/docs/trellis/cli.md This command downloads and executes a script to install the Trellis CLI. Ensure you trust the source before running. ```shell $ curl -sL https://roots.io/trellis/cli/get | bash ``` -------------------------------- ### Start a Queue Worker with WP-CLI Source: https://github.com/roots/docs/blob/docs/acorn/creating-and-processing-laravel-queues.md Run the 'queue:work' command to start a continuous process that picks up and executes jobs from the queue. ```bash $ wp acorn queue:work ``` -------------------------------- ### Boot Acorn in Theme or Plugin Source: https://github.com/roots/docs/blob/docs/acorn/installation.md Add this code to your theme's `functions.php` or main plugin file to boot Acorn. It includes a check to ensure Acorn is installed. ```php 'https://roots.io/acorn/docs/installation/', 'link_text' => __('Acorn Docs: Installation', 'domain'), ] ); } add_action('after_setup_theme', function () { Application::configure() ->withProviders([ App\Providers\ThemeServiceProvider::class, ]) ->boot(); }, 0); ``` -------------------------------- ### Write a Basic Pest Test Source: https://github.com/roots/docs/blob/docs/bedrock/testing.md Add new tests to the `tests/` directory. This example checks if the WP_HOME environment variable is set. ```php not->toBeEmpty(); }); ``` -------------------------------- ### Font File Structure Example Source: https://github.com/roots/docs/blob/docs/sage/fonts-setup.md Illustrates the recommended directory structure for adding custom font files to your Sage theme, including the placement of the `.woff2` file. ```plaintext resources ├── css │ ├── app.css │ ├── fonts.css # Create this file │ └── editor.css ├── fonts │ └── public-sans-v14-latin-regular.woff2 ├── images ├── js └── views ``` -------------------------------- ### Basic Post Controller Example Source: https://github.com/roots/docs/blob/docs/acorn/controllers-middleware-kernel.md A controller demonstrating methods for fetching, showing, and creating posts, returning JSON responses. It uses Eloquent models and request validation. ```php latest('ID') ->take(10) ->get(); return response()->json($posts); } public function show(int $id): JsonResponse { $post = Post::findOrFail($id); return response()->json($post); } public function store(Request $request): JsonResponse { $validated = $request->validate([ 'title' => 'required|max:255', 'content' => 'required', 'status' => 'in:draft,publish' ]); $post = Post::create([ 'post_title' => $validated['title'], 'post_content' => $validated['content'], 'post_status' => $validated['status'] ?? 'draft', 'post_type' => 'post', 'post_author' => get_current_user_id() ?: 1, ]); return response()->json($post, 201); } } ``` -------------------------------- ### Install dependencies from requirements.txt Source: https://github.com/roots/docs/blob/docs/trellis/python.md Manually install Ansible and other Trellis dependencies using pip by referencing the requirements.txt file. Avoid using sudo. ```shell pip install -r requirements.txt ``` -------------------------------- ### Install Core WordPress Languages Source: https://github.com/roots/docs/blob/docs/trellis/install-wordpress-language-files.md Installs specified languages for WordPress core. Use `--activate` to set a language as active. ```yaml - name: Install core languages en_GB de_DE command: wp language core install en_GB de_DE args: chdir: "{{ deploy_helper.current_path }}" ``` ```yaml - name: Install (and activate) core language de_DE_formal command: wp language core install de_DE_formal --activate args: chdir: "{{ deploy_helper.current_path }}" ``` -------------------------------- ### Configure Bedrock Multisite (Subdirectory Install) Source: https://github.com/roots/docs/blob/docs/bedrock/bedrock-with-valet.md Configure Bedrock for subdirectory multisite installations by setting `SUBDOMAIN_INSTALL` to false and defining multisite constants in `config/application.php`. ```php /** * Multisite */ Config::define('WP_ALLOW_MULTISITE', true); Config::define('MULTISITE', true); Config::define('SUBDOMAIN_INSTALL', false); Config::define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE')); Config::define('PATH_CURRENT_SITE', env('PATH_CURRENT_SITE') ?: '/'); Config::define('SITE_ID_CURRENT_SITE', env('SITE_ID_CURRENT_SITE') ?: 1); Config::define('BLOG_ID_CURRENT_SITE', env('BLOG_ID_CURRENT_SITE') ?: 1); ``` -------------------------------- ### Basic SSL Configuration Source: https://github.com/roots/docs/blob/docs/trellis/ssl.md This is a basic example of enabling SSL for a website in Trellis. Ensure the 'provider' is set to a valid SSL provider. ```yaml # group_vars/production/wordpress_sites.yml (example) example.com: # rest of site config ssl: enabled: true provider: ``` -------------------------------- ### Build Theme Assets with npm Source: https://github.com/roots/docs/blob/docs/sage/installation.md After installing dependencies with `npm install`, run this command to compile theme assets. Ensure the `base` path in `vite.config.js` is correctly set. ```shell npm run build ``` -------------------------------- ### Navigate to DevKinsta Site Directory Source: https://github.com/roots/docs/blob/docs/bedrock/bedrock-with-devkinsta.md Change the current directory to your DevKinsta site's path. This is where you will install Bedrock. ```shell cd ~/DevKinsta/public/example ``` -------------------------------- ### Configure Bedrock Multisite (Subdomain Install) Source: https://github.com/roots/docs/blob/docs/bedrock/bedrock-with-valet.md Configure Bedrock for subdomain multisite installations by setting `DOMAIN_CURRENT_SITE` in `.env` and defining multisite constants in `config/application.php`. ```php /** * Multisite */ Config::define('WP_ALLOW_MULTISITE', true); Config::define('MULTISITE', true); Config::define('SUBDOMAIN_INSTALL', true); Config::define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE')); Config::define('PATH_CURRENT_SITE', env('PATH_CURRENT_SITE') ?: '/'); Config::define('SITE_ID_CURRENT_SITE', env('SITE_ID_CURRENT_SITE') ?: 1); Config::define('BLOG_ID_CURRENT_SITE', env('BLOG_ID_CURRENT_SITE') ?: 1); ``` -------------------------------- ### Install Python 3 and pip on Ubuntu Source: https://github.com/roots/docs/blob/docs/trellis/python.md Installs Python 3, the python-is-python3 package to symlink python to python3, and pip for Python 3 on Ubuntu systems. ```shell sudo apt-get install -y python3 python-is-python3 python3-pip ``` -------------------------------- ### Provision Local Development VM Source: https://github.com/roots/docs/blob/docs/trellis/existing-projects.md Start the local development virtual machine for your Trellis project. Ensure you can access the development site afterward. ```shell $ trellis up ``` -------------------------------- ### Deploy to Production with Trellis Source: https://github.com/roots/docs/blob/docs/trellis/installation.md Execute this command to deploy your site to the production environment. Replace 'example.com' with your actual domain name. Refer to the deployments documentation for more details. ```shell $ trellis deploy production example.com ``` -------------------------------- ### Create a New Trellis Project Source: https://github.com/roots/docs/blob/docs/trellis/installation.md Run this command to create a new Trellis project. Replace 'example.com' with your desired project name, typically the domain of the site. ```shell $ trellis new example.com ``` -------------------------------- ### Add Deploy Hooks for Language Installation Source: https://github.com/roots/docs/blob/docs/trellis/install-wordpress-language-files.md These configurations add custom deploy hooks to the `deploy_finalize_after` list. This ensures that site setup for language installation and language updates are executed during the finalization stage of the deployment. ```yaml # Deploy hooks deploy_build_before: - "{{ playbook_dir }}/deploy-hooks/sites/{{ site }}-build-before.yml" # build + upload theme assets deploy_build_after: - "{{ playbook_dir }}/roles/deploy/hooks/build-after.yml" # built-in deploy_finalize_before: - "{{ playbook_dir }}/roles/deploy/hooks/finalize-before.yml" # built-in deploy_finalize_after: - "{{ playbook_dir }}/roles/deploy/hooks/finalize-after.yml" # built-in - "{{ playbook_dir }}/deploy-hooks/finalize-after.yml" # finish site setup for installing languages - "{{ playbook_dir }}/deploy-hooks/sites/{{ site }}-finalize-after.yml" # install + update languages ``` -------------------------------- ### Install Bedrock with Composer Source: https://github.com/roots/docs/blob/docs/bedrock/bedrock-with-devkinsta.md Use Composer to create a new Bedrock project within your DevKinsta site directory. Alternatively, you can clone an existing git repository. ```shell composer create-project roots/bedrock ``` -------------------------------- ### Composer Patch Application Output Source: https://github.com/roots/docs/blob/docs/bedrock/patching-wordpress-plugins-with-composer.md Example output indicating that patches are being applied during a Composer installation or update process. ```plaintext - Applying patches for vendor/package-name patches/example-plugin-fix.patch (Brief description of patch) ``` -------------------------------- ### Example Migration for App Settings Table Source: https://github.com/roots/docs/blob/docs/acorn/creating-and-running-laravel-migrations.md This PHP code defines a migration for creating an `app_settings` table. The `up()` method defines the table schema, and the `down()` method defines how to drop the table. ```php id(); $table->string('key')->unique(); $table->json('value')->nullable(); $table->string('group')->default('general'); $table->boolean('is_public')->default(false); $table->text('description')->nullable(); $table->timestamps(); $table->index('group'); $table->index('is_public'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('app_settings'); } }; ``` -------------------------------- ### Complete Multisite WordPress Sites YAML Entry Source: https://github.com/roots/docs/blob/docs/trellis/multisite.md An example of a full `wordpress_sites.yml` entry configured for a multisite installation. It includes site hosts, local path, multisite settings, SSL, cache, and environment-specific variables. ```yaml # group_vars/production/wordpress_sites.yml wordpress_sites: example.com: site_hosts: - canonical: example.com local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root) admin_email: admin@example.com multisite: enabled: true subdomains: true ssl: enabled: false cache: enabled: false env: domain_current_site: store1.example.com ``` -------------------------------- ### Access Server Create Help Source: https://github.com/roots/docs/blob/docs/trellis/deploy-to-hetzner-cloud.md View the available options and usage for the `trellis server create` command by passing the `--help` flag. ```shell $ trellis server create --help ``` -------------------------------- ### Optimize Acorn Configuration and Views Source: https://github.com/roots/docs/blob/docs/sage/deployment.md Run this command as part of your deployment process to cache configuration and views for optimization. Ensure Acorn is installed and configured. ```shell $ wp acorn optimize ``` -------------------------------- ### Install Lithify dependency Source: https://github.com/roots/docs/blob/docs/bedrock/converting-wordpress-sites-to-bedrock.md Add the Lithify plugin to your Bedrock project using Composer. This makes the WP-CLI command available. ```bash $ composer require mwdelaney/lithify ``` -------------------------------- ### Perform Basic Eloquent Queries in WordPress Source: https://github.com/roots/docs/blob/docs/acorn/eloquent-models.md Examples of fetching posts by status and type, retrieving a post with its author, and creating a new post using Eloquent models. ```php // Get all published posts $posts = Post::published()->get(); // Get posts of a specific type $pages = Post::ofType('page')->published()->get(); // Get a post with its author $post = Post::with('author')->find(123); // Create a new post $post = Post::create([ 'post_title' => 'Hello World', 'post_content' => 'This is my first post using Eloquent!', 'post_status' => 'publish', 'post_type' => 'post', 'post_author' => get_current_user_id(), ]); ``` -------------------------------- ### Initialize Acorn Storage and Publish Configs Source: https://github.com/roots/docs/blob/docs/acorn/directory-structure.md Uses WP-CLI to initialize the storage directory and publish Acorn's configuration files, setting up a traditional structure. ```shell $ wp acorn acorn:init storage && wp acorn vendor:publish --tag=acorn ``` -------------------------------- ### Configure Composer Installer Paths Source: https://github.com/roots/docs/blob/docs/bedrock/mu-plugin-autoloader.md Use this configuration in your `composer.json` to specify where different types of WordPress packages should be installed. It allows overriding default types, such as setting a `wordpress-plugin` to be installed in the `mu-plugins` directory. ```json { "installer-paths": { "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin", "roots/wp-stage-switcher"], "web/app/plugins/{$name}/": ["type:wordpress-plugin"], "web/app/themes/{$name}/": ["type:wordpress-theme"] } } ``` -------------------------------- ### Perform First Deploy to Provisioned Server Source: https://github.com/roots/docs/blob/docs/trellis/deploy-to-digitalocean.md Once your server is provisioned, run this command to perform the initial deployment of your Trellis site. Visiting the site before this step may result in a 500 error. ```shell $ trellis deploy production ``` -------------------------------- ### Install Sass Dependency Source: https://github.com/roots/docs/blob/docs/sage/sass.md Install the Sass compiler as a development dependency using npm. ```shell $ npm install -D sass ``` -------------------------------- ### Create Server with Default Provider Source: https://github.com/roots/docs/blob/docs/trellis/deploy-to-hetzner-cloud.md After setting Hetzner as the default provider, you can create a new server for an environment without specifying the provider flag. ```shell $ trellis server create production ``` -------------------------------- ### Apply Patches with Composer Install Source: https://github.com/roots/docs/blob/docs/bedrock/patching-wordpress-with-composer.md Composer automatically applies configured patches when dependencies are installed or updated. ```shell $ composer install ``` -------------------------------- ### Authentication middleware example Source: https://github.com/roots/docs/blob/docs/acorn/controllers-middleware-kernel.md Middleware that checks if a user is logged in and has the 'manage_options' capability. Returns JSON responses with appropriate status codes if checks fail. ```php json([ 'message' => 'Authentication required' ], 401); } if (!current_user_can('manage_options')) { return response()->json([ 'message' => 'Admin access required' ], 403); } return $next($request); } } ``` -------------------------------- ### Display Help for Trellis Server Create Command Source: https://github.com/roots/docs/blob/docs/trellis/deploy-to-digitalocean.md Access the help documentation for the `trellis server create` command to see all available options and arguments. This includes details on provider, region, size, image, and provisioning. ```shell $ trellis server create --help ``` -------------------------------- ### Install blade-icons Package Source: https://github.com/roots/docs/blob/docs/sage/use-blade-icons.md Add blade-icons as a Composer dependency to your project. This command should be run from the same directory where Acorn is installed. ```shell $ composer require blade-ui-kit/blade-icons ``` -------------------------------- ### Generate a basic controller Source: https://github.com/roots/docs/blob/docs/acorn/controllers-middleware-kernel.md Use the `make:controller` Artisan command to create a new controller file. ```bash wp acorn make:controller PostController ``` -------------------------------- ### Dispatching Queue Jobs in PHP Source: https://github.com/roots/docs/blob/docs/acorn/creating-and-processing-laravel-queues.md Demonstrates how to dispatch jobs to the queue, including options for adding a delay or specifying a target queue. ```php use App\Jobs\ProcessImageOptimization; // Dispatch a job to the default queue ProcessImageOptimization::dispatch($attachmentId); // Dispatch with a delay ProcessImageOptimization::dispatch($attachmentId) ->delay(now()->addMinutes(5)); // Dispatch to a specific queue ProcessImageOptimization::dispatch($attachmentId) ->onQueue('images'); ``` -------------------------------- ### Initialize Git Repository for Plugin Source: https://github.com/roots/docs/blob/docs/bedrock/patching-wordpress-plugins-with-composer.md Prepare a plugin directory for Git operations to create a patch file. ```shell $ cd web/app/plugins/example-plugin $ git init $ git add . && git commit -m "Base plugin" ``` -------------------------------- ### Example Environment Variable Usage Source: https://github.com/roots/docs/blob/docs/trellis/cli.md Demonstrates how to set a Trellis CLI configuration option using an environment variable. The `TRELLIS_` prefix is stripped, and the remainder is lowercased to match the setting key. ```shell $ TRELLIS_ASK_VAULT_PASS=true trellis provision production ``` -------------------------------- ### Create a Server in a Specific Region and Size Source: https://github.com/roots/docs/blob/docs/trellis/deploy-to-digitalocean.md When creating a server, you can specify the desired region and server size. If not provided, these will be prompted. ```shell $ trellis server create --region=nyc3 --size=s-1vcpu-1gb production ``` -------------------------------- ### Unencrypted vault.yml Example Source: https://github.com/roots/docs/blob/docs/trellis/vault.md This is an example of an unencrypted `vault.yml` file containing sensitive data. Replace placeholder values before encrypting. ```yaml # example vault.yml file -- unencrypted plain text my_password: example_password ``` -------------------------------- ### Update Installed Languages Source: https://github.com/roots/docs/blob/docs/trellis/install-wordpress-language-files.md Updates all installed languages for WordPress core, plugins, and themes to their latest available versions. These commands are idempotent. ```yaml # Update installed languages - name: Update installed core languages command: wp language core update args: chdir: "{{ deploy_helper.current_path }}" ``` ```yaml - name: Update plugins languages command: wp language plugin --all update args: chdir: "{{ deploy_helper.current_path }}" ``` ```yaml - name: Install themes languages command: wp language theme --all update args: chdir: "{{ deploy_helper.current_path }}" ``` -------------------------------- ### Provision Production Server with Trellis Source: https://github.com/roots/docs/blob/docs/trellis/installation.md Use this command to provision your production server. Ensure you have read the provisioning documentation before execution. ```shell $ trellis provision production ``` -------------------------------- ### Create Bedrock Project with Composer Source: https://github.com/roots/docs/blob/docs/bedrock/bedrock-with-ddev.md Run this command to create a new Bedrock project using Composer. ```shell ddev composer create roots/bedrock ``` -------------------------------- ### Perform First Deploy to Hetzner Cloud Source: https://github.com/roots/docs/blob/docs/trellis/deploy-to-hetzner-cloud.md After provisioning a server, perform the initial deployment of your Trellis site to the Hetzner Cloud server using the `trellis deploy` command. ```shell $ trellis deploy production ``` -------------------------------- ### Install pip with Python 3 on macOS Source: https://github.com/roots/docs/blob/docs/trellis/python.md Use this command to ensure pip is installed for your Python 3 environment if it's not already present. ```shell python3 -m ensurepip ``` -------------------------------- ### Create New Bedrock Site with Valet Source: https://github.com/roots/docs/blob/docs/bedrock/bedrock-with-valet.md Navigate to your Valet sites directory and use the `wp valet new` command to create a new Bedrock site. Ensure you have run `valet park` in your Valet sites directory. ```shell cd ~/Sites/valet ``` ```shell wp valet new bedrock --project=bedrock ``` -------------------------------- ### Configure Installer Paths for mu-plugins Source: https://github.com/roots/docs/blob/docs/bedrock/composer.md Modify the 'installer-paths' in your composer.json to force specific plugins to be installed in the 'mu-plugins' directory instead of the regular 'plugins' directory. ```yaml ... "extra": { "installer-paths": { "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin", "wp-plugin/akismet"], "web/app/plugins/{$name}/": ["type:wordpress-plugin"], "web/app/themes/{$name}/": ["type:wordpress-theme"] }, "wordpress-install-dir": "web/wp" }, ... ``` -------------------------------- ### Basic GitHub Actions Workflow for Trellis Deploy Source: https://github.com/roots/docs/blob/docs/trellis/deploy-with-github-actions.md An example GitHub Actions workflow file for deploying a Trellis site. This workflow is triggered on pushes to the `main` branch and uses the `roots/setup-trellis-cli` action. ```yaml name: Deploy Trellis site on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Trellis CLI uses: roots/setup-trellis-cli@v2 env: ANSIBLE_VAULT_PASSWORD: ${{ secrets.ANSIBLE_VAULT_PASSWORD }} - name: Deploy to production run: trellis deploy production -d "$TRELLIS_HOST" env: TRELLIS_DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.TRELLIS_DEPLOY_SSH_PRIVATE_KEY }} TRELLIS_DEPLOY_SSH_KNOWN_HOSTS: ${{ secrets.TRELLIS_DEPLOY_SSH_KNOWN_HOSTS }} ``` -------------------------------- ### Let's Encrypt with Multiple Domains and Redirects Source: https://github.com/roots/docs/blob/docs/trellis/ssl.md Example of configuring Let's Encrypt for a site with multiple hostnames, including redirects. Ensure DNS records exist for all listed hosts. ```yaml # group_vars/production/wordpress_sites.yml (example) mydomain.com: site_hosts: - canonical: mydomain.com redirects: - www.mydomain.com - mydomaintoredirect.com - www.mydomaintoredirect.com ssl: enabled: true provider: letsencrypt ``` -------------------------------- ### Trellis Server Create Command Help Output Source: https://github.com/roots/docs/blob/docs/trellis/deploy-to-digitalocean.md This is the detailed help output for the `trellis server create` command, outlining its usage, options, and arguments for creating servers on cloud providers like DigitalOcean. ```plaintext Usage: trellis server create [options] ENVIRONMENT Creates a server on a cloud provider for the environment specified. Only remote servers (for staging and production) are currently supported. This command requires a DigitalOcean personal access token. Link: https://cloud.digitalocean.com/account/api/tokens/new If the DIGITALOCEAN_ACCESS_TOKEN environment variable is not set, the command will prompt for one. Create a production server (region and size will be prompted): $ trellis server create production Create a 1gb server in the nyc3 region: $ trellis server create --region=nyc3 --size=s-1vcpu-1gb production Create a server but skip provisioning: $ trellis server create --skip-provision production Arguments: ENVIRONMENT Name of environment (ie: production) Options: --provider Cloud provider (digitalocean, hetzner) --region Region to create the server in --image (default: ubuntu-24-04-x64) Server image (ie: Linux distribution) --size Server size/type --skip-provision Skip provision after server is created --ssh-key Path to SSH public key to be added on the server -h, --help show this help ``` -------------------------------- ### Example Trellis CLI Configuration Source: https://github.com/roots/docs/blob/docs/trellis/cli.md This YAML snippet shows a sample configuration for the Trellis CLI, including settings for vault pass, update checks, plugin loading, site shortcuts, server provider, and virtual machine management. ```yaml ask_vault_pass: false check_for_updates: true load_plugins: true open: site: "https://mysite.com" admin: "https://mysite.com/wp/wp-admin" server: provider: digitalocean virtualenv_integration: true vm: manager: auto ubuntu: "24.04" ``` -------------------------------- ### Install Trellis CLI Dev/Unstable via Homebrew Source: https://github.com/roots/docs/blob/docs/trellis/cli.md Install the latest development or unstable version of the Trellis CLI using Homebrew. This command fetches the latest HEAD. ```shell $ brew install --HEAD roots/tap/trellis-cli-dev ``` -------------------------------- ### Require Memcached Package Source: https://github.com/roots/docs/blob/docs/trellis/redis.md Require the `automattic/wp-memcached` package using Composer. This installs the Memcached object cache drop-in. Omit `--ignore-platform-req=ext-memcache` if the extension is already installed. ```bash composer require automattic/wp-memcached:dev-master --ignore-platform-req=ext-memcache ``` -------------------------------- ### Install MilliCache for Full-Site Cache Source: https://github.com/roots/docs/blob/docs/trellis/redis.md Install the MilliCache package using Composer to enable Redis full-site caching. This is an alternative to the standard Redis object cache plugin. ```bash composer require millipress/millicache ``` -------------------------------- ### Create a New Queue Job Class Source: https://github.com/roots/docs/blob/docs/acorn/creating-and-processing-laravel-queues.md Use the 'make:job' command to scaffold a new job class file within the app/Jobs directory. ```bash $ wp acorn make:job ProcessImageOptimization ``` -------------------------------- ### Install Redis Object Cache Plugin Source: https://github.com/roots/docs/blob/docs/trellis/redis.md Install the Redis Object Cache plugin using Composer. This is the first step to enabling Redis object caching in WordPress. ```bash composer require wp-plugin/redis-cache ``` -------------------------------- ### Install npm Dependencies with NVM Source: https://github.com/roots/docs/blob/docs/trellis/sage-integration.md Use this command to install npm dependencies when managing Node.js versions with NVM. Ensure the `chdir` path points to your theme directory. ```yaml - name: Install npm dependencies command: $NVM_DIR/nvm-exec npm install delegate_to: localhost args: chdir: "{{ project_local_path }}/web/app/themes/mytheme" ``` -------------------------------- ### Generate a controller with all CRUD methods Source: https://github.com/roots/docs/blob/docs/acorn/controllers-middleware-kernel.md Use the `make:controller` Artisan command with the `--resource` flag to generate a controller with all standard CRUD methods. ```bash wp acorn make:controller PostController --resource ``` -------------------------------- ### Install Bedrock Plugin Disabler with Composer Source: https://github.com/roots/docs/blob/docs/bedrock/disable-plugins-based-on-environment.md Install the Bedrock Plugin Disabler mu-plugin using Composer. This package provides the functionality to disable plugins based on environment configurations. ```shell $ composer require lukasbesch/bedrock-plugin-disabler ``` -------------------------------- ### Provision with APT Sources Cleaned Source: https://github.com/roots/docs/blob/docs/trellis/troubleshooting.md Run a single provision with APT sources cleaned by setting the `apt_clean_sources` variable. This is useful for updating packages when mirrors may be outdated. ```shell $ trellis provision --extra-vars apt_clean_sources=true production ``` -------------------------------- ### Provision Trellis VM Source: https://github.com/roots/docs/blob/docs/trellis/local-development.md Run this command from your project's `trellis` directory to provision the development VM. ```shell $ trellis provision development ``` -------------------------------- ### Create a new Bedrock site Source: https://github.com/roots/docs/blob/docs/bedrock/converting-wordpress-sites-to-bedrock.md Use Composer to create a new Bedrock project. Navigate into the project directory after creation. ```bash $ composer create-project roots/bedrock example.com ``` ```bash $ cd example.com ``` -------------------------------- ### Install Composer Patches Plugin Source: https://github.com/roots/docs/blob/docs/bedrock/patching-wordpress-with-composer.md Add the cweagans/composer-patches package to your project to enable patch management. ```shell $ composer require cweagans/composer-patches ``` -------------------------------- ### Nginx Subdomain Multisite Rewrites Source: https://github.com/roots/docs/blob/docs/bedrock/server-configuration.md Add these Nginx rewrite rules for subdomain-based WordPress multisite installations. ```nginx rewrite ^/(wp-.*.php)$ /wp/$1 last; rewrite ^/(wp-(content|admin|includes).*) /wp/$1 last; ``` -------------------------------- ### Update Editor Stylesheet in `app.setup.php` Source: https://github.com/roots/docs/blob/docs/sage/sass.md Adjust the `block_editor_settings_all` filter in `app/setup.php` to use `editor.scss` for the block editor styles. ```diff add_filter('block_editor_settings_all', function ($settings) { - $style = Vite::asset('resources/css/editor.css'); + $style = Vite::asset('resources/css/editor.scss'); $settings['styles'][] = [ 'css' => "@import url('{$style}')", ]; return $settings; }); ``` -------------------------------- ### List Trellis Cron Jobs Source: https://github.com/roots/docs/blob/docs/trellis/cron-jobs.md Lists all cron job files managed by Trellis in `/etc/cron.d/` that start with 'wordpress-'. ```bash ls /etc/cron.d/wordpress-* ``` -------------------------------- ### Uninstall Trellis CLI (Dev) Source: https://github.com/roots/docs/blob/docs/trellis/cli.md Use this command to uninstall the development version of the Trellis CLI if it was installed via Homebrew. ```shell $ brew uninstall roots/tap/trellis-cli ``` -------------------------------- ### Create a Server Without Provisioning Source: https://github.com/roots/docs/blob/docs/trellis/deploy-to-digitalocean.md This command creates a new server on DigitalOcean but skips the automatic provisioning step. Use this if you plan to provision manually later. ```shell $ trellis server create --skip-provision production ``` -------------------------------- ### Test MilliCache Source: https://github.com/roots/docs/blob/docs/trellis/redis.md Test the MilliCache installation and configuration using the WordPress CLI. This verifies that the full-site cache is functioning correctly. ```bash wp millicache test ``` -------------------------------- ### Create a Production Server with Trellis CLI Source: https://github.com/roots/docs/blob/docs/trellis/deploy-to-digitalocean.md Use this command to automatically create and provision a new server on DigitalOcean for your production environment. The region and size will be prompted if not specified. ```shell $ trellis server create production ``` -------------------------------- ### Nginx Subfolder Multisite Rewrites Source: https://github.com/roots/docs/blob/docs/bedrock/server-configuration.md Include these Nginx rewrite rules for subfolder-based WordPress multisite installations when the file does not exist. ```nginx if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$uri/ permanent; rewrite ^(/[^/]+)?(/wp-.*) /wp$2 last; rewrite ^(/[^/]+)?(/.*.php) /wp$2 last; } ``` -------------------------------- ### Remove Default WordPress Files Source: https://github.com/roots/docs/blob/docs/bedrock/bedrock-with-local.md Execute these commands in the site shell to remove the default WordPress installation from the public directory. ```shell rm -rf * rm .htaccess ``` -------------------------------- ### Add Redis Package Dependency Source: https://github.com/roots/docs/blob/docs/acorn/laravel-redis-configuration.md Install the Laravel Redis package using Composer. This is a prerequisite for configuring Redis with Acorn. ```shell $ composer require illuminate/redis ``` -------------------------------- ### Encrypted vault.yml Example Source: https://github.com/roots/docs/blob/docs/trellis/vault.md This demonstrates the format of an encrypted `vault.yml` file after being processed by Ansible Vault. The sensitive data is obscured. ```yaml # example vault.yml file -- encrypted $ANSIBLE_VAULT;1.1;AES256 343163646662643438323831343332626234333233386666333162383265663 3132306538383762336332376165383530633838643937320a6363343238643 363065366664316364646561613163653866623566303235666537343437643 6638363265383831390a6631663239373833636133623333666363643166383 6237663637353638653266616562616535623465636265316231613331 etc. ``` -------------------------------- ### Add Memcached Package Repository Source: https://github.com/roots/docs/blob/docs/trellis/redis.md Add the `wp-memcached` package repository to Composer. This is a prerequisite for installing the Memcached object cache drop-in. ```bash composer repo add wp-memcached '{"type":"package","package":{"name":"automattic/wp-memcached","type":"wordpress-dropin","version":"dev-master","dist":{"type":"file","url":"https://raw.githubusercontent.com/Automattic/wp-memcached/bb3b9f689dd99df66454b93ece34093556dc37f9/object-cache.php","reference":"bb3b9f689dd99df66454b93ece34093556dc37f9"},"require":{"koodimonni/composer-dropin-installer":"^1.4","php":">=7.4.0","ext-memcache":"*"}}}' --before wp-packages ``` -------------------------------- ### Activate MilliCache Plugin Source: https://github.com/roots/docs/blob/docs/trellis/redis.md Activate the MilliCache plugin using the WordPress CLI after installation. This makes the full-site cache functionality available. ```bash wp plugin activate millicache ```