The Web Push API "magic" happens within a JavaScript service worker running in the user's browser, so it doesn't really matter which tech you are using in your web server. The important part is that you host a correctly coded service worker along with a properly setup manifest file.

My advice would be to download the Web Push example from https://github.com/realtime-framework/WebPushNotifications, follow the setup steps in the README file and host the files in your PHP server.

Don't forget that if you are using your own domain (instead of localhost) you'll need a valid SSL certificate for the domain you are using.

What about publishing the push?

If you wish to send the push notifications from your PHP server use the following code sample:

<?php
 
$curl = curl_init();
 
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://ortc-mobilepush.realtime.co/mp/publish",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => array(
    "content-type: application/json"
  ),
  CURLOPT_POSTFIELDS => '{
      "applicationKey": "YOUR_REALTIME_APPKEY",
      "privateKey": "YOUR_REALTIME_PRIVATEKEY",
      "channel" : "NewArticles",
      "message" : "We have new articles for you"
  }'
));
 
$response = curl_exec($curl);
$err = curl_error($curl);
 
curl_close($curl);
 
if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
Did this answer your question?