Install PublishPress Plugins using Composer

It is possible to install and manage the PublishPress plugins using Composer.

There are separate instructions for the Free and Pro plugins.


For the PublishPress Free plugins #

Settings for composer.json #

Here is an example of the composer.json file based on WPStarter:

{
  "name": "gmazzap/wpstarter-simple-example",
  "description": "Example project for WordPress + Composer + WP Starter",
  "type": "project",
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    }
  ],
  "require": {
    "wecodemore/wpstarter": "~2.0",
    "wpackagist-plugin/publishpress": "*"
  },
  "config": {
    "vendor-dir": "wp-content/vendor"
  },
  "scripts": {
    "post-install-cmd": "WCM\WPStarter\Setup::run",
    "post-update-cmd": "WCM\WPStarter\Setup::run"
  },
  "extra": {
    "wordpress-install-dir": "wp"
  }
}

WPStarter is not required, but it is one way you can use to install WordPress itself as a Composer dependency. If you don't use WPStarter, you can add the following properties to your own composer.json file:

{
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    }
  ],
  "require": {
    "wpackagist-plugin/publishpress": "*"
  }
}

In the repository property, don't use our Github repository URL, but use the WPackagist repository.


For the PublishPress Pro plugins #

The Pro plugins are available on our private repositories.

In order to use the Pro plugins, you need some additional configuration that we'll outline below.

Settings for composer.json #

Here is an example for the composer.json file based on WPStarter:

{
  "name": "gmazzap/wpstarter-simple-example",
  "description": "Example project for WordPress + Composer + WP Starter",
  "type": "project",
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    },
    {
        "type": "vcs",
        "url": "https://github.com/publishpress/PublishPress.git"
    },
    {
      "type": "vcs",
      "url": "https://github.com/publishpress/PublishPress-Pro.git"
    }
  ],
  "require": {
    "wecodemore/wpstarter": "~2.0",
    "publishpress/publishpress-pro": "*"
  },
  "config": {
    "vendor-dir": "wp-content/vendor"
  },
  "scripts": {
    "post-install-cmd": "WCM\WPStarter\Setup::run",
    "post-update-cmd": "WCM\WPStarter\Setup::run"
  },
  "extra": {
    "wordpress-install-dir": "wp"
  }
}

If you don't use WPStarter, here are the required properties you should add to your own composer.json file:

{
  "repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/publishpress/PublishPress.git"
    },
    {
      "type": "vcs",
      "url": "https://github.com/publishpress/PublishPress-Pro.git"
    }
  ],
  "require": {
    "publishpress/publishpress-pro": "*"
  }
}

In the repository property, don't use our Github repository's URL, but use the WPackagist repository.

Settings for wp-config.php #

The Pro plugin requires an additional configuration in the wp-config.php file. You need to define two constants for specifying the path and URL of your vendor directory. The plugin requires the vendor directory is available to the internet.

define('PUBLISHPRESS_CUSTOM_VENDOR_URL', 'https://dev.local/wp-content/vendor/');
define('PUBLISHPRESS_CUSTOM_VENDOR_PATH', '/Users/me/Local Sites/dev/app/public/wp-content/vendor/');

Access to our private repositories #

If you have an active PublishPress subscription, please contact us. Send us your public SSH key and ask for repository access. The number of Composer users does depend on your plan. Our 1 Site plans provide support for 1 key, our 5 Site plans provide support for 5 keys, and so on.

Due to permissions limitations on vendor folders in Composer installations, it may not be possible to install PublishPress Pro, Authors Pro, Checklists Pro or Permissions Pro.  In some cases, a workaround is available by moving vendor files to a publicly accessible location. Contact us for details.

The authentication is done using SSH keys. You will need to generate and send one key per repository you want to access.

In case you need more info about how to generate SSH keys you can read this documentation: Generating a new SSH key and adding it to the ssh-agent.

Those keys need to be generated, or installed, in the server you want to install our plugins using Composer.