PHPackages                             anikeen/yaac - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. anikeen/yaac

ActivePackage[HTTP &amp; Networking](/categories/http)

anikeen/yaac
============

Yet Another ACME client: a decoupled LetsEncrypt client

1.0.1(11mo ago)0413Apache-2.0PHP

Since Dec 21Pushed 11mo agoCompare

[ Source](https://github.com/anikeen-com/yaac)[ Packagist](https://packagist.org/packages/anikeen/yaac)[ Docs](https://anikeen.com)[ RSS](/packages/anikeen-yaac/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

yaac - Yet another ACME client
==============================

[](#yaac---yet-another-acme-client)

Note

This package is a fork of afosto/yaac

Written in PHP, this client aims to be a simplified and decoupled Let’s Encrypt client, based on [ACME V2](https://tools.ietf.org/html/rfc8555).

Decoupled from a filesystem or webserver
----------------------------------------

[](#decoupled-from-a-filesystem-or-webserver)

Instead of, for example writing the certificate to the disk under an nginx configuration, this client just returns the data (the certificate and private key).

Why
---

[](#why)

Why would I need this package? At Afosto we run our software in a multi-tenant setup, as any other SaaS would do, and therefore we cannot make use of the many clients that are already out there.

Almost all clients are coupled to a type of webserver or a fixed (set of) domain(s). This package can be extremely useful in case you need to dynamically fetch and install certificates.

Requirements
------------

[](#requirements)

- PHP7+
- openssl
- [Flysystem](http://flysystem.thephpleague.com/) (any adapter would do) - to store the Lets Encrypt account information

Getting started
---------------

[](#getting-started)

Getting started is easy. First install the client, then you need to construct a flysystem filesystem, instantiate the client and you can start requesting certificates.

### Installation

[](#installation)

Installing this package is done easily with composer.

```
composer require anikeen/yaac
```

### Instantiate the client

[](#instantiate-the-client)

To start the client you need 3 things; a username for your Let’s Encrypt account, a bootstrapped Flysystem and you need to decide whether you want to issue `Fake LE Intermediate X1` (staging: `MODE_STAGING`) or `Let's Encrypt Authority X3`(live: `MODE_LIVE`, use for production) certificates.

```
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
use Afosto\Acme\Client;

//Prepare flysystem
$adapter = new Local('data');
$filesystem = new Filesystem($adapter);

//Construct the client
$client = new Client([
    'username' => 'example@example.org',
    'fs'       => $filesystem,
    'mode'     => Client::MODE_STAGING,
]);
```

While you instantiate the client, when needed a new Let’s Encrypt account is created and then agrees to the TOS.

### Create an order

[](#create-an-order)

To start retrieving certificates, we need to create an order first. This is done as follows:

```
$order = $client->createOrder(['example.org', 'www.example.org']);
```

In the example above the primary domain is followed by a secondary domain(s). Make sure that for each domain you are able to prove ownership. As a result the certificate will be valid for all provided domains.

### Prove ownership

[](#prove-ownership)

Before you can obtain a certificate for a given domain you need to prove that you own the given domain(s). We request the authorizations to prove ownership. Obtain the authorizations for order. For each domain supplied in the create order request an authorization is returned.

```
$authorizations = $client->authorize($order);
```

You now have an array of `Authorization` objects. These have the challenges you can use (both `DNS` and `HTTP`) to provide proof of ownership.

#### HTTP validation

[](#http-validation)

HTTP validation (where serve specific content at a specific url on the domain, like: `example.org/.well-known/acme-challenge/*`) is done as follows:

Use the following example to get the HTTP validation going. First obtain the challenges, the next step is to make the challenges accessible from

```
foreach ($authorizations as $authorization) {
    $file = $authorization->getFile();
    file_put_contents($file->getFilename(), $file->getContents());
}
```

> If you need a wildcard certificate, you will need to use DNS validation, see below

#### DNS validation

[](#dns-validation)

You can also use DNS validation - to do this, you will need access to an API of your DNS provider to create TXT records for the target domains.

```
foreach ($authorizations as $authorization) {
    $txtRecord = $authorization->getTxtRecord();

    //To get the name of the TXT record call:
    $txtRecord->getName();

    //To get the value of the TXT record call:
    $txtRecord->getValue();
}
```

### Self test

[](#self-test)

After exposing the challenges (made accessible through HTTP or DNS) we should perform a self test just to be sure it works before asking Let's Encrypt to validate ownership.

For a HTTP challenge test call:

```
if (!$client->selfTest($authorization, Client::VALIDATION_HTTP)) {
    throw new \Exception('Could not verify ownership via HTTP');
}
```

For a DNS test call:

```
if (!$client->selfTest($authorization, Client::VALIDATION_DNS)) {
    throw new \Exception('Could not verify ownership via DNS');
}
sleep(30); // this further sleep is recommended, depending on your DNS provider, see below
```

With DNS validation, after the `selfTest` has confirmed that DNS has been updated, it is recommended you wait some additional time before proceeding, e.g. `sleep(30);`. This is because Let’s Encrypt will perform [multiple viewpoint validation](https://community.letsencrypt.org/t/acme-v1-v2-validating-challenges-from-multiple-network-vantage-points/112253), and your DNS provider may not have completed propagating the changes across their network.

If you proceed too soon, [Let's Encrypt will fail to validate](https://community.letsencrypt.org/t/during-secondary-validation-incorrect-txt-record/113643).

### Request validation

[](#request-validation)

Next step is to request validation of ownership. For each authorization (domain) we ask Let’s Encrypt to verify the challenge.

For HTTP validation:

```
foreach ($authorizations as $authorization) {
    $client->validate($authorization->getHttpChallenge(), 15);
}
```

For DNS validation:

```
foreach ($authorizations as $authorization) {
    $client->validate($authorization->getDnsChallenge(), 15);
}
```

The code above will first perform a self test and, if successful, will do 15 attempts to ask Let’s Encrypt to validate the challenge (with 1 second intervals) and retrieve an updated status (it might take Let’s Encrypt a few seconds to validate the challenge).

### Get the certificate

[](#get-the-certificate)

Now to know if we can request a certificate for the order, test if the order is ready as follows:

```
if ($client->isReady($order)) {
    //The validation was successful.
}
```

We now know validation was completed and can obtain the certificate. This is done as follows:

```
$certificate = $client->getCertificate($order);
```

We now have the certificate, to store it on the filesystem:

```
//Store the certificate and private key where you need it
file_put_contents('certificate.cert', $certificate->getCertificate());
file_put_contents('private.key', $certificate->getPrivateKey());
```

> To get a seperate intermediate certificate and domain certificate:
>
> ```
> $domainCertificate = $certificate->getCertificate(false);
> $intermediateCertificate = $certificate->getIntermediate();
> ```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance52

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 51.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~177 days

Total

2

Last Release

331d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/03da561a330aa76d1a09096b2ee0c48ee53ca51d62fa0239469d9615b6855733?d=identicon)[ghostzero](/maintainers/ghostzero)

![](https://www.gravatar.com/avatar/64a10ad37cbd186601e725d894b9f35bdb9ec47782d9751a36e639d4ae795174?d=identicon)[envoyr](/maintainers/envoyr)

---

Top Contributors

[![bakkerpeter](https://avatars.githubusercontent.com/u/23257320?v=4)](https://github.com/bakkerpeter "bakkerpeter (31 commits)")[![lordelph](https://avatars.githubusercontent.com/u/444004?v=4)](https://github.com/lordelph "lordelph (4 commits)")[![envoyr](https://avatars.githubusercontent.com/u/81368729?v=4)](https://github.com/envoyr "envoyr (4 commits)")[![gpibarra](https://avatars.githubusercontent.com/u/21188012?v=4)](https://github.com/gpibarra "gpibarra (2 commits)")[![mikemunger](https://avatars.githubusercontent.com/u/654364?v=4)](https://github.com/mikemunger "mikemunger (2 commits)")[![mgilfillan](https://avatars.githubusercontent.com/u/25685838?v=4)](https://github.com/mgilfillan "mgilfillan (2 commits)")[![bessone](https://avatars.githubusercontent.com/u/1089510?v=4)](https://github.com/bessone "bessone (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![tipswithpunch](https://avatars.githubusercontent.com/u/47672855?v=4)](https://github.com/tipswithpunch "tipswithpunch (1 commits)")[![xolf](https://avatars.githubusercontent.com/u/8250052?v=4)](https://github.com/xolf "xolf (1 commits)")[![adrorocker](https://avatars.githubusercontent.com/u/1872940?v=4)](https://github.com/adrorocker "adrorocker (1 commits)")[![zagrad](https://avatars.githubusercontent.com/u/1423264?v=4)](https://github.com/zagrad "zagrad (1 commits)")[![aitrex-global](https://avatars.githubusercontent.com/u/129726402?v=4)](https://github.com/aitrex-global "aitrex-global (1 commits)")[![AlexNodex](https://avatars.githubusercontent.com/u/17162626?v=4)](https://github.com/AlexNodex "AlexNodex (1 commits)")[![Manawyrm](https://avatars.githubusercontent.com/u/748791?v=4)](https://github.com/Manawyrm "Manawyrm (1 commits)")[![redelschaap](https://avatars.githubusercontent.com/u/6915990?v=4)](https://github.com/redelschaap "redelschaap (1 commits)")[![smitpipaliya](https://avatars.githubusercontent.com/u/42377816?v=4)](https://github.com/smitpipaliya "smitpipaliya (1 commits)")[![spekulatius](https://avatars.githubusercontent.com/u/8433587?v=4)](https://github.com/spekulatius "spekulatius (1 commits)")[![TheDevilOnLine](https://avatars.githubusercontent.com/u/2675104?v=4)](https://github.com/TheDevilOnLine "TheDevilOnLine (1 commits)")

---

Tags

letsencryptphpencryptv2letsencryptafostoACMEletsacmev2anikeen

### Embed Badge

![Health badge](/badges/anikeen-yaac/health.svg)

```
[![Health](https://phpackages.com/badges/anikeen-yaac/health.svg)](https://phpackages.com/packages/anikeen-yaac)
```

###  Alternatives

[afosto/yaac

Yet Another ACME client: a decoupled LetsEncrypt client

245500.4k1](/packages/afosto-yaac)[acmephp/acmephp

Let's Encrypt client written in PHP

649155.1k](/packages/acmephp-acmephp)[daanra/laravel-lets-encrypt

A Laravel package to easily generate SSL certificates using Let's Encrypt

22650.9k](/packages/daanra-laravel-lets-encrypt)[basecrm/basecrm-php

BaseCRM Official API V2 library client for PHP

221.0M](/packages/basecrm-basecrm-php)[romanpitak/dotmailer-api-v2-client

Client library for the dotMailer v2 (REST) API.

21101.0k2](/packages/romanpitak-dotmailer-api-v2-client)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
