Download the PHP package npav/laravel-fcm-push without Composer

On this page you can find all versions of the php package npav/laravel-fcm-push. 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-push

npav/laravel-fcm-push

Firebase Cloud Messaging (HTTP v1) web push for Laravel — no kreait/firebase-php or google/apiclient dependency (the OAuth2 JWT is hand-signed with openssl, which matters if you're on a PHP build without the sodium extension, where those packages won't install at all). Channel/audience-based subscriber targeting, plus on-device diagnostics logging, because mobile browsers have no console you can open when a push silently doesn't show up.

New to this package? docs/GETTING-STARTED.md is a step-by-step walkthrough (Firebase setup → install → wire it up → debug a "notification didn't show" report) written for someone doing this for the first time. This README is the API reference.

Install

That single command is all you need — the package is a Composer plugin, so composer require automatically runs config/asset publishing, the fcm_push_subscriptions migration, and the CSRF/.env scaffolding described below. Composer will ask a one-time trust prompt the first time (answer y); see docs/GETTING-STARTED.md for details, including how to skip the prompt or opt out and do it by hand.

Can't run php artisan migrate against the target database (a remote/shared host where schema changes go through a DBA or manual execution)? Run database/sql/create_fcm_push_subscriptions_table.sql by hand instead — it's the exact same table.

Add to .env (the install step above adds these as blank placeholders automatically — just fill in the values):

Download the service account key from Firebase Console → Project Settings → Service Accounts → Generate new private key. Keep it out of version control.

CSRF — one required step

The service worker calls POST /fcm-push/log via a bare fetch(), which has no access to your page's CSRF meta tag. That route must be excluded from CSRF verification, or every diagnostic beacon 302-redirects instead of logging anything (harmless, but you lose the diagnostics).

Laravel 11+ (bootstrap/app.php):

Laravel 10 (app/Http/Middleware/VerifyCsrfToken.php):

Server-side usage

channel is whatever groups your recipients — a ticket token, an order id, a chat room slug. audience is an optional tag for splitting a channel's subscribers into groups (e.g. 'admin' vs null for "everyone else"). There's no foreign key on channel — the package doesn't know your schema.

If you don't need per-request validation before subscribing, the package ships a ready-to-use endpoint: POST /fcm-push/subscribe with {channel, fcm_token, audience?}, named route fcm-push.subscribe.

Client-side usage

Publish the JS helper once:

Service worker

GET /sw.js is registered automatically at the domain root (a service worker's control scope is limited to its own path and below, so root is usually what you want). It serves resources/stubs/sw.js.stub with your fcm-push.web.* config injected — no hardcoded config in a static file to keep in sync with .env.

If you need the service worker at a different path, or you already have one of your own registering push handlers, don't rely on the package route — call Npav\FcmPush\Http\Controllers\FcmServiceWorkerController::serve() from wherever suits you, or copy resources/stubs/sw.js.stub as a starting point.

Gotchas this package already fixes for you

These cost real debugging time building the thing this package was extracted from — recorded here so you don't rediscover them:

Debugging a "no notification" report

  1. Have the reporter open the page with ?debug=1 once — the client JS persists this and starts sending diagnostic beacons.
  2. Reproduce, then grep your logs for FCM client event and FCM push.
  3. Read the trail in order: page:init (was permission ever granted?) → page:sw-registered → page:got-token → page:subscribed → (send from the other side) → FCM push sending / FCM push response (what did FCM's API actually say?) → sw:push-received (did the OS deliver it to the device at all?) → sw:notification-shown.
  4. Whichever step is missing tells you where it's actually breaking — almost always earlier in that chain than "FCM."

All versions of laravel-fcm-push with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
composer-plugin-api Version ^2.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/routing Version ^8.0|^9.0|^10.0|^11.0|^12.0|^13.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 npav/laravel-fcm-push contains the following files

Loading the files please wait ...