yiisoft / yiisoft/yii-debug-api
Fatal Error: Cannot modify readonly property Yiisoft\Yii\Http\Application::$dispatcher in HttpApplicationWrapper
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 17
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
Description
Description:
When trying to use yiisoft/yii-debug-api with the latest versions of Yii3 core packages (specifically where Yiisoft\Yii\Http\Application::$dispatcher has been refactored to be a readonly property), a Fatal Error is thrown on every request.
The wrapper attempts to modify this readonly property via reflection/closure, which PHP explicitly forbids, crashing the entire application.
Error Stack Trace:
Unhandled error "Cannot modify readonly property Yiisoft\Yii\Http\Application::$dispatcher" while building "Yiisoft\Yii\Http\Application".
Caused by: Error
Cannot modify readonly property Yiisoft\Yii\Http\Application::$dispatcher
in ./vendor/yiisoft/yii-debug-api/src/Debug/Http/HttpApplicationWrapper.php at line 29
Steps to Reproduce:
- Install yiisoft/yii-debug:dev-master and yiisoft/yii-debug-api:dev-master with Symfony 6.4+/7.x support.
- Enable the debug extension in config/params.php.
- Try to access any endpoint or the /debug route.
Environment:
PHP Version: 8.2.12
Framework: Yii3 (latest dev-master / stable components)
Package Version: yiisoft/yii-debug-api (dev-master / 3.0.x-dev)
Proposed Solution:
The HttpApplicationWrapper.php needs to be refactored so it doesn't attempt to overwrite the $dispatcher property directly if it is marked as readonly, or Yii3's Application class should provide a safe way to intercept or decorate the dispatcher without mutating a readonly state.
Package version
yiisoft/yii-debug-api: 3.0.x-dev (dev-master) | yiisoft/yii-debug: 3.0.x-dev (dev-master)
PHP version
8.2.12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/Debug/Http/HttpApplicationWrapper.php at line 29 and reproduce the failure by accessing any endpoint or the /debug route with the debug extension enabled. Trace how the wrapper handles Application::$dispatcher and verify the approach does not mutate the readonly property. Done means requests and the /debug route no longer fail with the fatal error on the stated Yii3 and PHP versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100