---
description: https://github.com/Minishlink/web-push-php-example
---

# Web Push example in PHP (ok)

{% file src="https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MCBeDUD-PK_RF-YgJRe%2F-MDrSCr5nGP_EIL5Po_-%2F-MDrSSQ6PBksj0wsXXd9%2Fweb-push-php-example.rar?alt=media&token=a19b55f8-9195-4fa8-9dd6-34a23f72f58a" %}

![](https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MCBeDUD-PK_RF-YgJRe%2F-MDrSrcDaJ-R1AaTp6Wk%2F-MDrT9dPYZUmcWiQNPU1%2FScreenshot_1.png?alt=media\&token=6821d11e-a0af-40dd-acae-87c00ae59d5c)

## Web Push example in PHP

Navigating through the commits and files will help you build:

* on the client
  * a user friendly opt-in push notification button
* on the server
  * an endpoint for managing your push notification subscriptions
  * an endpoint that triggers push notification thanks to [web-push-php](https://github.com/web-push-libs/web-push-php)

### Requirements

* Chrome or Firefox
* [composer](https://getcomposer.org/)
* PHP 7.2+
  * gmp
  * mbstring
  * curl
  * openssl

PHP 7.1 is no longer maintained, but you can checkout the `v2.x` branch. PHP 5.6+ is no longer maintained, but you can checkout the `v1.x` branch.

### Installation

```
$ composer create-project minishlink/web-push-php-example
$ cd web-push-php-example
```

You can change the VAPID keys in the [keys](https://github.com/Minishlink/web-push-php-example/blob/master/keys) folder with [this guide](https://github.com/web-push-libs/web-push-php#authentication-vapid). Don't forget to update the public key in [app.js](https://github.com/Minishlink/web-push-php-example/blob/master/src/app.js) too.

### Usage

```
$ php -S localhost:8000 router.php
```

And open [localhost:8000](http://localhost:8000/).
