# errorgap for PHP (Symfony / Slim / plain)

See [index.md](./index.md) for API details and the placeholder values (`ERRORGAP_API_KEY`, `ERRORGAP_ENDPOINT`, `ERRORGAP_PROJECT_SLUG`).

SDK source: `github.com/errorgaphq/errorgap-php` · current version: `0.3.0`. For **Laravel**, use [`errorgap/laravel`](./laravel.md). For **WordPress**, use [`errorgap-wordpress`](./wordpress.md).

## Install

```sh
composer require errorgap/errorgap
```

Requires PHP 8.1+.

## Configure

In your bootstrap (Symfony `src/Kernel.php`, Slim `public/index.php`, or plain front controller):

```php
use Errorgap\Errorgap;

Errorgap::init([
    'endpoint'    => $_ENV['ERRORGAP_ENDPOINT'],
    'projectSlug' => $_ENV['ERRORGAP_PROJECT_SLUG'],
    'apiKey'      => $_ENV['ERRORGAP_API_KEY'],
]);
```

By default, `init` installs `set_exception_handler` + `set_error_handler` to catch otherwise-unreported errors.

## Trigger a test error

Add a temporary route:

```php
$app->get('/errorgap-test', function () {
    throw new \Exception('Errorgap test error');
});
```

## Verify

Run the verification curl from [index.md](./index.md), then hit `/errorgap-test` and confirm the onboarding screen advances.
