Coder Social home page Coder Social logo

tomrf / dotenv Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 151 KB

simple dotenv file loader using the PHP built-in parse_ini_file() to efficiently parse dotenv files

License: MIT License

PHP 100.00%
dotenv dotenv-parser environment-variables ini-parser ini-reader php php-dotenv

dotenv's Introduction

dotenv - simple dotenv file loader using the built-in parse_ini_file()

PHP Version Require Latest Stable Version License

Load environment variables from dotenv file using the PHP built-in parse_ini_file() function with scanner mode INI_SCANNER_TYPED (See PHP manual)

It is a simple, reliable and super fast way to load dotenv files without any bells nor whistles.

๐Ÿ“” Go to documentation

Installation

Installation via composer:

composer require tomrf/dotenv

Usage

$dotEnvLoader = new \Tomrf\DotEnv\DotEnvLoader();

// loadImmutable() will not overwrite existing environment variables
$dotEnvLoader->loadImmutable(__DIR__ . '/.env');

// load() will overwrite existing environment variables
$dotEnvLoader->load('/path/to/dotenv/file');

Testing

composer test

License

This project is released under the MIT License (MIT). See LICENSE for more information.

Documentation


๐Ÿ“‚ Tomrf\DotEnv\DotEnvLoader::class

Simple dotenv loader using parse_ini_file().

load()

Loads dotenv file into local environment, overwriting any environment variable already set.

public function load(
    string $filename
): void

@throws   \Tomrf\DotEnv\DotEnvLoaderException if parsing fails or if the file is not found

loadImmutable()

Loads dotenv file into local environment while preserving any existing environment variable.

public function loadImmutable(
    string $filename
): void

@throws   \Tomrf\DotEnv\DotEnvLoaderException if parsing fails or if the file is not found

Generated 2023-04-21T13:16:14+00:00 using ๐Ÿ“štomrf/readme-gen

dotenv's People

Contributors

tomrf avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.