Skip to content

Commit 85d3589

Browse files
authored
Drop Composer v1 support (#10)
1 parent adc6ac2 commit 85d3589

5 files changed

Lines changed: 23 additions & 37 deletions

File tree

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
- '8.1'
2222
- '8.2'
2323
- '8.3'
24+
- '8.4'
25+
- '8.5'
2426

2527
steps:
2628
- uses: actions/checkout@v4
@@ -29,6 +31,7 @@ jobs:
2931
uses: shivammathur/setup-php@v2
3032
with:
3133
php-version: ${{ matrix.php-version }}
34+
tools: composer:v2
3235
coverage: xdebug
3336

3437
- name: Install dependencies

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,30 @@
66
[![Follow Roots](https://img.shields.io/badge/follow%20@rootswp-1da1f2?logo=twitter&logoColor=ffffff&message=&style=flat-square)](https://twitter.com/rootswp)
77
[![Sponsor Roots](https://img.shields.io/badge/sponsor%20roots-525ddc?logo=github&style=flat-square&logoColor=ffffff&message=)](https://github.com/sponsors/roots)
88

9-
*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)*
9+
> [!NOTE]
10+
> 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).
1011
1112
A custom Composer plugin to install WordPress core outside of `vendor`.
1213

1314
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.
1415

15-
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/).
16+
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.
1617

1718
## Support us
1819

1920
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.
2021

22+
## Requirements
23+
24+
- Composer 2+
25+
- PHP 7.2.24+
26+
27+
Composer 2 requires explicitly allowing plugins. If needed, run:
28+
29+
```bash
30+
composer config --no-plugins allow-plugins.roots/wordpress-core-installer true
31+
```
32+
2133
## Community
2234

2335
Keep track of development and community news.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
"class": "Roots\\Composer\\WordPressCorePlugin"
3333
},
3434
"require": {
35-
"composer-plugin-api": "^1.0 || ^2.0",
35+
"composer-plugin-api": "^2.0",
3636
"php": ">=7.2.24"
3737
},
3838
"require-dev": {
39-
"composer/composer": "^1.0 || ^2.0",
39+
"composer/composer": "^2.0",
4040
"phpunit/phpunit": "^8.5"
4141
},
4242
"conflict": {

tests/phpunit/WordPressCoreInstallerTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,7 @@ private function jpbExpectException($class, $message = '', $isRegExp = false)
221221
$this->expectException($class);
222222
if ($message) {
223223
if ($isRegExp) {
224-
if (method_exists($this, 'expectExceptionMessageRegExp')) {
225-
$this->expectExceptionMessageRegExp($message);
226-
} else {
227-
$this->expectExceptionMessageMatches($message);
228-
}
224+
$this->expectExceptionMessageMatches($message);
229225
} else {
230226
$this->expectExceptionMessage($message);
231227
}

tests/phpunit/WordPressCorePluginTest.php

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@
2424
use Composer\Composer;
2525
use Composer\Config;
2626
use Composer\Installer\InstallationManager;
27-
use Composer\IO\IOInterface;
2827
use Composer\IO\NullIO;
2928
use Composer\Package\RootPackage;
30-
use Composer\Plugin\PluginInterface;
31-
use Composer\Test\Mock\HttpDownloaderMock;
3229
use Composer\Util\HttpDownloader;
3330
use Composer\Util\Loop;
3431
use Roots\Composer\WordPressCorePlugin;
@@ -55,7 +52,9 @@ public function testActivate()
5552
$composer->setDownloadManager($downloadManager);
5653

5754
$nullIO = new NullIO();
58-
$installationManager = $this->getInstallationManager($composer, $nullIO);
55+
$http = new HttpDownloader($nullIO, $composer->getConfig());
56+
$loop = new Loop($http);
57+
$installationManager = new InstallationManager($loop, $nullIO);
5958
$composer->setInstallationManager($installationManager);
6059

6160
$plugin = new WordPressCorePlugin();
@@ -65,28 +64,4 @@ public function testActivate()
6564

6665
$this->assertInstanceOf('\Roots\Composer\WordPressCoreInstaller', $installer);
6766
}
68-
69-
/**
70-
* @param Composer $composer
71-
* @param IOInterface $io
72-
*
73-
* @return InstallationManager
74-
*/
75-
private function getInstallationManager($composer, $io)
76-
{
77-
$installationManager = null;
78-
switch (explode('.', PluginInterface::PLUGIN_API_VERSION)[0]) {
79-
case '1':
80-
$installationManager = new InstallationManager();
81-
break;
82-
case '2':
83-
default:
84-
$http = new HttpDownloader($io, $composer->getConfig());
85-
$loop = new Loop($http);
86-
$installationManager = new InstallationManager($loop, $io);
87-
break;
88-
}
89-
90-
return $installationManager;
91-
}
9267
}

0 commit comments

Comments
 (0)