[ All integrations ](https://ohdear.app/third-party-integrations)

# PHP SDK

An easy-to-use PHP package to communicate with the Oh Dear API from your own applications.

[ ohdearapp/ohdear-php-sdk ](https://github.com/ohdearapp/ohdear-php-sdk)

by [ Oh Dear ](https://ohdear.app)

We've created an easy-to-use [open source PHP package](https://github.com/ohdearapp/ohdear-php-sdk) that allows you to communicate with the Oh Dear API. It provides convenient models and methods to quickly get started.

## Installation [\#](#installation)

Grab the latest stable version via composer:

```
<span class="hl-keyword">composer</span> require ohdearapp/ohdear-php-sdk
```

## Getting Started [\#](#getting-started)

Create an instance of the SDK with your API key:

```
<span class="hl-variable">$apiKey</span> = <span class="hl-value">"iK4YfZe2i1RAe22tKP4xejGKDZP...."</span>;
<span class="hl-variable">$ohDear</span> = <span class="hl-keyword">new</span> <span class="hl-type">OhDear\PhpSdk\OhDear</span>(<span class="hl-variable">$apiKey</span>);
```

If you don't have an API key yet, [read up on the API authentication](https://ohdear.app/docs/api/introduction) first.

## Quick Examples [\#](#quick-examples)

### Get all monitors [\#](#get-all-monitors)

```
<span class="hl-variable">$monitors</span> = <span class="hl-variable">$ohDear</span>-><span class="hl-property">sites</span>();
```

### Add a new monitor [\#](#add-a-new-monitor)

```
<span class="hl-variable">$ohDear</span>-><span class="hl-property">createSite</span>([
   <span class="hl-value">'url'</span> => <span class="hl-value">'https://yourbrandnewsite.tld'</span>,
   <span class="hl-value">'team_id'</span> => <span class="hl-variable">$yourTeamId</span>
]);
```

### Get uptime data [\#](#get-uptime-data)

```
<span class="hl-variable">$ohDear</span>-><span class="hl-property">site</span>(<span class="hl-variable">$monitorId</span>)-><span class="hl-property">uptime</span>(<span class="hl-variable">$start</span>, <span class="hl-variable">$end</span>, <span class="hl-variable">$split</span>);
```

### Manage maintenance periods [\#](#manage-maintenance-periods)

```
<span class="hl-comment">// Start maintenance for 10 minutes</span>
<span class="hl-variable">$ohDear</span>-><span class="hl-property">site</span>(<span class="hl-variable">$monitorId</span>)-><span class="hl-property">startMaintenance</span>(600);

<span class="hl-comment">// Stop maintenance</span>
<span class="hl-variable">$ohDear</span>-><span class="hl-property">site</span>(<span class="hl-variable">$monitorId</span>)-><span class="hl-property">stopMaintenance</span>();
```

## Full Documentation [\#](#full-documentation)

For complete documentation covering all available methods including checks, broken links, certificate health, status pages, cron job monitoring, and more, visit the [full SDK documentation](https://ohdear.app/docs/tools-and-sdks/the-oh-dear-php-sdk).
