Are you working on a new super useful WordPress plugin? Do you want it to be developer-friendly? Define it as a Composer package and submit it to the official Composer package repository: Packagist.org. Other programmers can then require your plugin as a dependency to their projects. You’ll make their lives much better and they’ll give you a hug.
Defining a plugin as Composer package
Before using Composer, you need to download and install it. When installed, open your command line application and navigate to your plugin’s main directory. Run
composer init
from the command line. An interactive Composer config generator will guide you through the process. Fill out the package name and rest of the fields. After that, edit the generated composer.json
file and add a new key-value pair:
"type": "wordpress-plugin"
under the "name"
key. You also need to add composer/installers
into the "require"
part of the file:
"require": { "composer/installers": "~1.0.12" }
Using git, commit and push the plugin to GitHub or any other online git repository.
Submitting the plugin to Packagist.org
Create a new account onPackagist.org. Hit the “Submit Package” button. Copy-paste the plugin’s online git repository URL to the input field and hit “Check”. Finish the process.
Congratulations, your plugin is now in the official Composer package repository!
Now, I can simply require it and have it installed into my WordPress project’s plugins directory.