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
$maintenanceWindows = $ohDear->maintenancePeriods(1);
This will return an array of
You can get a few properties of a maintenance window.
$window->id; $window->siteId; $window->startsAt; $window->endsAt;
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
$ohDear->startSiteMaintenance( 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:
$ohDear->createSiteMaintenance( 1, // Site ID '2020-05-19 13:00:00', // Start date '2020-05-19 13:02:00' // End date )
createSiteMaintenance() method allows a
$endDate to be specified.
Stopping any ongoing maintenance #
If you used the
startSiteMaintenance() shorthand for creating a new maintenance window, you can also use the
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 $ohDear->stopSiteMaintenance(1);
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