---
title: "Extending — Certificates for Laravel | Roundly"
description: "Plug in your own certificate provider with Certificates::extend(), persist material through CertificateStore and add macros to the manager."
url: https://roundly-consulting.com/open-source/docs/certificates-for-laravel/extending
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Certificates for Laravel](https://roundly-consulting.com/open-source/docs/certificates-for-laravel.md)

# Extending

The provider contract is public. Implement CertificateProvider — plus ProvisionsMultipleDomains and ReportsCertificateStatus when your backend can handle SANs and live status:

```php
use Illuminate\Support\Collection;
use RoundlyConsulting\Certificates\Contracts\CertificateProvider;
use RoundlyConsulting\Certificates\Contracts\ProvisionsMultipleDomains;
use RoundlyConsulting\Certificates\Contracts\ReportsCertificateStatus;
use RoundlyConsulting\Certificates\DataTransferObjects\CertificateStatusReport;

final class VaultCertificateProvider implements CertificateProvider, ProvisionsMultipleDomains, ReportsCertificateStatus
{
    public function get(): Collection { /* Collection<int, RemoteCertificate> */ }

    public function exists(string $name, string $domain): bool { /* ... */ }

    public function generate(string $name, string $domain): void { /* provision one domain */ }

    public function generateMany(string $name, array $domains): void { /* one SAN certificate */ }

    public function status(string $name, string $domain): CertificateStatusReport { /* live status + expiry */ }
}
```

Register it through the facade — for example from a service provider’s boot(). Certificates::extend() adds the driver to CertificateProviderManager, the driver manager behind Certificates::driver(); then select it as the default driver or per call:

```php
use RoundlyConsulting\Certificates\Contracts\CertificateProvider;
use RoundlyConsulting\Certificates\Facades\Certificates;

Certificates::extend('vault', fn (): CertificateProvider => new VaultCertificateProvider());

// CERTIFICATES_DRIVER=vault, or per call:
Certificates::for('app.example.com')->using('vault')->issue();
```

get() returns RemoteCertificate value objects (name, domain). status() is the proof of issuance: a report that is failed, expired or revoked fails the issue or renewal, and on issue a still-pending one leaves the row requested. Report the expiry so the registry can populate expires\_at — without it the registry falls back to validForDays — and the fingerprint, which tells a real renewal from an unchanged certificate. Without a fingerprint, a renewal counts only when the reported expiry moves later.

## Certificate stores

CertificateStore persists PEM material — leaf, key and chain — as a StoredCertificate. The package ships FilesystemCertificateStore; implement the contract inside your own provider to keep material elsewhere:

```php
namespace RoundlyConsulting\Certificates\Contracts;

interface CertificateStore
{
    public function put(string $name, StoredCertificate $material): void;
    public function get(string $name): ?StoredCertificate;
    public function exists(string $name): bool;
    public function delete(string $name): void;
    public function names(): array; // list<string>
}
```

The container binds CertificateStore to a FilesystemCertificateStore on drivers.acme.store. The shipped acme and filesystem drivers build their own store from their config keys, so rebinding the contract does not redirect them.

## Macros

CertificatesManager and CertificateBuilder are macroable — bolt on your own domain methods, for example from AppServiceProvider::boot(). A manager macro is callable on the facade:

```php
use RoundlyConsulting\Certificates\CertificatesManager;

CertificatesManager::macro('issueForTeam', function (Team $team, string $domain) {
    /** @var CertificatesManager $this */
    return $this->for($domain)->owner($team)->issue();
});

Certificates::issueForTeam($team, 'app.example.com');
```

To override a use case instead, bind your own action in the container — the manager resolves every action on each call (see DI and actions).

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/certificates-for-laravel.md)
