# Weitere Checks programmieren

### Datenbank Beispiel

Zuerst musst du eine PHP-Klasse in deinem Plugin schreiben, der die Logik beinhaltet. Wichtig ist, dass das Interface `HealthCheckInterface` implementiert wird.

```php
<?php declare(strict_types=1);

namespace ShopStudio\HealthCheck\Core\HealthCheck;

use Doctrine\DBAL\Connection;

class DatabaseHealthCheck implements HealthCheckInterface
{
    public const NAME = 'database';

    private Connection $connection;

    public function __construct(Connection $connection)
    {
        $this->connection = $connection;
    }

    public function getName(): string
    {
        return self::NAME;
    }

    public function check(): ?HealthCheckResult
    {
        $up = true;

        try {
            $this->connection->executeQuery($this->connection->getDatabasePlatform()->getDummySelectSQL());
        } catch (\Throwable $throwable) {
            $up = false;
        }

        return new HealthCheckResult($up, ['additional' => 'payload']);
    }
}

```

Anschließend noch die PHP-Klasse als Service in der services.xml implementieren. Vergesse nicht den Service als `shop-studio.health-check` zu taggen.

```xml
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
    <services>

        <service id="ShopStudio\HealthCheck\Core\HealthCheck\DatabaseHealthCheck">
            <argument type="service" id="Doctrine\DBAL\Connection" />
            <tag name="shop-studio.health-check"/>
        </service>

    </services>
</container>

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shop-studio.io/shopware/de/erweiterungen/health-check/weitere-checks-programmieren.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
