pirabyte / erecht24-laravel
Laravel integration for the eRecht24 Rechtstexte SDK.
Requires
- php: ^8.2
- erecht24/rechtstexte-sdk: ^1.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- symfony/html-sanitizer: ^6.4|^7.0|^8.0
Requires (Dev)
- laravel/pint: ^1.29
- mockery/mockery: ^1.6
- orchestra/testbench: ^8.37|^9.17|^10.11|^11.1
- pestphp/pest: ^2.36|^3.8|^4.7
- pestphp/pest-plugin-laravel: ^2.4|^3.2|^4.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-06 14:52:16 UTC
README
Laravel integration for the erecht24/rechtstexte-sdk package.
This package is a thin service layer around the official SDK. It fetches supported legal texts and returns DTOs so your application can decide how to render, cache, store, or publish them.
Installation
composer require pirabyte/erecht24-laravel
Publish the configuration file:
php artisan vendor:publish --tag=erecht24-config
Configuration
Set the required API key:
ERECHT24_API_KEY=
Optional configuration:
ERECHT24_LANGUAGE=de ERECHT24_CACHE_ENABLED=true ERECHT24_CACHE_TTL=3600
The registered pirabyte developer key is included in the package. You only supply your private project API key, which must stay in server configuration. ERECHT24_CACHE_STORE and ERECHT24_CACHE_PREFIX are also available in the published config.
Usage
Use the service directly:
use Pirabyte\ERecht24Laravel\ERecht24; use Pirabyte\ERecht24Laravel\Enums\LegalTextType; $data = app(ERecht24::class)->document(LegalTextType::PrivacyPolicy, 'de'); echo $data->html;
Or use the facade:
use Pirabyte\ERecht24Laravel\Facades\ERecht24; $html = ERecht24::privacyPolicy()->html;
Available service methods:
$erecht24->imprint(); $erecht24->privacyPolicy(); $erecht24->privacyPolicySocialMedia(); $erecht24->document(LegalTextType::Imprint); $erecht24->html(LegalTextType::PrivacyPolicy); $erecht24->htmlOrLastKnownGood(LegalTextType::PrivacyPolicy, 'en'); $erecht24->isConfigured(); $erecht24->clearCache();
Supported Documents
Only document types supported by erecht24/rechtstexte-sdk are exposed:
imprintprivacy_policyprivacy_policy_social_media
Terms of Service documents are not supported by this package because the SDK does not expose them.
Caching
Successful responses are cached when erecht24.cache.enabled is true. Cache keys use this format:
erecht24:<project-key-sha256>:privacy_policy:de
Cache entries are isolated by project API key. Changing the key fetches fresh documents. Existing entries expire after their configured TTL.
Use clearCache() to forget all supported document cache keys for the configured project, or pass a LegalTextType to clear a single document type.
htmlOrLastKnownGood() returns sanitized, nonempty HTML in the exact requested language. Headings, paragraphs, emphasis, lists and HTTP, HTTPS, mail and telephone links are preserved. Scripts, styles, media, unsafe links and event handlers are removed before validation or retention. Retained HTML is sanitized again before use. Input larger than 1 MiB is rejected without truncating the legal text. It never substitutes German for a missing English document.
When caching is enabled, it retains the last valid HTML without a TTL and serves it if the API fails or the requested language is unavailable. clearCache() removes these retained documents too. Disabling caching skips retention and fallback.
A configured project API key is required, including when serving retained HTML. Removing or changing the key never serves documents retained under the previous key. Existing application-specific fallback entries are not imported. html() and document() continue to return raw API HTML. Without valid current or retained HTML, the method throws ERecht24Exception so the application can show its unavailable page.
Disclaimer
This is an independent third-party project maintained by pirabyte. It is not an official eRecht24 product and is not developed, maintained, or endorsed by eRecht24. eRecht24 is a trademark of its respective owner.
This package is technical integration software and is not legal advice. Users are responsible for validating their legal texts and their eRecht24 account/API setup.
License
This wrapper package is open-sourced software licensed under the MIT license.
It depends on erecht24/rechtstexte-sdk, which has its own license and terms.