Search by

yard / wp-package-installer

Yard

Composer installer for WordPress packages

Package info

github.com/yardinternet/wp-package-installer

Type:composer-plugin

pkg:composer/yard/wp-package-installer

Statistics

Installs: 68

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 2

v1.2.1 2026-12-02 09:17 UTC

This package is auto-updated.

Last update: 2026-12-02 09:17:48 UTC


README

A Composer plugin that installs packages of type wordpress-package into a dedicated directory, similar to how composer/installers handles plugins and themes.

Installation

composer require yard/wp-package-installer

Usage

Give a package the wordpress-package type in its composer.json:

{
    "name": "yard/some-wordpress-package",
    "type": "wordpress-package"
}

When required by a project, it will be installed into:

wp-content/packages/<vendor>/<package-name>

Custom install directory

Override the default install location by setting wordpress-packages-install-dir in the root project's composer.json:

{
    "extra": {
        "wordpress-packages-install-dir": "web/app/packages"
    }
}

Runtime helpers

This package also ships a small set of helper functions for resolving the filesystem path or URL of any installed wordpress-package, by its Composer package name. They live under the Yard\WordPressPackageInstaller namespace:

  • Yard\WordPressPackageInstaller\package_path( string $package, ?string $path = null ): ?string — absolute filesystem path to the installed package (optionally appending $path), or null if the package isn't installed.
  • Yard\WordPressPackageInstaller\package_url( string $package, ?string $path = null ): ?string — URL to the installed package (optionally appending $path), or null if the package isn't installed, its path falls outside the webroot, or the webroot cannot be determined.
  • Yard\WordPressPackageInstaller\package_version( string $package ): ?string — installed version of the package, or null if it isn't installed. For dev-* versions, the commit reference is returned instead of the branch alias.
use function Yard\WordPressPackageInstaller\package_path;
use function Yard\WordPressPackageInstaller\package_url;
use function Yard\WordPressPackageInstaller\package_version;

$path    = package_path( 'yard/some-wordpress-package' );
$url     = package_url( 'yard/some-wordpress-package', '/assets/style.css' );
$version = package_version( 'yard/some-wordpress-package' );

package_url() derives the URL by stripping $_SERVER['DOCUMENT_ROOT'] from the resolved path and appending the remainder to the webroot's own URL, so it requires the package to be installed somewhere under the site's webroot. Where DOCUMENT_ROOT is unset, as under WP-CLI and cron, it returns null rather than guessing a base.

Only the scheme, host and port of home_url() are used: on a subdirectory multisite a subsite's home URL carries the subsite's path, which is no part of where the package sits on disk.

These functions are loaded automatically wherever this package's Composer autoloader is included (e.g. vendor/autoload.php).

About us

banner