Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 30, 2024 via composer

vlucas/phpdotenv v5.5.0

Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
Package summary
Share
0
issues
3
licenses
4
MIT
1
Apache-2.0
1
BSD-3-Clause
Package created
23 Jan 2013
Version published
16 Oct 2022
Maintainers
1
Total deps
6
Direct deps
5
License
BSD-3-Clause

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
4 Packages, Including:
graham-campbell/result-type@v1.1.2
symfony/polyfill-ctype@v1.29.0
symfony/polyfill-mbstring@v1.29.0
symfony/polyfill-php80@v1.29.0

Apache License 2.0

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
use-patent-claims
place-warranty
Cannot
hold-liable
use-trademark
Must
include-copyright
include-license
state-changes
include-notice
1 Packages, Including:
phpoption/phpoption@1.9.2

BSD 3-Clause "New" or "Revised" License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
place-warranty
Cannot
use-trademark
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
vlucas/phpdotenv@v5.5.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

5
All Dependencies CSV
β“˜ This is a list of vlucas/phpdotenv 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
graham-campbell/result-typev1.1.23.98 kBMIT
prod
phpoption/phpoption1.9.2-Apache-2.0
prod
symfony/polyfill-ctypev1.29.0-MIT
prod
symfony/polyfill-mbstringv1.29.0-MIT
prod
symfony/polyfill-php80v1.29.0-MIT
prod

Visualizations

Frequently Asked Questions

What does vlucas/phpdotenv do?

The vlucas/phpdotenv is a PHP package that helps developers manage environmental variables for their applications. This package automagically loads environment variables from a .env file in your project to getenv(), $_ENV and $_SERVER. This ensures that sensitive credentials, like database passwords or API keys, are never stored directly in your code, providing an enhanced level of security.

How do you use vlucas/phpdotenv?

Using the vlucas/phpdotenv in your PHP project is straightforward. The first step is to install it via Composer using the command composer require vlucas/phpdotenv. After the installation, you create a .env file in the root of your project and add your application's configuration parameters, making sure the .env file is added to your .gitignore so it's not checked-in the code.

You can load the variables in your PHP application as follows:

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

This code will load the .env file from your project root directory. If you want to suppress the exception thrown for a missing .env file, you can use safeLoad():

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();

You can access the loaded variables via the $_ENV and $_SERVER super-globals:

$s3_bucket = $_ENV['S3_BUCKET'];
$s3_bucket = $_SERVER['S3_BUCKET'];

Where are the vlucas/phpdotenv docs?

The documentation for the vlucas/phpdotenv package is not provided separately, but comprehensive usage instructions are available directly in the readme file on the package's GitHub page. It provides details on installation, upgrading, creating and loading the environment variables, as well as more advanced usage examples including setting immutability, nesting variables, requiring variables to be set, and customizing repositories.