Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Polyfill Newrelic

Polyfill Newrelic Laravel Package

ostrolucky/polyfill-newrelic

Composer polyfill that defines New Relic PHP agent newrelic_* functions when the New Relic extension isn’t installed. Helps apps run on PHP setups without the extension while keeping calls to the agent API compatible.

View on GitHub
Deep Wiki
Context7

Polyfill for the New Relic PHP extension

Frequently asked questions about Polyfill Newrelic
How do I install the New Relic polyfill in a Laravel project?
Run `composer require ostrolucky/polyfill-newrelic` in your project directory. The package will automatically register itself if Laravel’s autoloader detects it. No additional configuration is required unless you need environment-specific behavior.
Does this polyfill work with Laravel’s service container?
Yes, the polyfill integrates seamlessly with Laravel’s service container. It mimics the native New Relic extension’s functions (`newrelic_*`) without requiring manual binding, though you may need to conditionally enable it via `config/newrelic.php` for environments like Docker or CI.
Which Laravel versions are supported by this polyfill?
The polyfill is designed for Laravel 8.x and 9.x. For Laravel 10+, verify compatibility with PHP 8.1+ as the polyfill may rely on deprecated functions in older PHP versions. Always check the package’s `composer.json` for version constraints.
Will this polyfill work in CI/CD pipelines where the New Relic extension isn’t installed?
Absolutely. The polyfill is explicitly built for environments lacking the native extension, such as Docker containers or CI/CD pipelines. It ensures `newrelic_*` functions remain available without requiring the extension to be pre-installed.
Are all New Relic PHP extension functions supported by this polyfill?
The polyfill covers core `newrelic_*` functions like `newrelic_start_transaction()` and `newrelic_notice_error()`, but advanced features (e.g., custom metrics, distributed tracing) may not be fully supported. Test critical workflows to confirm feature parity for your use case.
How do I conditionally enable the polyfill only in specific environments (e.g., Docker)?
Use Laravel’s environment detection in `config/newrelic.php` to toggle the polyfill. For example, add `'enabled' => app()->environment('docker'),` to your New Relic config array. The polyfill will activate automatically when the native extension is absent.
Does this polyfill introduce performance overhead compared to the native New Relic extension?
Yes, polyfills typically add a slight abstraction layer, which may introduce minimal latency. Benchmark your application in staging to measure the impact, especially for high-throughput endpoints. The overhead is usually negligible for most use cases.
Can I use this polyfill alongside the native New Relic extension in production?
Yes, the polyfill is designed to coexist with the native extension. It will only activate when the extension is unavailable. However, ensure your Laravel config doesn’t conflict between the two (e.g., duplicate transaction naming). Test in staging first.
Are there alternatives to this polyfill for New Relic instrumentation in Laravel?
Alternatives include manually implementing `newrelic_*` functions or using New Relic’s official PHP agent with a Docker image that includes the extension. However, this polyfill is the most lightweight solution for environments where the extension cannot be installed.
How do I test my Laravel app with the polyfill enabled?
Mock the New Relic extension in unit tests using PHP’s `extension_loaded()` check or environment variables to simulate its absence. For integration tests, deploy to a Dockerized environment without the extension and verify metrics are still captured. Use Laravel’s `AppServiceProvider` to conditionally load the polyfill in tests.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views