Skip to content

Instantly share code, notes, and snippets.

@mfdeveloper
Last active November 5, 2018 10:38
Show Gist options
  • Select an option

  • Save mfdeveloper/cb012310c96af8311e48dba632076e90 to your computer and use it in GitHub Desktop.

Select an option

Save mfdeveloper/cb012310c96af8311e48dba632076e90 to your computer and use it in GitHub Desktop.

Composer PHP: Wordpress plugin local path

To reference to a local path reference to a wordpress plugin, using Composer, you need do:

In your WP project/source

  1. Add a repository pointing to local path (absolute or relative) like the composer.json

  2. Add a installer-paths key to move to a specific folder when install the plugin, only if the target plugin contains contains a composer.json with type "wordpress-plugin"

  3. Reference to a git branch in require key

In target WP plugin

  1. Create a composer.json file

  2. Add a type key with value "wordpress-plugin" (optionally). The type needs match with defined in installer-paths of the wordpress project composer.json

  3. Checkout to a branch and develop your feature. The plugin will be a symlink to wp-content/plugins folder.

{
"name": "wordpress-local-plugin",
"description": "This is a local plugin relative to wordpress project",
"type": "wordpress-plugin",
"license": "GPL-3.0-only",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
}
],
"minimum-stability": "beta",
"require": {
"php": ">=5.2.0"
}
}
{
"name": "wordpress-project-local-test",
"description": "This is a composer.json example of a local dependency reference to a wordpress plugin",
"type": "project",
"license": "MIT",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
},
{
"type": "path",
"url": "/local/path/to/plugins/my-local-plugin",
"options": {
"symlink": true
}
}
],
"extra": {
"installer-paths": {
"wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
}
},
"require": {
"woocommerce-parcelas":"dev-my-branch",
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment