Earlier this year, I gave a talk at WordCamp Atlanta about Namespaces and Autoloading.

These are two topics that, even though we can’t often use some of the native features of PHP7+ in our work, I think that many of us should be using in our plugin development.

Sometimes though, I think the problem is that developers lack the time, resources, or experience to know where to start understanding autoloaders let alone write their own.

And I want to fix that.

For some time now, I’ve been using a very simple autoloader in my projects. It’s served me well, but I think it could it be more powerful and I think it’s something that others could easily use in their projects, too.

So I’ve started a repository that offers a simple autoloader for WordPress. No, it’s not for WordPress core nor is it meant to be used with themes, but it’s for those who want to begin using autoloading in their WordPress plugins and similar projects.

Simple Autoloader for WordPress

Simple Autoloader for WordPress

You can read all of the details in the project’s repository, but here are the basics:

TL;DR: An autoloader you can drop into a WordPress plugin and begin using it automagically.

I have a very simple autoloader that I’m sharing in this repository that I hope the greater (and smarter!) WordPress developers at large will contribute to improving.

The repository provides:

In the CONTRIBUTING document, I provide information on how to take advantage of GitHub issues. I also provide steps for how to go about offering contributions from branching to PRs and tagging for the project. This should alleviate any potential problems when working with others who start adding their work to the project.

The Project’s Goal

Ultimately, my goal is to have something as simple as this:

  1. Download the project,
  2. Drop lib/autoload.php into your project,
  3. Start using namespaces.

And you’re ready to go.

But I know that many of us have different ways that we go about organizing our files, there are some things that we’ll need to tackle as well. These include files such as:

  • abstract classes,
  • interfaces,
  • etc.

And that’s okay. The point for a 0.1.0 isn’t to have a feature complete version of a project. Instead, it’s a foundation off of which to build and to which others can contribute.

I hope to see others offer their work (but remember to read this page first) and then we’ll go from there.

Finally, comments are closed on this post as I’d prefer all activity to take place on the repository. If you have a question, don’t hesitate to send me a tweet. If you must, email me, but Twitter is likely to get a faster response 😏.