diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d00a30..e3045e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,15 @@ Ideas under consideration, not promises: - A read-only REST endpoint for monitoring. - A network-wide cap on multisite. +### Fixed + +- README: the Composer install now works while the Packagist listing is + pending. It adds the GitHub repository as a `vcs` source with + `"no-api": true`, so no GitHub token is needed, and gives the steps that + put the plugin in the site's plugins folder rather than `vendor/`: + allowing and requiring `composer/installers`, and `installer-paths` when + `composer.json` is not in the WordPress root (#5). + ## [0.1.0] - 2026-11-14 ### Added diff --git a/README.md b/README.md index 3e646b8..e20cc7b 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,48 @@ Requirements: PHP 8.1 or later, WordPress 6.4 or later, MySQL 5.7+ or MariaDB 10 **Without Composer.** Nothing to do: the plugin loads its own classes through `autoload.php`. To use the classes outside the plugin, `require 'path/to/gen-queue/autoload.php';`. -**With Composer.** `composer require indianopinion/gen-queue` (type `wordpress-plugin`, so installers place it in your plugins folder). It has no runtime dependencies. +**With Composer.** The package is not on Packagist yet (the listing is pending), so tell Composer where it lives first. The package type is `wordpress-plugin`, and Composer puts such a package in `vendor/`, where WordPress never loads it, unless the project uses [`composer/installers`](https://github.com/composer/installers). This package does not pull that in, so the project has to. Run these where your `composer.json` is (run `composer init` first if there is none): + +```sh +composer config repositories.gen-queue '{"type": "vcs", "url": "https://github.com/IndianOpinion/gen-queue", "no-api": true}' +composer config allow-plugins.composer/installers true +composer require composer/installers +composer require indianopinion/gen-queue +``` + +- `allow-plugins`: `composer/installers` is a Composer plugin, and Composer 2.2 and later refuse to run a plugin that `allow-plugins` does not list. Without that line, `composer require composer/installers` stops with "blocked by your allow-plugins config" when it cannot ask (CI, scripts, `--no-interaction`). +- Where the plugin lands: `composer/installers` puts it in `wp-content/plugins/gen-queue/` relative to `composer.json`. That is your site's plugins folder only when `composer.json` sits in the WordPress root (next to `wp-config.php`). If it sits elsewhere, say where the plugins folder is **before** requiring the plugin, with the path relative to `composer.json`, for example for WordPress in `web/`: + + ```sh + composer config --json extra.installer-paths '{"web/wp-content/plugins/{$name}/": ["type:wordpress-plugin"]}' + ``` + + Bedrock and similar projects already set `installer-paths` and allow the plugin, so there only the first and last commands are needed. +- `"no-api": true` makes Composer read the repository with git over HTTPS instead of the GitHub API. A plain `vcs` entry reads every branch and tag through the API, which allows anonymous callers 60 requests an hour, so it often fails without a GitHub token on shared machines and CI runners. With `no-api`, no token is needed, but the machine running Composer needs `git`. + +With `composer.json` in the WordPress root, that adds these entries to it: + +```json +{ + "require": { + "composer/installers": "^2.3", + "indianopinion/gen-queue": "^0.1.0" + }, + "repositories": [{ + "name": "gen-queue", + "type": "vcs", + "url": "https://github.com/IndianOpinion/gen-queue", + "no-api": true + }], + "config": { + "allow-plugins": { + "composer/installers": true + } + } +} +``` + +and the plugin in `wp-content/plugins/gen-queue/`. Activate it there as usual. It has no runtime Composer dependencies and loads its own classes through `autoload.php`, so no other repository entry is needed. When the Packagist listing is live, the `repositories` entry can go. ## Quick start