Download the PHP package netosts/laravel-fcm-notifications without Composer

On this page you can find all versions of the php package netosts/laravel-fcm-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-fcm-notifications

Laravel FCM Notifications

Latest Version on Packagist Total Downloads License

A robust and secure Firebase Cloud Messaging (FCM) notification system for Laravel applications. This package provides a comprehensive solution for sending push notifications with automatic token management, cleanup, and support for all FCM message types.

Table of Contents

Features

Requirements

Installation

You can install the package via Composer:

Publish the configuration file:

Quick Start

Get up and running in minutes:

1. Set up your Firebase credentials

Add these environment variables to your .env file:

2. Add FCM token to your User model

3. Send your first notification

That's it! Your notification will be sent to the user's device.

Configuration

๐Ÿ’ก Tip: If you just want to get started quickly, check the Quick Start section above.

1. Firebase Setup

To use FCM, you need a Firebase project with proper credentials:

  1. Go to the Firebase Console
  2. Create a new project or select an existing one
  3. Navigate to Project Settings โ†’ Service Accounts
  4. Click Generate New Private Key to download the service account JSON file

2. Environment Variables

Add the following variables to your .env file:

โš ๏ธ Important: The private key must include \n characters for line breaks.

3. Database Setup

Choose one of the following approaches for storing FCM tokens:

Option A: Multiple Tokens per User (Recommended)

For users with multiple devices, create a dedicated tokens table:

Option B: Single Token per User

Add a token column to your existing users table:

4. Token Management

Configure how the package discovers FCM tokens from your models:

For Multiple Tokens (Option A)

For Single Token (Option B)

Usage

Basic Usage

There are two main ways to send FCM notifications:

Method 1: Using FcmNotification Directly (Simple)

Method 2: Custom Notification Class (Recommended)

Create a custom notification class for better organization:

Extend the FcmNotification class:

Use your custom notification:

Direct Service Usage

For more control, use the FCM service directly:

Message Types

FCM supports different message types for different use cases:

1. Notification + Data (Default)

Shows a system notification and passes custom data to your app:

2. Data Only

Sends data silently to your app without showing a notification:

3. Notification Only

Shows only a system notification without custom data:

Batch Sending

Send the same message to multiple devices efficiently:

Platform-Specific Configuration

Customize notifications for different platforms:

Android Specific Settings

iOS Specific Settings

Cross-Platform Message

Event Listeners

The package automatically handles token cleanup through events:

When an invalid token is detected, it's automatically removed from your database (if FCM_AUTO_CLEANUP_TOKENS=true).

Testing

Built-in Test Commands

The package includes helpful commands for testing your FCM integration:

Token Validation

Validate FCM tokens before sending notifications:

Testing in Development

Configuration Options

The config/fcm-notifications.php file provides comprehensive configuration options:

Configuration Details

Option Description Default
project_id Your Firebase project ID Required
client_email Service account email Required
private_key Service account private key Required
timeout HTTP request timeout (seconds) 30
default_mode Default message type data_only
token_column Single token column name token
auto_cleanup_tokens Auto-remove invalid tokens true
cache_token Cache JWT authentication tokens true

Troubleshooting

Common Issues

๐Ÿ” Authentication Failed

Symptoms: Authentication errors, 401 responses from FCM

Solutions:

๐Ÿ” Tokens Not Found

Symptoms: No notifications sent, "no tokens found" errors

Solutions:

๐Ÿ“ฑ Messages Not Received

Symptoms: API calls succeed but notifications don't appear

Solutions:

โšก Performance Issues

Symptoms: Slow notification sending, timeouts

Solutions:

Debug Mode

Enable detailed logging for troubleshooting:

This will log detailed FCM request/response information to help diagnose issues.

Getting Help

If you're still having issues:

  1. Check the logs - Look in storage/logs/laravel.log for detailed error messages
  2. Test with the built-in commands - Use php artisan fcm:test to isolate issues
  3. Validate your setup - Double-check Firebase credentials and configuration
  4. Review the FCM documentation - Some issues may be Firebase-specific

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Support

Need help? Here's how to get support:


**โญ If this package helped you, please consider giving it a star on GitHub! โญ**

All versions of laravel-fcm-notifications with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0|^11.0
illuminate/notifications Version ^10.0|^11.0
illuminate/http Version ^10.0|^11.0
illuminate/console Version ^10.0|^11.0
illuminate/cache Version ^10.0|^11.0
illuminate/log Version ^10.0|^11.0
illuminate/events Version ^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package netosts/laravel-fcm-notifications contains the following files

Loading the files please wait ....