### Start the WebSocket Server Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Execute this command to initiate the Sockeon WebSocket server. ```bash php artisan start:sockeon ``` -------------------------------- ### Install and verify bcmath extension Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Install the required bcmath PHP extension and verify its installation. ```bash # Debian/Ubuntu sudo apt-get install php-bcmath sudo systemctl restart php8.2-fpm # Adjust version as needed # Check installation php -m | grep bcmath ``` -------------------------------- ### Start Sockeon Server Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Command to initiate the WebSocket server required for real-time notifications. ```bash php artisan sockeon:start ``` -------------------------------- ### Install Package via Composer Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Install the package using Composer. ```bash composer require xentixar/filament-push-notifications ``` -------------------------------- ### Install PHP Extensions Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Installs necessary PHP extensions for push notification functionality. ```bash # For Debian/Ubuntu sudo apt-get install php-bcmath # Or for better performance, install GMP sudo apt-get install php-gmp ``` -------------------------------- ### Update Sockeon Start Command Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Updates the command used to start the Sockeon server. ```bash # Old command: php artisan sockeon:start # New command: php artisan start:sockeon ``` ```ini [program:sockeon] command=php /path/to/your/project/artisan start:sockeon ``` -------------------------------- ### Run Migrations Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Execute the migrations to set up the required database tables. ```bash php artisan migrate ``` -------------------------------- ### Publish Configuration and Migrations Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Publish the necessary configuration files and database migrations to your application. ```bash php artisan vendor:publish --tag=filament-push-notifications-config php artisan vendor:publish --tag=filament-push-notifications-migrations ``` -------------------------------- ### Publish Configuration Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Backs up existing configuration and publishes the new version for manual merging. ```bash # Backup your current config cp config/filament-push-notifications.php config/filament-push-notifications.php.backup # Publish the new config php artisan vendor:publish --tag=filament-push-notifications-config --force # Manually merge your customizations from the backup ``` -------------------------------- ### Run Migrations Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Publishes and runs the migration for the push_subscriptions table. ```bash php artisan vendor:publish --tag=filament-push-notifications-migrations php artisan migrate ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Set up WebSocket and Web Push configuration in your .env file. ```env # WebSocket Server Configuration SOCKEON_HOST=localhost SOCKEON_PORT=8080 SOCKEON_KEY=your-secret-key SOCKEON_DEBUG=true # Web Push VAPID Keys (Generated via: php artisan push:generate-vapid-keys) VAPID_PUBLIC_KEY="your-public-key" VAPID_PRIVATE_KEY="your-private-key" VAPID_SUBJECT="mailto:admin@example.com" # Web Push Configuration (Optional) WEB_PUSH_TTL=2419200 WEB_PUSH_URGENCY=normal # Native Notification Configuration (Optional) NOTIFICATION_FAVICON=https://your-domain.com/favicon.ico NOTIFICATION_DEFAULT_URL=https://your-domain.com NOTIFICATION_TAG=default NOTIFICATION_REQUIRE_INTERACTION=false NOTIFICATION_SILENT=false NOTIFICATION_BADGE=https://your-domain.com/badge.ico NOTIFICATION_DIR=auto NOTIFICATION_LANG=en NOTIFICATION_RENOTIFY=false NOTIFICATION_TIMEOUT=5000 ``` -------------------------------- ### Configure Web Push settings Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Add the new web_push configuration section to your package configuration file to enable VAPID authentication and push notification settings. ```php 'web_push' => [ 'vapid_public_key' => env('VAPID_PUBLIC_KEY'), 'vapid_private_key' => env('VAPID_PRIVATE_KEY'), 'vapid_subject' => env('VAPID_SUBJECT', 'mailto:admin@example.com'), 'ttl' => env('WEB_PUSH_TTL', 2419200), 'urgency' => env('WEB_PUSH_URGENCY', 'normal'), 'topic' => env('WEB_PUSH_TOPIC', null), ], ``` -------------------------------- ### Rollback to version 1.x Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Follow these steps to revert the package to version 1.x, including database and configuration restoration. ```bash # 1. Update composer.json composer require xentixar/filament-push-notifications:^1.0 # 2. Rollback the migration (CAUTION: This deletes subscription data) php artisan migrate:rollback --step=1 # 3. Restore your old config file cp config/filament-push-notifications.php.backup config/filament-push-notifications.php # 4. Remove service worker rm public/service-worker.js # 5. Clear caches php artisan config:clear php artisan cache:clear php artisan view:clear # 6. Restart Sockeon with old command php artisan sockeon:start ``` -------------------------------- ### Enable Debug Mode Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Configuration setting to enable verbose logging in the .env file. ```env SOCKEON_DEBUG=true ``` -------------------------------- ### Publish service worker assets Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Use this command to force publish the service worker assets if a 404 error occurs. ```bash php artisan vendor:publish --tag=filament-push-notifications-assets --force ``` -------------------------------- ### Configure Environment Variables for Production Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Update the .env file to define internal binding and external public connection settings for the WebSocket server. ```env # Server Binding (Internal) SOCKEON_HOST=127.0.0.1 SOCKEON_PORT=8080 # Public Connection (External) SOCKEON_EXTERNAL_HOST=ws.your-domain.com SOCKEON_EXTERNAL_PORT=443 ``` -------------------------------- ### Update WebSocket configuration Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Include the new external host and port settings in the socket configuration to support WSS and reverse proxy environments. ```php 'socket' => [ // ... existing configs 'external_host' => env('SOCKEON_EXTERNAL_HOST', env('SOCKEON_HOST', 'localhost')), 'external_port' => env('SOCKEON_EXTERNAL_PORT', env('SOCKEON_PORT', 8080)), ], ``` -------------------------------- ### Generate VAPID Keys Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Generate and automatically add VAPID keys to your .env file. ```bash php artisan push:generate-vapid-keys --update-env ``` -------------------------------- ### Update Environment Variables Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Required environment variables for VAPID authentication and Web Push configuration. ```env # Web Push VAPID Keys (Generated via: php artisan push:generate-vapid-keys) VAPID_PUBLIC_KEY="your-generated-public-key" VAPID_PRIVATE_KEY="your-generated-private-key" VAPID_SUBJECT="mailto:admin@yourdomain.com" # Web Push Configuration (Optional - defaults shown) WEB_PUSH_TTL=2419200 # 4 weeks in seconds WEB_PUSH_URGENCY=normal # Options: very-low, low, normal, high WEB_PUSH_TOPIC= # Optional: for replacing notifications # For Production with SSL/WSS Support SOCKEON_HOST=127.0.0.1 # Internal bind address SOCKEON_PORT=8080 # Internal bind port SOCKEON_EXTERNAL_HOST=ws.yourdomain.com # Public WebSocket host SOCKEON_EXTERNAL_PORT=443 # Public WebSocket port (SSL) ``` -------------------------------- ### Register Plugin in Admin Panel Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Add the PushNotification plugin to your Filament AdminPanelProvider. ```php use Xentixar\FilamentPushNotifications\PushNotification; class AdminPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel // ... other configuration ->plugins([ // ... other plugins PushNotification::make(), ]); } } ``` -------------------------------- ### Configure Nginx Reverse Proxy Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Set up an Nginx server block to handle SSL termination and proxy WebSocket traffic to the internal Sockeon server. ```nginx server { listen 443 ssl http2; server_name ws.your-domain.com; ssl_certificate /path/to/cert.pem; ssl_certificate_key /path/to/key.pem; # Proxy to Sockeon (Internal) location / { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; # WebSocket support proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # Forward headers proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # WebSocket timeouts proxy_connect_timeout 7d; proxy_send_timeout 7d; proxy_read_timeout 7d; } } ``` -------------------------------- ### Publish Service Worker Assets Source: https://github.com/xentixar/filament-push-notifications/blob/main/README.md Publish the required service worker files to the public directory. ```bash php artisan vendor:publish --tag=filament-push-notifications-assets ``` -------------------------------- ### Clear Caches Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Clears Laravel caches to ensure new configurations are loaded. ```bash php artisan config:clear php artisan cache:clear php artisan view:clear php artisan route:clear ``` -------------------------------- ### Update Composer Dependencies Source: https://github.com/xentixar/filament-push-notifications/blob/main/UPGRADE.md Updates the package to the latest version and pulls in required dependencies. ```bash composer update xentixar/filament-push-notifications ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.