We have an Acorn Example Package repo that can be used as a template for creating your own Acorn packages. It's similar to some of the other Laravel package templates out there, but more specific to Acorn.
Creating Acorn packages is useful for when you want to reuse specific functionality on your Acorn-powered WordPress sites, or open-sourcing functionality that's not tied directly to your site. You can think of Acorn packages similiar to WordPress plugins, or any other dependency.
Packages are installed by Composer, just like Acorn is.
We recommend referencing the Laravel docs on Packages
Creating an Acorn package
From the roots/acorn-example-package repo, click the Use this template button to create a new repo with the template.
Developing an Acorn package
Once your package is created, clone your new git repo somewhere on your machine that's accessible from a WordPress site with Acorn installed. To work on a package locally, you can require it by defining a new local repository from the
composer.json file used for your site/theme:
./packages/vendor-name/example-package above with the path to your local package, along with the correct names.
Then run the Acorn WP-CLI command to discover your package:
$ wp acorn package:discover
INFO Discovering packages.
vendor-name/example-package ...... DONE
roots/sage ....................... DONE
We have plans to automate replacing the placeholders in the example package in the future
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