Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'

steps:
- uses: actions/checkout@v4
Expand All @@ -29,6 +31,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
coverage: xdebug

- name: Install dependencies
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 1 addition & 5 deletions tests/phpunit/WordPressCoreInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
31 changes: 3 additions & 28 deletions tests/phpunit/WordPressCorePluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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;
}
}
Loading