Languages
Envlet for PHP
Client->inject() fills putenv and $_ENV. Laravel, Symfony, and plain PHP read them the way they always did.
Inject
use Envlet\Client;
$envlet = new Client();
$envlet->inject();
$stripe = new StripeClient(getenv("STRIPE_KEY"));Load
use Envlet\Client;
$envlet = new Client();
$values = $envlet->load();
$pdo = new PDO($values["DATABASE_URL"]);Get
use Envlet\Client;
$envlet = new Client();
$stripeKey = $envlet->get("STRIPE_KEY");Install
composer require envlet/envletSet up
- 01
Install
composer require envlet/envlet.
- 02
Set one secret
ENVLET_TOKEN in the environment of PHP-FPM, the container, or the CLI.
- 03
Inject at boot
Create a Client and call inject() in your front controller before config loads.
Questions
- Will my app start if Envlet is down?
- No, and that is the point. The SDK retries for a few seconds, then fails so you notice. It never starts your app with half an environment.
- What does the host need?
- One variable, ENVLET_TOKEN. Everything else arrives at boot.
- Can I still set some values on the PHP host?
- Yes. A value the host already set wins. Pass override if you want Envlet to win instead.