{"id":37014689,"url":"https://github.com/pushpad/pushpad-php","last_synced_at":"2026-01-14T01:28:12.206Z","repository":{"id":50530054,"uuid":"51579743","full_name":"pushpad/pushpad-php","owner":"pushpad","description":"PHP library for sending push notifications from websites and web apps.","archived":false,"fork":false,"pushed_at":"2025-10-07T11:27:30.000Z","size":96,"stargazers_count":25,"open_issues_count":1,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T11:35:17.745Z","etag":null,"topics":["notifications","web-push"],"latest_commit_sha":null,"homepage":"https://pushpad.xyz","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pushpad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-02-12T10:06:57.000Z","updated_at":"2025-10-07T11:23:24.000Z","dependencies_parsed_at":"2024-01-22T15:27:24.510Z","dependency_job_id":"861780a3-64ef-4f92-afd4-601a0c860101","html_url":"https://github.com/pushpad/pushpad-php","commit_stats":{"total_commits":45,"total_committers":1,"mean_commits":45.0,"dds":0.0,"last_synced_commit":"87f9c6bef7d0bdd9850bf87f64103446ce5350a3"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/pushpad/pushpad-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpad%2Fpushpad-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpad%2Fpushpad-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpad%2Fpushpad-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpad%2Fpushpad-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pushpad","download_url":"https://codeload.github.com/pushpad/pushpad-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpad%2Fpushpad-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notifications","web-push"],"created_at":"2026-01-14T01:28:11.667Z","updated_at":"2026-01-14T01:28:12.191Z","avatar_url":"https://github.com/pushpad.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pushpad - Web Push Notifications\n\n![Build Status](https://github.com/pushpad/pushpad-php/workflows/CI/badge.svg)\n[![Latest Stable Version](https://poser.pugx.org/pushpad/pushpad-php/v)](//packagist.org/packages/pushpad/pushpad-php)\n[![Total Downloads](https://poser.pugx.org/pushpad/pushpad-php/downloads)](//packagist.org/packages/pushpad/pushpad-php)\n[![License](https://poser.pugx.org/pushpad/pushpad-php/license)](//packagist.org/packages/pushpad/pushpad-php)\n\n[Pushpad](https://pushpad.xyz) is a service for sending push notifications from websites and web apps. It uses the **Push API**, which is supported by all major browsers (Chrome, Firefox, Opera, Edge, Safari).\n\nNotifications are delivered in real time even when the users are not on your website and you can target specific users or send bulk notifications.\n\n## Installation\n\n### Composer\n\nThis package requires PHP 8.0+ with the `curl` extension.\n\nInstall the SDK via [Composer](https://getcomposer.org/):\n\n```bash\ncomposer require pushpad/pushpad-php\n```\n\nThen include Composer's autoloader:\n\n```php\nrequire_once __DIR__ . '/vendor/autoload.php';\n```\n\n### Manual installation\n\nClone the repository and require the bootstrap file in your project:\n\n```bash\ngit clone https://github.com/pushpad/pushpad-php.git\n```\n\n```php\nrequire_once __DIR__ . '/path/to/pushpad-php/init.php';\n```\n\n## Getting started\n\nFirst sign up to Pushpad and create a project.\n\nConfigure the SDK with your credentials before you make any API calls:\n\n```php\nPushpad\\Pushpad::$authToken = '5374d7dfeffa2eb49965624ba7596a09';\nPushpad\\Pushpad::$projectId = 123; // set a default project (optional)\n```\n\n- `authToken` can be created in the account settings.\n- `projectId` is shown in the project settings. If you work with multiple projects you can pass a different project id to individual method calls instead of configuring the global default.\n\n## Collecting user subscriptions\n\nUse the JavaScript SDK to subscribe users to push notifications (see the [getting started guide](https://pushpad.xyz/docs/pushpad_pro_getting_started)).\n\nWhen you need to sign a `uid`, generate the HMAC signature with:\n\n```php\n$signature = Pushpad\\Pushpad::signatureFor((string) $currentUserId);\n```\n\n## Sending push notifications\n\nUse `Pushpad\\Notification::create()` (or the `send()` alias) to create and send a notification:\n\n```php\n$response = Pushpad\\Notification::create([\n    // required content\n    'body' =\u003e 'Hello world!',\n\n    // optional fields\n    'title' =\u003e 'Website Name',\n    'target_url' =\u003e 'https://example.com',\n    'icon_url' =\u003e 'https://example.com/assets/icon.png',\n    'badge_url' =\u003e 'https://example.com/assets/badge.png',\n    'image_url' =\u003e 'https://example.com/assets/image.png',\n    'ttl' =\u003e 604800,\n    'require_interaction' =\u003e true,\n    'silent' =\u003e false,\n    'urgent' =\u003e false,\n    'custom_data' =\u003e '123',\n    'actions' =\u003e [\n        [\n            'title' =\u003e 'My Button 1',\n            'target_url' =\u003e 'https://example.com/button-link',\n            'icon' =\u003e 'https://example.com/assets/button-icon.png',\n            'action' =\u003e 'myActionName',\n        ],\n    ],\n    'starred' =\u003e true,\n    'send_at' =\u003e (new DateTimeImmutable('+1 hour'))-\u003eformat(DATE_ATOM),\n    'custom_metrics' =\u003e ['examples', 'another_metric'],\n\n    // targeting options\n    'uids' =\u003e ['user-1', 'user-2'],\n    'tags' =\u003e ['segment1', 'segment2'],\n]);\n```\n\n- Omit `uids` and `tags` to broadcast to everyone.\n- If you set `uids` and some users are not subscribed to notifications, Pushpad ignores them.\n- Use boolean expressions inside `tags` for complex segments (e.g. `'zip_code:28865 \u0026\u0026 !optout:local_events'`).\n- Scheduled notifications require an ISO 8601 timestamp in `send_at` (as produced by `DateTimeInterface::format(DATE_ATOM)`).\n- You can set default values for most notification fields in the project settings.\n- Refer to the [REST API docs](https://pushpad.xyz/docs/rest_api#notifications_api_docs) for more details about the notification fields and their usage.\n\nThe response includes useful information:\n\n```php\n// Notification ID\n$notificationId = $response['id'];\n\n// Estimated number of devices that will receive the notification\n// Not available for notifications that use send_at\n$estimatedReach = $response['scheduled'];\n\n// Available only if you specify some user IDs (uids) in the request:\n// it indicates which of those users are subscribed to notifications.\n// Not available for notifications that use send_at\n$reachedUids = $response['uids'];\n\n// The time when the notification will be sent.\n// Available for notifications that use send_at\n$scheduledAt = $response['send_at'];\n```\n\n## Getting push notification data\n\nFetch a single notification and inspect its attributes:\n\n```php\n$notification = Pushpad\\Notification::find(42);\n\necho $notification-\u003etitle; // \"Foo Bar\"\necho $notification-\u003etarget_url; // \"https://example.com\"\necho $notification-\u003ettl; // 604800\necho $notification-\u003ecreated_at; // ISO 8601 string\necho $notification-\u003esuccessfully_sent_count; // 4\necho $notification-\u003eopened_count; // 2\n\n// ... and many other attributes\nprint_r($notification-\u003etoArray());\n```\n\nList notifications for a project (pagination supported through the `page` query parameter):\n\n```php\n$notifications = Pushpad\\Notification::findAll(['page' =\u003e 1]);\n\nforeach ($notifications as $item) {\n    printf(\"Notification %d: %s\\n\", $item-\u003eid, $item-\u003etitle);\n}\n```\n\nPass the project id as the second argument when you prefer not to rely on the globally configured `Pushpad\\Pushpad::$projectId`:\n\n```\nPushpad\\Notification::findAll([], projectId: 456);\n```\n\nIf you need to refresh a previously loaded notification, call `$notification-\u003erefresh()` to hydrate the latest data from the API.\n\n## Scheduled notifications\n\nCreate a notification that will be sent later:\n\n```php\nPushpad\\Notification::create([\n    'body' =\u003e 'This notification will be sent after 60 seconds',\n    'send_at' =\u003e (new DateTimeImmutable('+60 seconds'))-\u003eformat(DATE_ATOM),\n]);\n```\n\nCancel a scheduled notification when it is still pending:\n\n```php\n$notification = Pushpad\\Notification::find(5);\n$notification-\u003ecancel();\n```\n\n## Getting subscription count\n\nRetrieve the number of subscriptions associated with a project, optionally filtered by user IDs or tags:\n\n```php\n$total = Pushpad\\Subscription::count();\n$byUser = Pushpad\\Subscription::count(['uids' =\u003e ['user1']]);\n$byTags = Pushpad\\Subscription::count(['tags' =\u003e ['sports \u0026\u0026 travel']]);\n$combined = Pushpad\\Subscription::count(['uids' =\u003e ['user1'], 'tags' =\u003e ['sports \u0026\u0026 travel']], 5);\n```\n\nThe second argument lets you override the project id if you did not configure `Pushpad\\Pushpad::$projectId` or you need to switch project on the fly.\n\n## Getting push subscription data\n\nFetch subscriptions with optional filters and pagination:\n\n```php\n$subscriptions = Pushpad\\Subscription::findAll(['tags' =\u003e ['sports'], 'page' =\u003e 2]);\n\nforeach ($subscriptions as $subscription) {\n    echo $subscription-\u003eid . PHP_EOL;\n    // ...\n}\n```\n\nLoad a specific subscription when you already know its id:\n\n```php\n$subscription = Pushpad\\Subscription::find(123);\n\necho $subscription-\u003eid;\necho $subscription-\u003eproject_id;\necho $subscription-\u003eendpoint;\necho $subscription-\u003euid;\necho $subscription-\u003etags;\necho $subscription-\u003elast_click_at;\necho $subscription-\u003ecreated_at;\n\n// ... and many other attributes\nprint_r($subscription-\u003etoArray());\n```\n\n## Updating push subscription data\n\nAlthough tags and user IDs are usually managed from the JavaScript SDK, you can also update them from server:\n\n```php\n$subscriptions = Pushpad\\Subscription::findAll(['uids' =\u003e ['user1']]);\n\nforeach ($subscriptions as $subscription) {\n    $tags = $subscription-\u003etags ?? [];\n    $tags[] = 'another_tag';\n\n    $subscription-\u003eupdate([\n        'uid' =\u003e 'myuser1',\n        'tags' =\u003e array_values(array_unique($tags)),\n    ]);\n}\n```\n\n## Importing push subscriptions\n\nTo import existing subscriptions or seed test data use `Pushpad\\Subscription::create()`:\n\n```php\n$subscription = Pushpad\\Subscription::create([\n    'endpoint' =\u003e 'https://example.com/push/f7Q1Eyf7EyfAb1',\n    'p256dh' =\u003e 'BCQVDTlYWdl05lal3lG5SKr3VxTrEWpZErbkxWrzknHrIKFwihDoZpc_2sH6Sh08h-CacUYI-H8gW4jH-uMYZQ4=',\n    'auth' =\u003e 'cdKMlhgVeSPzCXZ3V7FtgQ==',\n    'uid' =\u003e 'exampleUid',\n    'tags' =\u003e ['exampleTag1', 'exampleTag2'],\n]);\n```\n\nTypically subscriptions are collected from the browser using the [JavaScript SDK](https://pushpad.xyz/docs/javascript_sdk_reference); server-side creation should be reserved for migrations and special workflows.\n\n## Deleting push subscriptions\n\nDelete subscriptions programmatically (use with care, the operation is irreversible):\n\n```php\n$subscription = Pushpad\\Subscription::find(123);\n$subscription-\u003edelete();\n```\n\n## Managing projects\n\nProjects can also be managed via the API for automation use cases:\n\n```php\n$project = Pushpad\\Project::create([\n    'sender_id' =\u003e 123,\n    'name' =\u003e 'My project',\n    'website' =\u003e 'https://example.com',\n    'icon_url' =\u003e 'https://example.com/icon.png',\n    'badge_url' =\u003e 'https://example.com/badge.png',\n    'notifications_ttl' =\u003e 604800,\n    'notifications_require_interaction' =\u003e false,\n    'notifications_silent' =\u003e false,\n]);\n\n$projects = Pushpad\\Project::findAll();\n\n$project = Pushpad\\Project::find(123);\n$project-\u003eupdate(['name' =\u003e 'The New Project Name']);\n$project-\u003edelete();\n```\n\n## Managing senders\n\nSenders hold the VAPID credentials used for Web Push:\n\n```php\n$sender = Pushpad\\Sender::create([\n    'name' =\u003e 'My sender',\n    // omit the keys below to let Pushpad generate them automatically\n    // 'vapid_private_key' =\u003e '-----BEGIN EC PRIVATE KEY----- ...',\n    // 'vapid_public_key' =\u003e '-----BEGIN PUBLIC KEY----- ...',\n]);\n\n$senders = Pushpad\\Sender::findAll();\n\n$sender = Pushpad\\Sender::find(987);\n$sender-\u003eupdate(['name' =\u003e 'The New Sender Name']);\n$sender-\u003edelete();\n```\n\n## License\n\nThe library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpushpad%2Fpushpad-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpushpad%2Fpushpad-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpushpad%2Fpushpad-php/lists"}