diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index decb5cb..5a9438e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,6 +21,8 @@ jobs: - '8.1' - '8.2' - '8.3' + - '8.4' + - '8.5' steps: - uses: actions/checkout@v4 @@ -29,6 +31,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} + tools: composer:v2 coverage: xdebug - name: Install dependencies diff --git a/README.md b/README.md index e4c5920..794d45d 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,30 @@ [![Follow Roots](https://img.shields.io/badge/follow%20@rootswp-1da1f2?logo=twitter&logoColor=ffffff&message=&style=flat-square)](https://twitter.com/rootswp) [![Sponsor Roots](https://img.shields.io/badge/sponsor%20roots-525ddc?logo=github&style=flat-square&logoColor=ffffff&message=)](https://github.com/sponsors/roots) -*This is a fork of [johnpbloch/wordpress-core-installer](https://github.com/johnpbloch/wordpress-core-installer) with some fixes to enhance compatibility with [roots/wordpress](https://packagist.org/packages/roots/wordpress)* +> [!NOTE] +> This is a fork of [johnpbloch/wordpress-core-installer](https://github.com/johnpbloch/wordpress-core-installer) with fixes to enhance compatibility with [roots/wordpress](https://packagist.org/packages/roots/wordpress). A custom Composer plugin to install WordPress core outside of `vendor`. This installer is meant to support a rather specific WordPress installation setup in which WordPress is installed in a subdirectory ([see the WordPress codex on that subject](https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory)) and in which the location of `WP_CONTENT_DIR` and `WP_CONTENT_URL` have been customized to be outside of WordPress core ([see the WordPress codex on that subject](https://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content_folder)). This is because composer will delete your whole wp-content directory every time it updates core if you don't separate the two. If that installation setup isn't what you are looking for, then this installer is probably not something you will want to use. -For more information on this site setup and using Composer to manage a whole WordPress site, [check out @Rarst's informational website](https://composer.rarst.net/) which also includes [a site stack example using this package](https://composer.rarst.net/recipe/site-stack/). +For more information on using Composer with WordPress, check out our [Composer WordPress resources](https://roots.io/composer-wordpress-resources/). Use [WP Packages](https://wp-packages.org/) to install WordPress plugins and themes via Composer, and see the [`roots/wordpress` documentation](https://wp-packages.org/roots-wordpress) for WordPress core installation options. ## Support us Roots is an independent open source org, supported only by developers like you. Your sponsorship funds [WP Packages](https://wp-packages.org/) and the entire Roots ecosystem, and keeps them independent. Support us by purchasing [Radicle](https://roots.io/radicle/) or [sponsoring us on GitHub](https://github.com/sponsors/roots) — sponsors get access to our private Discord. +## Requirements + +- Composer 2+ +- PHP 7.2.24+ + +Composer 2 requires explicitly allowing plugins. If needed, run: + +```bash +composer config --no-plugins allow-plugins.roots/wordpress-core-installer true +``` + ## Community Keep track of development and community news. diff --git a/composer.json b/composer.json index 538e812..30bcdd3 100644 --- a/composer.json +++ b/composer.json @@ -32,11 +32,11 @@ "class": "Roots\\Composer\\WordPressCorePlugin" }, "require": { - "composer-plugin-api": "^1.0 || ^2.0", + "composer-plugin-api": "^2.0", "php": ">=7.2.24" }, "require-dev": { - "composer/composer": "^1.0 || ^2.0", + "composer/composer": "^2.0", "phpunit/phpunit": "^8.5" }, "conflict": { diff --git a/tests/phpunit/WordPressCoreInstallerTest.php b/tests/phpunit/WordPressCoreInstallerTest.php index 12a592c..2bf938a 100644 --- a/tests/phpunit/WordPressCoreInstallerTest.php +++ b/tests/phpunit/WordPressCoreInstallerTest.php @@ -221,11 +221,7 @@ private function jpbExpectException($class, $message = '', $isRegExp = false) $this->expectException($class); if ($message) { if ($isRegExp) { - if (method_exists($this, 'expectExceptionMessageRegExp')) { - $this->expectExceptionMessageRegExp($message); - } else { - $this->expectExceptionMessageMatches($message); - } + $this->expectExceptionMessageMatches($message); } else { $this->expectExceptionMessage($message); } diff --git a/tests/phpunit/WordPressCorePluginTest.php b/tests/phpunit/WordPressCorePluginTest.php index 9a753da..142d8ca 100644 --- a/tests/phpunit/WordPressCorePluginTest.php +++ b/tests/phpunit/WordPressCorePluginTest.php @@ -24,11 +24,8 @@ use Composer\Composer; use Composer\Config; use Composer\Installer\InstallationManager; -use Composer\IO\IOInterface; use Composer\IO\NullIO; use Composer\Package\RootPackage; -use Composer\Plugin\PluginInterface; -use Composer\Test\Mock\HttpDownloaderMock; use Composer\Util\HttpDownloader; use Composer\Util\Loop; use Roots\Composer\WordPressCorePlugin; @@ -55,7 +52,9 @@ public function testActivate() $composer->setDownloadManager($downloadManager); $nullIO = new NullIO(); - $installationManager = $this->getInstallationManager($composer, $nullIO); + $http = new HttpDownloader($nullIO, $composer->getConfig()); + $loop = new Loop($http); + $installationManager = new InstallationManager($loop, $nullIO); $composer->setInstallationManager($installationManager); $plugin = new WordPressCorePlugin(); @@ -65,28 +64,4 @@ public function testActivate() $this->assertInstanceOf('\Roots\Composer\WordPressCoreInstaller', $installer); } - - /** - * @param Composer $composer - * @param IOInterface $io - * - * @return InstallationManager - */ - private function getInstallationManager($composer, $io) - { - $installationManager = null; - switch (explode('.', PluginInterface::PLUGIN_API_VERSION)[0]) { - case '1': - $installationManager = new InstallationManager(); - break; - case '2': - default: - $http = new HttpDownloader($io, $composer->getConfig()); - $loop = new Loop($http); - $installationManager = new InstallationManager($loop, $io); - break; - } - - return $installationManager; - } }