1. Go to this page and download the library: Download daanra/laravel-lets-encrypt library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
daanra / laravel-lets-encrypt example snippets
Route::get('/.well-known/acme-challenge/{token}', function (string $token) {
return \Illuminate\Support\Facades\Storage::get('public/.well-known/acme-challenge/' . $token);
})
// 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');
LetsEncrypt::certificate('mydomain.com')
->chain([
new SomeJob()
])
->delay(5)
->retryAfter(4)
->setTries(4)
->setRetryList([1, 5, 10])
->create(); // or ->renew()
// 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()->