Adding Your WordPress Plugin To Packagist

When you start adding your WordPress plugins to GitHub, one of the next things you’re likely going to want to do is make it easy for other developers to begin incorporating those packages into their composer.json file.

That is, they don’t have to download your plugin, include it in your project, watch for updates, or anything like that. Instead, they add the file then run:

$ composer update

…whenever they are ready to get the latest version of your work.

But simply contributing your work to GitHub is not enough. You have to submit your WordPress plugin to Packagist (of course, this works with other projects, too, but that’s outside the scope of this blog, really).

And here’s how to do it.

Add Your WordPress Plugin to Packagist

For those who aren’t familiar, here’s the gist of it:

Packagist is the main Composer repository. It aggregates public PHP packages installable with Composer.

In short, it makes it easy to include third-party libraries into your projects via Composer.

Adding Your WordPress Plugin To Packagist

Anyway, once your plugin is on GitHub, there are a few more steps to include to get your work ready to register with Packagist. It’s easy, though:

  1. If you’ve not already, create an account with Packagist,
  2. Add a composer.json file to your project and make sure it includes the following:

Once done, make sure you update Composer to generate your composer.lock file. From there, navigate to the Submit page and add the URL to your GitHub repository.

From there, you and anyone else will be able to drop in a reference in their project’s respective composer.json file and then have it included in their project.

An Example

For a working example of what this may look like, see this project. (And I’ll have more information about this particular project in a future post.)

8 Replies to “Adding Your WordPress Plugin To Packagist”

  1. Using packagist for WordPress related stuff is great and I really appreciate it when developers do that.

    However, I assume you are aware of that, but for completion’s sake, there is https://wpackagist.org/ which makes every wordpress.org hosted plugin and theme available through composer.

    I would like to hear your thoughts on that: Do you prefer Packagist or is WPackagist also an option for you?

    1. I would like to hear your thoughts on that: Do you prefer Packagist or is WPackagist also an option for you?

      It really just depends on the plugin. The more work I do for others, the more inclined I am to keep it on Packagist though this one particular plugin is just an example. I don’t have much of anything else on there right now.

    1. Yeah – I mean having your work on GitHub and then registering on Packagist is what this is all about. WPackagist will automatically pull in plugins from the public WordPress repository.

      1. I understand that, i only interjected because you said “But simply contributing your work to GitHub is not enough. You have to submit your WordPress plugin to Packagist” which is misleading. Not saying that the workflow you suggested isnt smooth and nifty.

  2. Lest the above critique be misconstrued, i appreciate this blog and have used and intend to continue to use it as a resource, the attempt at clarification is for my and others use so “we” get the best out of these resources as we continually seek improvements, i may also like you said be following a totally different thought pattern from you regarding this implementation. Thanks again Tom.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.