From 930418f762e8293c3ff4ff816f53ed0ff9bbdb20 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Wed, 24 Apr 2024 12:23:10 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20`acorn:install`=20to=20Aco?= =?UTF-8?q?rn=20installation=20docs=20(#511)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- acorn/installation.md | 63 ++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/acorn/installation.md b/acorn/installation.md index 57ef9718..e76954e9 100644 --- a/acorn/installation.md +++ b/acorn/installation.md @@ -1,5 +1,5 @@ --- -date_modified: 2024-02-02 10:00 +date_modified: 2024-04-24 13:00 date_published: 2021-11-19 11:58 description: Install Acorn by running `composer require roots/acorn` in the root of your Composer-based WordPress project. title: Installing Acorn @@ -32,22 +32,16 @@ We recommend that you install Acorn on your WordPress install managed by Compose $ composer require roots/acorn ``` -We also recommend adding Acorn's `postAutoloadDump` function to Composer's `post-autoload-dump` event in the `scripts` section of `composer.json`: +If you don't use Composer to manage your WordPress install and you are using a Sage-based theme, you can install Acorn with Composer from your theme directory. Navigate to your theme folder and then run the command above. -```json -"scripts": { - //... - "post-autoload-dump": [ - "Roots\\Acorn\\ComposerScripts::postAutoloadDump" - ] -} -``` +## Booting Acorn -If you don't use Bedrock and you are using a Sage-based theme, you can install Acorn with Composer from your theme directory. +Acorn must be booted in order to use it. [Sage](https://roots.io/sage/) and [Radicle](https://roots.io/radicle/) already handle booting Acorn. -## Booting Acorn +
+Boot Acorn in your own theme or plugin -If you aren't using [Sage](https://roots.io/sage/) or [Radicle](https://roots.io/radicle/), you can boot Acorn in your own theme or plugin: +Add the following in your theme's `functions.php` file, or in your main plugin file: ```php \Roots\bootloader()->boot()); ``` +
+ +## Add the autoload dump script + +Acorn has a function that should be added to the `scripts` section of your `composer.json` file for the `post-autoload-dump` event. To automatically configure this script, run the following command: + +```shell +$ wp acorn acorn:install +``` + +Select **Yes** when prompted to install the Acorn autoload dump script. + +::: warning +`wp acorn` commands won't work if your theme/plugin that boots Acorn hasn't been activated and will result in the following message: + +**Error: 'acorn' is not a registered wp command.** +::: + +
+Manually adding Acorn's post autoload dump function + +Open `composer.json` and add Acorn's `postAutoloadDump` function to Composer's `post-autoload-dump` event in the `scripts`: + +```json +"scripts": { + //... + "post-autoload-dump": [ + "Roots\\Acorn\\ComposerScripts::postAutoloadDump" + ] +} +``` + +
+ ## Server requirements Acorn's server requirements are minimal, and mostly come from WordPress and [Laravel 10's requirements](https://laravel.com/docs/10.x/deployment#server-requirements). -- PHP >=8.1 +- PHP >=8.1 with extensions: BCMath, Ctype, Fileinfo, JSON, Mbstring, Tokenizer, XML - WordPress >= 5.4 - [WP-CLI](https://wp-cli.org/) -- BCMath PHP Extension -- Ctype PHP Extension -- Fileinfo PHP Extension -- JSON PHP Extension -- Mbstring PHP Extension -- Tokenizer PHP Extension -- XML PHP Extension