Skip to content
  1. Blog

Creating an Acorn Package

Brandon Nifong Brandon Nifong on

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!

Discuss this post on Roots Discourse

About the author

Brandon Nifong

Brandon is a full-time internet marketer with over 14 years of web development experience. In his free time, he enjoys gaming and traveling with his wife.

Subscribe for updates

Join over 8,000 subscribers on our newsletter to get the latest Roots updates and tips on building better WordPress sites

Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?