Skip to content
Acorn
v4.0.3

Installation

What is Acorn?

Acorn is a way to use Laravel components inside of WordPress.

Why use Acorn?

Acorn brings elements of the Laravel ecosystem to any WordPress plugin or theme.

To put it simply, Acorn provides a way to gracefully load a Laravel application container inside of WordPress while respecting the WordPress lifecycle and template hierarchy.

This means you get access to Laravel's artisan commands through the use of wp acorn. You can utilize Blade templates. You gain access to third-party packages built specifically for Acorn. And we provide some first-party components as well, such as view composers and assets management.

Installing Acorn with Composer

We recommend that you install Acorn on your WordPress install managed by Composer, such as with Bedrock:

$ 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:

"scripts": {
  //...
  "post-autoload-dump": [
    "Roots\\Acorn\\ComposerScripts::postAutoloadDump"
  ]
}

If you don't use Bedrock and you are using a Sage-based theme, you can install Acorn with Composer from your theme directory.

Booting Acorn

If you aren't using Sage or Radicle, you can boot Acorn in your own theme or plugin:

<?php

if (! function_exists('\Roots\bootloader')) {
    wp_die(
        __('You need to install Acorn to use this site.', 'domain'),
        '',
        [
            'link_url' => 'https://roots.io/acorn/docs/installation/',
            'link_text' => __('Acorn Docs: Installation', 'domain'),
        ]
    );
}

add_action('after_setup_theme', fn () => \Roots\bootloader()->boot());

Server requirements

Acorn's server requirements are minimal, and mostly come from WordPress and Laravel 10's requirements.

  • PHP >=8.1
  • WordPress >= 5.4
  • WP-CLI
  • BCMath PHP Extension
  • Ctype PHP Extension
  • Fileinfo PHP Extension
  • JSON PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

Contributors

Last updated

Support Roots

Help us continue to build and maintain our open source projects. We’re a small team of independent developers and every little bit helps.

Sponsor Roots on GitHub

Digging Deeper