Support for PHP Framework Yii2
razvanphp opened this issue · 4 comments
Hello,
I see that in the documentation of the agent it's stated that Yii 1.x support is built-in for automatic framework detection, but we've noticed that for Yii 2 this is not the case.
To give you some context about this, Yii 2.0 was released in Oct 2014 and it's been well maintained since then to be a reputable PHP framework used in (many) production deployments.
Yii 1.1 end of life was declared since 2023, but it still receives security updates from the community till 2026.
Since the integration extensions are not so great and have low quality of code, was wondering if it would be possible to develop the framework detection in the Newrelic Agent for everybody, I'm sure the community would love that.
Can we support somehow with the testing and implementation? Are contributions welcome for this? I could probably do it myself with some guidance and testing support.
PS: we also sent this internally through support, Feature Request ID: NR-158719
Thank you in advance!
R
For reference, here is the current detection trigger code:
newrelic-php-agent/agent/fw_yii.c
Lines 84 to 89 in 320ea57
This is the referenced source code from Yii1:
- https://github.com/yiisoft/yii/blob/master/framework/web/actions/CAction.php#L70
- https://github.com/yiisoft/yii/blob/master/framework/web/actions/CInlineAction.php#L41
In Yii2, the Action class is renamed to:
- https://github.com/yiisoft/yii2/blob/master/framework/base/Action.php#L82
- https://github.com/yiisoft/yii2/blob/master/framework/base/InlineAction.php#L49
Yii2 has automatic route naming function getUniqueId() that we should use, it prepends the module name too, when present.
Please let me know if I can provide more information for fixing this.
Discovered also the path here:
newrelic-php-agent/agent/php_execute.c
Lines 415 to 416 in 320ea57
This file is now named
Yii.php
, so correct path for v2 would be yiisoft/yii2/Yii.php
or just yii2/Yii.php
The biggest problem is that currently the ErrorHandler is not wrapped at all, so no errors are displayed in NewRelic...
I can see for other frameworks that this is implemented:
newrelic-php-agent/agent/fw_laravel.c
Line 573 in 320ea57
@razvanphp Thank you for providing the details of changes in Yii2 and your contribution. Our team is actively looking into incorporating these updates in one of the upcoming agent release.
I can confirm that this works with the official version of PHP agent now.