Install the Bundle:
composer require alexandermatveev/raven-bundle
Update AppKernel.php to register the bundle:
new AlexanderMatveev\RavenBundle\AlexanderMatveevRavenBundle(),
Install Assets:
php bin/console assets:install web --symlink
Verify the asset is available at:
/web/bundles/alexandermatveevraven/raven.min.js
First Use Case:
Include the script in your base template (e.g., base.html.twig):
<script src="{{ asset('bundles/alexandermatveevraven/raven.min.js') }}"></script>
Initialize Raven in JavaScript (e.g., app.js):
Raven.config('YOUR_DSN_HERE').install();
Configuration:
config.yml (if supported) or environment variables.app/config/config_prod.yml:
alexander_matveev_raven:
dsn: '%env(SENTRY_DSN)%'
Integration with Symfony:
{{ raven_context|json_encode|raw }}
Raven::captureMessage('Failed to process order', [
'order_id' => $order->id,
'user_id' => $user->id,
]);
Asset Management:
<script src="{{ asset('bundles/alexandermatveevraven/raven.min.js', {'version': '1.0'}) }}"></script>
Environment-Specific Setup:
dev environment via Twig:
{% if app.environment == 'dev' %}
<script>window.Raven = {install: function() {}};</script>
{% else %}
{{ include('scripts/raven.js') }}
{% endif %}
Outdated Dependencies:
raven.js via CDN or bundle it separately.Asset Path Assumptions:
/web/bundles/alexandermatveevraven/. Custom paths may break asset resolution.config.yml (if configurable) or symlink manually.No Symfony 3/4+ Support:
symfony/sentry-bundle.Missing Configuration Options:
Raven.config('DSN', {
release: '1.0.0',
environment: 'production',
ignoreUrls: [/^\/health-check/]
}).install();
Verify Installation:
raven.min.js loads in the browser’s Network tab. 404 errors indicate asset misconfiguration.Test Error Capture:
throw new Error('Test')) and check Sentry for the event. Missing events may indicate:
Raven.install().Log Level:
app/config/config_dev.yml:
monolog:
handlers:
main:
level: debug
Custom Error Handling:
kernel.exception event.Dynamic DSN:
fetch('/api/sentry-dsn')
.then(response => response.text())
.then(dsn => Raven.config(dsn).install());
Polyfill for Modern Sentry:
raven.min.js with @sentry/browser via npm/webpack for up-to-date features.How can I help you explore Laravel packages today?