From c4b720161fd217093368017fb6826b019d77238d Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Mon, 24 Aug 2026 20:17:21 -0400 Subject: [PATCH] fix: preserve plugin self-updates and clarify framework-agnostic Composer application support. --- CHANGELOG.md | 1 + README.md | 39 ++++++++------------------------------- src/Foxy.php | 9 ++++++--- tests/FoxyTest.php | 26 ++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a20bda7..2d38e29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - docs: update command syntax in `development.md` and `testing.md` for clarity and consistency. - fix: remove the unnecessary `src` argument from the Rector command in `composer.json`. - feat: prepare Foxy `0.3` for PHP `8.3`, faster execution, safer fallbacks, updated tooling, and clearer docs. +- fix: preserve plugin self-updates and clarify framework-agnostic Composer application support. ## 0.2.0 January 24, 2026 diff --git a/README.md b/README.md index 458dd54..43c279c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

- - PHP Forge + + PHP Forge

Foxy


@@ -18,8 +18,8 @@ Easy Coding Standard - - Dependency Check + + Security

@@ -74,33 +74,11 @@ contains lockfiles from more than one manager. ## Quick start -### Yii2 application template 22 +### Composer-based PHP application -The [Yii2 basic application template branch 22](https://github.com/yiisoft/yii2-app-basic/tree/22) requires PHP 8.3 -and targets [Yii2 framework branch 22.0](https://github.com/yiisoft/yii2/tree/22.0). Create the tested development -version with: - -```bash -composer create-project --prefer-dist yiisoft/yii2-app-basic basic 22.x-dev -``` - -The application keeps `package.json` at the project root and configures npm explicitly. Foxy merges frontend -dependencies from installed Composer packages and runs npm during Composer install and update operations. - -For an existing Yii2 22 application, use the installation commands above and ensure its configuration contains: - -```json -{ - "config": { - "allow-plugins": { - "php-forge/foxy": true - }, - "foxy": { - "manager": "npm" - } - } -} -``` +Foxy is framework agnostic and works with any Composer-based PHP application that meets the requirements above. No +framework integration or application template is required. Composer packages that opt in contribute their frontend +dependencies, and Foxy merges them whenever Composer installs or updates the project. ### Project with package.json under web/ @@ -145,7 +123,6 @@ the Composer project directory. [![PHPStan Level 5](https://img.shields.io/badge/PHPStan-Level%205-4F5D95.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/php-forge/foxy/actions/workflows/static.yml) [![Quality](https://img.shields.io/github/actions/workflow/status/php-forge/foxy/quality.yml?style=for-the-badge&label=Quality&logo=github)](https://github.com/php-forge/foxy/actions/workflows/quality.yml) [![Dependency Check](https://img.shields.io/github/actions/workflow/status/php-forge/foxy/dependency-check.yml?style=for-the-badge&label=Dependency%20Check&logo=github)](https://github.com/php-forge/foxy/actions/workflows/dependency-check.yml) -[![Security](https://img.shields.io/github/actions/workflow/status/php-forge/foxy/security.yml?style=for-the-badge&label=Security&logo=github)](https://github.com/php-forge/foxy/actions/workflows/security.yml) ## Community diff --git a/src/Foxy.php b/src/Foxy.php index ccb269c..15c62c4 100644 --- a/src/Foxy.php +++ b/src/Foxy.php @@ -133,7 +133,7 @@ public function init(): void $this->assetFallback->save(); $this->composerFallback->save(); - if ($this->config->isEnabled('run-asset-manager')) { + if ($this->isEnabled('run-asset-manager')) { $this->assetManager->validate(); } } @@ -208,8 +208,11 @@ private function getAssetManager( /** * Check whether plugin execution is enabled. */ - private function isEnabled(): bool + private function isEnabled(string $key = 'enabled'): bool { - return $this->config->isEnabled('enabled'); + // Composer can load this entry point with the previous Config class during a plugin self-update. + $value = $this->config->get($key); + + return true === $value || 1 === $value || '1' === $value; } } diff --git a/tests/FoxyTest.php b/tests/FoxyTest.php index ec1b45f..c973f63 100644 --- a/tests/FoxyTest.php +++ b/tests/FoxyTest.php @@ -15,6 +15,7 @@ use Composer\Repository\RepositoryManager; use Composer\Script\{Event, ScriptEvents}; use Foxy\Asset\{AbstractAssetManager, AssetManagerInterface}; +use Foxy\Config\Config as FoxyConfig; use Foxy\Exception\RuntimeException; use Foxy\Fallback\AssetFallback; use Foxy\Foxy; @@ -247,6 +248,31 @@ public function testActivateWithInvalidManager(): void $foxy->activate($this->composer, $this->io); } + public function testConfigurationFlagsRemainCompatibleDuringPluginSelfUpdate(): void + { + $config = $this + ->getMockBuilder(FoxyConfig::class) + ->disableOriginalConstructor() + ->onlyMethods(['get', 'isEnabled']) + ->getMock(); + + $config + ->expects(self::exactly(2)) + ->method('get') + ->willReturnCallback( + static fn(string $key): bool|int => 'enabled' === $key ? 1 : false, + ); + $config->expects(self::never())->method('isEnabled'); + + $foxy = new Foxy(); + $reflection = new ReflectionClass($foxy); + $reflection->getProperty('config')->setValue($foxy, $config); + $isEnabled = $reflection->getMethod('isEnabled'); + + self::assertTrue($isEnabled->invoke($foxy)); + self::assertFalse($isEnabled->invoke($foxy, 'run-asset-manager')); + } + public function testDeactivate(): void { $foxy = new Foxy();