Creating an Acorn Package
Have you been wondering how to get started with developing an Acorn package? We’ve updated the Acorn Package Development documentation and published a acorn-example-package repo to help you get started.
Why create an Acorn package?
Think about Acorn packages similar to any other dependency, like a WordPress plugin. If you ever want to reuse functionality on your Acorn sites, or release functionality as an open-source library, then creating an Acorn package is the ideal way to do so. By extracting your code into a package, you can make it easier to maintain your reusable code.
Packages can be anything from a simple utility class to a complex system with configuration, views, and WP-CLI commands.
Acorn packages are installed by Composer, just like Acorn itself is.
If you aren’t yet familiar with Laravel packages and service providers, make sure to read Laravel’s Package docs.
Getting started with Acorn package development
Visit the acorn-example-page repo on GitHub and then click the Use this template button to create a new repo with the template.
Currently the repo contains placeholder names for both the name of the package and the vendor. The vendor name is the name of the author, usually your username or organization name on Packagist. In the future, we will offer a script for automating the string replacement.
You can work on a package locally by defining a local repository for the package on your WordPress project.
Existing packages to reference
There’s several community packages that already exist that can be used as a reference and inspiration for creating your own. Some community packages include:
Create your own packages and share them with us on Roots Discourse!