Download the PHP package ez-php/push without Composer

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

ez-php/push

Mobile push notifications for ez-php applications. Delivers a PushMessage to a device token through a pluggable driver — APNS (Apple, HTTP/2 provider API with token-based .p8 authentication) or FCM (Firebase Cloud Messaging, HTTP v1 API with service-account OAuth2), or Web Push (browsers, VAPID + RFC 8291 encryption) — plus Null and Array drivers for local development and testing.

Device-token storage, invalid-token pruning, and topic/channel subscription management are application-layer concerns — this package only delivers a message to a token you already have.


Installation

Requires ez-php/http-client to be registered first — the apns and fcm drivers resolve HttpClient from the container.


Quick Start

Register the providers in provider/modules.php:

Add configuration to config/push.php:

Send a push notification from anywhere:

Or fan out to many tokens without one failure blocking the rest:


Drivers

Driver PUSH_DRIVER Description
Null null Silently discards all notifications (default)
Array array Stores notifications in memory — designed for testing
APNS apns Apple Push Notification service, HTTP/2 provider API
FCM fcm Firebase Cloud Messaging, HTTP v1 API
Web Push webpush Browser push (VAPID), encrypted per RFC 8291

APNS Driver

PUSH_APNS_PRIVATE_KEY is the PEM contents of the .p8 authentication key downloaded from the Apple Developer portal. The driver signs an ES256 provider JWT from it and reuses that JWT across requests for up to 50 minutes, per Apple's guidance. Set PUSH_APNS_SANDBOX=true to target the sandbox APNS host during development.

FCM Driver

PUSH_FCM_CLIENT_EMAIL and PUSH_FCM_PRIVATE_KEY come from a Firebase service-account JSON key (Project Settings → Service Accounts → Generate new private key). The driver exchanges an RS256-signed JWT-bearer assertion for an OAuth2 access token and caches it for its ~1-hour lifetime.

Web Push Driver

PUSH_WEBPUSH_PRIVATE_KEY is your VAPID key: a P-256 EC private key in PEM form (openssl ecparam -genkey -name prime256v1 -noout). Give the browser the matching public key when subscribing — WebPushDriver::vapidPublicKey($pem) returns it in the base64url form pushManager.subscribe({applicationServerKey}) expects.

The "device token" is the browser's PushSubscription as JSON — store JSON.stringify(subscription) and pass it to Push::send():

The service worker receives {"title", "body", "data", "badge"?, "sound"?}. Payloads are encrypted per RFC 8291 (max 4079 bytes). A 404/410 from the push service means the subscription is gone — a PushException is raised; dropping the subscription is up to you.

Array Driver (for Testing)


Static Facade

Push is a static facade backed by a Pusher singleton:

Method Description
Push::send(string $token, PushMessage $message) Deliver to one device token
Push::sendToMany(list<string> $tokens, PushMessage $message) Deliver to many tokens, returning a token => PushException\|null map
Push::setPusher(Pusher) Wire the singleton (done by PushServiceProvider)
Push::resetPusher() Reset to null — call in test tearDown()

Throws RuntimeException if called before setPusher().


Custom Driver

Implement PushDriverInterface to add a custom backend:

Bind it in a service provider:


Exceptions

PushException (extends RuntimeException) is the base exception for this package — thrown on an invalid signing key or a non-2xx response from APNS/FCM. Push::send() / Push::sendToMany() throw plain RuntimeException if called before the pusher is set.


License

MIT


All versions of push with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ext-openssl Version *
ez-php/contracts Version ^2.7.0
ez-php/http-client Version ^2.7.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 ez-php/push contains the following files

Loading the files please wait ...