Manage maintenance windows with the PHP SDK

This page will get you started managing your sites with the PHP SDK. Make sure you've read the getting started guide first. Once that's done, you should have our package & authentication ready to go.

Retrieve all maintenance windows

The simplest example is one where we list the maintenance windows for a particular website. Here, we'll get the maintenance periods for a site with ID 1.

$maintenanceWindows = $ohDear->maintenancePeriods(1);

This will return an array of OhDear\PhpSdk\Resources\MaintenancePeriod instances.

You can get a few properties of a maintenance window.


Add a maintenance period through the SDK

We have a convenient method for adding a maintenance window now to any site. This can be useful in deploy-scripts, to create a maintenance period that lasts for X amount of minutes.

This can be done using the startSiteMaintenance() method.

   1,       // Site ID
   120      // Amount of seconds

This creates a new maintenance period for site ID 1 that lasts for 120 seconds, or 2 minutes. It's a shorthand for this, longer version, of the maintenance period creation:

    1,                   // Site ID
    '2020-05-19 13:00',  // Start date
    '2020-05-19 13:02'   // End date

The createSiteMaintenance() method allows a $startDate and $endDate to be specified. You can pass the date as any string, it will be formatted by the SDK into the correct format.

Stopping any ongoing maintenance

If you used the startSiteMaintenance() shorthand for creating a new maintenance window, you can also use the stopSiteMaintenance() method.


This will stop any currently ongoing maintenance window.

The ideal use case is in deployment scripts, where you can call the following methods:

// Create a 10-minute maintenance period
$ohDear->startSiteMaintenance(1, 600);

// Your deployment code here
// ...

// Stop the maintenance period

This will create a perfectly timed, on-demand maintenance window.

Deleting a particular maintenance window

If you have the maintenance period ID, you can also delete it.


The above will delete maintenance period with ID 1.

Was this page helpful to you? Feel free to reach out via or on Twitter via @OhDearApp if you have any other questions. We'd love to help!