Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Environment

Environment Laravel Package

sebastian/environment

Detects runtime details of the PHP environment, including version, operating system, and whether running under HHVM, so your code can branch into runtime-specific execution paths.

View on GitHub
Deep Wiki
Context7

Provides functionality to handle HHVM/PHP environments

Frequently asked questions about Environment
How do I install sebastian/environment in a Laravel project?
Install it with Composer using composer require sebastian/environment for production use, or composer require --dev sebastian/environment if you only need it for tests and CI scripts. It is a framework-agnostic library, so no Laravel service provider registration is required. You can use its Runtime class directly or bind it in Laravel's container if you prefer dependency injection.
Does sebastian/environment support Laravel 10 and Laravel 11?
sebastian/environment is not a Laravel package, so it does not publish a Laravel version compatibility matrix. It works in Laravel 10 and Laravel 11 as long as Composer can install a package release that supports your PHP version. Check Packagist for the release that matches your PHP constraint, since Laravel 10 and 11 already require modern PHP versions.
What is the difference between sebastian/environment and Laravel's app()->environment()?
Laravel's app()->environment() tells you the application environment name, such as local, testing, or production. sebastian/environment focuses on low-level runtime details like PHP version, operating system, HHVM detection, and OPcache status. Use Laravel's helper for app environment branching and sebastian/environment when you need to branch on the actual PHP runtime.
How can I check the PHP version at runtime in Laravel with sebastian/environment?
Resolve or instantiate SebastianBergmann\Environment\Runtime and call getVersion() to get the current PHP version string. You can then compare it with version_compare() or PHP_VERSION_ID for feature gating. For cleaner Laravel code, wrap this check in a small helper, facade, or service instead of scattering version_compare calls across your codebase.
Can sebastian/environment detect HHVM and help deprecate HHVM support?
Yes, the Runtime class provides isHHVM() and isPHP() methods so your code can take runtime-specific paths. In a Laravel app you can log deprecation notices, skip HHVM-specific tests, or fail CI builds when HHVM is detected. This is useful when you are removing legacy HHVM support while still needing a clear migration period.
How do I bind sebastian/environment's Runtime class in Laravel's service container?
Register a singleton in a service provider, for example binding SebastianBergmann\Environment\Runtime to a new Runtime instance. Then type-hint Runtime in constructors or resolve it with app(Runtime::class). This keeps runtime checks testable and avoids creating new instances throughout your application.
Should sebastian/environment be a production dependency or a dev dependency in Laravel?
Use it as a normal production dependency if your application code branches on PHP version, OS, HHVM, or OPcache at runtime. Use require-dev if you only need it for test suite gating, CI validation scripts, or local development tooling. Many Laravel projects only need it as a dev dependency because Laravel itself handles most high-level environment concerns.
How can I use sebastian/environment in Laravel tests to skip unsupported runtimes?
Resolve Runtime in your test and call methods like isHHVM(), isPHP(), or getVersion() before running runtime-specific assertions. If the current runtime is unsupported, call markTestSkipped() with a clear message instead of letting the test fail unpredictably. This keeps PHP-only and HHVM-related tests isolated across local machines and CI runners.
What is the performance impact of runtime checks with sebastian/environment?
Most checks are lightweight boolean or string reads, so normal PHP version, OS, and HHVM checks add negligible overhead. Avoid calling heavier methods such as getSettings() repeatedly in hot paths or tight loops. For typical Laravel feature gates and CI scripts, the cost is effectively insignificant compared with application work.
How can I enforce PHP version or runtime checks in Laravel CI/CD pipelines?
Create an Artisan command or standalone PHP script that resolves Runtime, checks getVersion(), isHHVM(), or other runtime details, and exits with a non-zero status when requirements are not met. Run that command early in CI before tests or deployment steps so builds fail fast on unsupported runtimes. You can also use the same checks to emit warnings, such as deprecation notices for HHVM, instead of hard failures.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource