php-standard-library/env
A lightweight PHP package from the Standard Library for inspecting and modifying environment variables, working directories, and filesystem paths, with simple, consistent functions that are easy to drop into any project.
Psl\Env\get_var(), set_var(), unset_var(), current_dir(), chdir(), plus path helpers) that replaces hand-rolled getenv()/$_ENV wrappers. The decision it informs: stop letting each team write its own escape hatch, adopt one.config() isn't available and getenv() sprawl accumulates..env files, cache config, validate schemas, or manage secrets. Do not let it be positioned as a replacement for config(), vlucas/phpdotenv, or a secrets manager — that framing will fail in review.Adopt if:
getenv()/$_ENV usage and want a mechanical, low-risk replacement with a stable namespace.phpdotenv for .env parsing.Look elsewhere if:
config() (cached, testable) plus framework env() covers this; adding a second access path creates two ways to do one thing."true", "1", "yes" to bool, required-vs-optional rules, nested schema. That's phpdotenv + symfony/validator or typed config objects. This package gives uniform access, not validation; casting stays your job.For executives: We have PHP code that runs outside the web request — queue workers, scheduled jobs, deploy scripts, and internal packages — where environment and path handling is inconsistent and quietly fragile. This is a small, MIT-licensed, zero-dependency helper that gives those places one predictable API. It's a modest scope: a few days of migration in one service, no licensing cost, no framework lock-in, and trivially reversible. It is not a config platform — I'm deliberately not selling it as one.
For engineering: This is a drop-in, namespaced replacement for scattered getenv(), chdir(), and manual path string-building — uniform across Laravel, Symfony, and plain PHP. It sits alongside config() and phpdotenv, not on top of them: keep config() for app configuration, use this in CLI, jobs, and shared packages. Two honest caveats: it does not validate or cast values ("false" still needs handling on your side), and the upstream project has minimal adoption signals, so we pin the version and treat the surface as small and replaceable. Pilot it in one worker or CLI tool, measure, then decide on wider rollout.
For developers: One import, no globals, no === 'true' guesswork about where the value came from. Env\get_var('KEY', 'default'), Env\current_dir(), and path helpers that behave the same on macOS, Linux, and in CI. Replaces the boilerplate you've copy-pasted into three repos. Keep your existing .env loading — this reads the environment, it doesn't populate it.
How can I help you explore Laravel packages today?