There are a lot of other threads on this subject. Be sure to search for existing solutions before posting a new thread.
I’m assuming you’re talking about Bedrock here, even though this thread is tagged Sage; everything below presumes you’re using Bedrock.
SatisPress is a great option, but requires a little more management than I usually need. Here’s how I handle it:
Create a private GitHub Repo for your paid plugin
I’m using SearchWP as an example here.
Create a composer.json and commit it to the repository alongside the plugin code:
{
"name": "mwdelaney/searchwp",
"description": "",
"keywords": ["wordpress", "plugin", "search"],
"homepage": "https://github.com/mwdelaney/searchwp",
"license": "MIT",
"authors": [
{
"name": "Michael W. Delaney",
"email": "name@domain.com",
"homepage": ""
}
],
"type": "wordpress-plugin",
"require": {
"php": ">=5.3.2"
}
}
Make sure the repository private, otherwise you’re making paid code available to the world! Commit your paid plugin (and the above composer.json
file) to the repo and create a release matching the version number of the plugin you’re committing.
Add the private repo to your project’s composer.json
Add the repository to the repositories
section of composer.json
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
},
...
{
"type": "vcs",
"url": "git@github.com:mwdelaney/searchwp.git"
},
...
],
And add the actual plugin to the require
section of composer.json
"require": {
...
"mwdelaney/searchwp": "^2.9.5",
...
},
Update your dependencies
Run composer update
in your bedrock directory to get your new plugin.