Docs Ping PingArk from plain PHP

Ping PingArk from plain PHP

From plain PHP, a ping is a single call that opens the ping URL. This suits a standalone script or any framework. If you run Laravel, the PingArk plugin wires this into your scheduler for you.

Before you start

You need a check and its ping URL. Create one in the dashboard, then copy the ping URL from the check page. New to PingArk? Start with the getting started guide.

Ping on success

Call the ping URL after your job finishes its work. A plain ping means success and re-arms the check for its next run.

<?php

file_get_contents("https://ping.pingark.com/ping/3f9c2a1b-7d4e-4c8a-9f1b-2e6d8a0c4b5e");
Copy

Report failures, starts and duration

Add a suffix to the ping URL to say more than a plain success. Call these the same way you called the success URL above. The ping API has the full reference.

https://ping.pingark.com/ping/3f9c2a1b-7d4e-4c8a-9f1b-2e6d8a0c4b5e        # success: the job finished, re-arms the timer
https://ping.pingark.com/ping/3f9c2a1b-7d4e-4c8a-9f1b-2e6d8a0c4b5e/start  # the run started, lets PingArk measure duration
https://ping.pingark.com/ping/3f9c2a1b-7d4e-4c8a-9f1b-2e6d8a0c4b5e/fail   # an explicit failure, alerts right away
https://ping.pingark.com/ping/3f9c2a1b-7d4e-4c8a-9f1b-2e6d8a0c4b5e/log    # a timeline note, never alerts
https://ping.pingark.com/ping/3f9c2a1b-7d4e-4c8a-9f1b-2e6d8a0c4b5e/$?     # a shell exit code: 0 is success, anything else fails
Copy

The example uses file_get_contents for brevity. In production, prefer a short curl call with a timeout so a slow request cannot hold up your script.

To report a failure, request the /fail URL from your catch block. To measure duration, request /start first, then the success URL at the end.

Using Laravel? Skip the manual curl and let the plugin ping every scheduled task for you, capturing run duration and exception details. See the Laravel plugin guide.

Troubleshooting

  • If allow_url_fopen is disabled on your host, file_get_contents cannot open a URL. Use curl through the ext-curl extension instead.
  • Wrap the ping in a try and catch, or suppress its errors, so a network issue never interrupts your script.