For the complete documentation index, see llms.txt. This page is also available as Markdown.

Example

This page provides a complete example of implementing Web Push notifications in a Symfony application.

Complete Working Example

Step 1: Configuration

First, configure the bundle with VAPID authentication:

config/packages/webpush.yaml
webpush:
  vapid:
    enabled: true
    subject: 'mailto:admin@example.com'
    web_token:
      enabled: true
      public_key: '%env(WEBPUSH_PUBLIC_KEY)%'
      private_key: '%env(WEBPUSH_PRIVATE_KEY)%'
  payload:
    aes128gcm:
      padding: 'recommended'
    aesgcm:
      padding: 'recommended'
  logger: 'monolog.logger'

Step 2: Create the Subscription Entity

Step 3: Create the Repository

Step 4: Create the Subscription Controller

Step 5: Create the Notification Service

Step 6: Client-side JavaScript

Step 7: Usage Example

Demo Application

For a complete working demo application, please visit: https://github.com/Spomky-Labs/web-push-demo

Last updated

Was this helpful?