PHPackages                             daanra/laravel-lets-encrypt - 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. [Security](/categories/security)
4. /
5. daanra/laravel-lets-encrypt

ActiveLibrary[Security](/categories/security)

daanra/laravel-lets-encrypt
===========================

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

v0.5.7(4mo ago)22650.9k↓10.4%31[8 issues](https://github.com/Daanra/laravel-lets-encrypt/issues)MITPHPPHP ^7.2|^8.0CI passing

Since Oct 1Pushed 4mo ago5 watchersCompare

[ Source](https://github.com/Daanra/laravel-lets-encrypt)[ Packagist](https://packagist.org/packages/daanra/laravel-lets-encrypt)[ Docs](https://github.com/daanra/laravel-lets-encrypt)[ RSS](/packages/daanra-laravel-lets-encrypt/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (19)Used By (0)

Let's Encrypt Laravel
=====================

[](#lets-encrypt-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7ac758f652d84df2c128bae1e413964d896507bfce17771a0acfe04009dcc541/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461616e72612f6c61726176656c2d6c6574732d656e63727970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daanra/laravel-lets-encrypt)[![GitHub Tests Action Status](https://camo.githubusercontent.com/e8d8b4e6a04216e4ab2e7c0eb136cbd438618d4405305e3bc7f032c82de0161a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6461616e72612f6c61726176656c2d6c6574732d656e63727970742f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/daanra/laravel-lets-encrypt/actions?query=workflow%3Arun-tests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/a8ae2f457d8827177ead4f107c7ce84929e875420716e5a8e7fa32cd423f2aa4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461616e72612f6c61726176656c2d6c6574732d656e63727970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daanra/laravel-lets-encrypt)

A Laravel package for easily generating and renewing SSL certificates using Let's Encrypt. This package is especially useful if you have a Laravel application that manages the SSL certificates of many domains. This package is **not** recommended if you just need to generate a single SSL certificate for your application.

This package is essentially a Laravel-friendly wrapper around [Acme PHP](https://github.com/acmephp/acmephp).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require daanra/laravel-lets-encrypt
```

If you're having installation problems with conflicting dependencies caused by Guzzle then you might want to run:

```
composer require daanra/laravel-lets-encrypt guzzlehttp/guzzle:^6.0  -w
```

Publish the configuration file and the migration:

```
php artisan vendor:publish --provider="Daanra\LaravelLetsEncrypt\LetsEncryptServiceProvider" --tag="lets-encrypt"
```

Run the migration:

```
php artisan migrate
```

**Note:**

You somehow have to return a stored challenge whenever it it retrieved from the `/.well-known/acme-challenge` endpoint. You could do this by configuring NGINX/Apache appropriately or by registering a route:

```
Route::get('/.well-known/acme-challenge/{token}', function (string $token) {
    return \Illuminate\Support\Facades\Storage::get('public/.well-known/acme-challenge/' . $token);
})
```

Sometimes the `/.well-known/` prefix is disabled by default in the NGINX/Apache config (see [\#4](https://github.com/Daanra/laravel-lets-encrypt/issues/4)). Make sure it is forwarded to your Laravel application if you want Laravel to return the challenge.

Usage
-----

[](#usage)

Creating a new SSL certificate for a specific domain is easy:

```
// Puts several jobs on the queue to handle the communication with the lets-encrypt server
[$certificate, $pendingDispatch] = \Daanra\LaravelLetsEncrypt\Facades\LetsEncrypt::create('mydomain.com');

// You could, for example, chain some jobs to enable a new virtual host
// in Apache and send a notification once the website is available
[$certificate, $pendingDispatch] = \Daanra\LaravelLetsEncrypt\Facades\LetsEncrypt::create('mydomain.com', [
    new CreateNewApacheVirtualHost('mydomain.com'),
    new ReloadApache(),
    new NotifyUserOfNewCertificate(request()->user()),
]);

// You can also do it synchronously:
\Daanra\LaravelLetsEncrypt\Facades\LetsEncrypt::createNow('mydomain.com');
```

Alternative syntax available from v0.3.0:

```
LetsEncrypt::certificate('mydomain.com')
            ->chain([
                new SomeJob()
            ])
            ->delay(5)
            ->retryAfter(4)
            ->setTries(4)
            ->setRetryList([1, 5, 10])
            ->create(); // or ->renew()
```

Where you can specify values for all jobs:

- tries (The number of times the job may be attempted)
- retryAfter (The number of seconds to wait before retrying the job)
- retryList (The list of seconds to wait before retrying the job)
- chain (Chain some jobs after the certificate has successfully been obtained)
- delay (Set the desired delay for the job)

You could also achieve the same by using an artisan command:

```
php artisan lets-encrypt:create -d mydomain.com
```

Certificates are stored in the database. You can query them like so:

```
// All certificates
\Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate::all();
// All expired certificates
\Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate::query()->expired()->get();
// All currently valid certificates
\Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate::query()->valid()->get();
// All certificates that should be renewed (because they're more than 60 days old)
\Daanra\LaravelLetsEncrypt\Models\LetsEncryptCertificate::query()->requiresRenewal()->get();

// Find certificate by domain
$certificate = LetsEncryptCertificate::where('domain', 'mydomain.com')->first();
// If you no longer need it, you can soft delete
$certificate->delete();
// Or use a hard delete
$certificate->forceDelete();
```

Subject Alternative Names
-------------------------

[](#subject-alternative-names)

It's also possible to specify Subject Alternative Names as below (requires &gt;= 0.5.0):

```
LetsEncrypt::certificate('mydomain.com')
        ->setSubjectAlternativeNames(['mydomain2.com'])
        ->create();
```

Failure events
--------------

[](#failure-events)

If one of the jobs fails, one of the following events will be dispatched:

```
Daanra\LaravelLetsEncrypt\Events\CleanUpChallengeFailed
Daanra\LaravelLetsEncrypt\Events\ChallengeAuthorizationFailed
Daanra\LaravelLetsEncrypt\Events\RegisterAccountFailed
Daanra\LaravelLetsEncrypt\Events\RequestAuthorizationFailed
Daanra\LaravelLetsEncrypt\Events\RequestCertificateFailed
Daanra\LaravelLetsEncrypt\Events\StoreCertificateFailed
Daanra\LaravelLetsEncrypt\Events\RenewExpiringCertificatesFailed
```

Every event implements the `Daanra\LaravelLetsEncrypt\Interfaces\LetsEncryptCertificateFailed` interface so you can listen for that as well.

Automatically renewing certificates
-----------------------------------

[](#automatically-renewing-certificates)

Certificates are valid for 90 days. Before those 90 days are over, you will want to renew them. To do so, you could add the following to your `App\Console\Kernel`:

```
protected function schedule(Schedule $schedule)
{
    $schedule->job(new \Daanra\LaravelLetsEncrypt\Jobs\RenewExpiringCertificates)->daily();
}
```

This will automatically renew every certificate that is older than 60 days, ensuring that they never expire.

Configuration
-------------

[](#configuration)

By default this package will use Let's Encrypt's staging server to issue certificates. You should set:

```
LETS_ENCRYPT_API_URL=https://acme-v02.api.letsencrypt.org/directory
```

in the `.env` file of your production server.

By default, this package will attempt to validate a certificate using [a HTTP-01 challenge](https://letsencrypt.org/docs/challenge-types/). For this reason, a file will be temporarily stored in your application's storage directory under the path `app/public/.well-known/acme-challenge/`. You can customise this behavior by setting a custom `PathGenerator` class in your config under `path_generator`. Note that Let's Encrypt expects the following path:

```
/.well-known/acme-challenge/
```

to return the contents of the file located at `$pathGenerator->getPath($token)`.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker. If you have a question, please open an issue instead of sending an email.

Credits
-------

[](#credits)

- [Daan Raatjes](https://github.com/Daanra)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance76

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.4% 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 ~137 days

Recently: every ~159 days

Total

15

Last Release

125d ago

PHP version history (2 changes)v0.1PHP ^7.2

v0.2.1PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7329241f78d1dc1731c0c669a93c7084a1423474a7c1526a660c46c844e6ff98?d=identicon)[daanraatjes](/maintainers/daanraatjes)

---

Top Contributors

[![Daanra](https://avatars.githubusercontent.com/u/6588838?v=4)](https://github.com/Daanra "Daanra (99 commits)")[![arkaitzgarro](https://avatars.githubusercontent.com/u/1712467?v=4)](https://github.com/arkaitzgarro "arkaitzgarro (2 commits)")[![Muffinman](https://avatars.githubusercontent.com/u/1319568?v=4)](https://github.com/Muffinman "Muffinman (2 commits)")[![condor-bird](https://avatars.githubusercontent.com/u/14821572?v=4)](https://github.com/condor-bird "condor-bird (1 commits)")[![countless-integers](https://avatars.githubusercontent.com/u/2060726?v=4)](https://github.com/countless-integers "countless-integers (1 commits)")[![oriondevelops](https://avatars.githubusercontent.com/u/39307250?v=4)](https://github.com/oriondevelops "oriondevelops (1 commits)")

---

Tags

laravelletsencryptssl-certificatelaravelencryptcertificatesslletsdaanra

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/daanra-laravel-lets-encrypt/health.svg)

```
[![Health](https://phpackages.com/badges/daanra-laravel-lets-encrypt/health.svg)](https://phpackages.com/packages/daanra-laravel-lets-encrypt)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[laravel/ui

Laravel UI utilities and presets.

2.7k134.9M601](/packages/laravel-ui)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)

PHPackages © 2026

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