PHPackages                             talmira/envelophp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. talmira/envelophp

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

talmira/envelophp
=================

Parse dotenv file for native php applications

v2.0.0(5y ago)119MITPHPPHP &gt;=5.6

Since Apr 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/theahmedlatif/envelophp)[ Packagist](https://packagist.org/packages/talmira/envelophp)[ RSS](/packages/talmira-envelophp/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (6)DependenciesVersions (8)Used By (0)

[![alt text](https://camo.githubusercontent.com/ed61a276a646af107cecfe23e83e3784351833d16bb637cb4a97e261ad3ae9f4/68747470733a2f2f616d3370617030303566696c65732e73746f726167652e6c6976652e636f6d2f79346d477271513178574552314b6564576c31515967696b2d6d5a39314938305f66647a566d554b683736594c4953535846496b5a5f653571374f794a4278557730363472366f44716a72506a6c2d58654734444a3946466d683875446f3745626d366675394d4e5348664c355934456745474c514142314a79453146354c32534e59737469443675783861484c345f6433695a634e47426876585a746f4a707655374d69475238475232746830544153306577706f61634359646f63594c426e76743f77696474683d353638266865696768743d3133382663726f706d6f64653d6e6f6e65 "Envelophp")](https://camo.githubusercontent.com/ed61a276a646af107cecfe23e83e3784351833d16bb637cb4a97e261ad3ae9f4/68747470733a2f2f616d3370617030303566696c65732e73746f726167652e6c6976652e636f6d2f79346d477271513178574552314b6564576c31515967696b2d6d5a39314938305f66647a566d554b683736594c4953535846496b5a5f653571374f794a4278557730363472366f44716a72506a6c2d58654734444a3946466d683875446f3745626d366675394d4e5348664c355934456745474c514142314a79453146354c32534e59737469443675783861484c345f6433695a634e47426876585a746f4a707655374d69475238475232746830544153306577706f61634359646f63594c426e76743f77696474683d353638266865696768743d3133382663726f706d6f64653d6e6f6e65)

---

[![License](https://camo.githubusercontent.com/79b6f6cbab9b314528cedced89e1119c57b60b23aee80e21835e78b06f3dddfb/68747470733a2f2f706f7365722e707567782e6f72672f74616c6d6972612f656e76656c6f7068702f6c6963656e7365)](//packagist.org/packages/talmira/envelophp)[![GitHub stars](https://camo.githubusercontent.com/350bcd909c30cdf4fe66760502066ce337dc5936df0b9a9affc4f8ce372caafa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f74686561686d65646c617469662f656e76656c6f706870)](https://github.com/theahmedlatif/envelophp/stargazers)[![GitHub forks](https://camo.githubusercontent.com/b657deec85161bcd0a02a6c6c52603bf876a5deac2dad67490ddf1bec526ff0d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f74686561686d65646c617469662f656e76656c6f706870)](https://github.com/theahmedlatif/envelophp/network)[![GitHub issues](https://camo.githubusercontent.com/4032154dcdda26a67642183d6ef37d024ca95fb8f7608cfb528d5dce3865a089/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f74686561686d65646c617469662f656e76656c6f706870)](https://github.com/theahmedlatif/envelophp/issues)

[![Latest Stable Version](https://camo.githubusercontent.com/449166a01b940681bde33fc8cb306c236ff076058c7afcb49d89a5549fc028ce/68747470733a2f2f706f7365722e707567782e6f72672f74616c6d6972612f656e76656c6f7068702f76)](//packagist.org/packages/talmira/envelophp)[![Latest Unstable Version](https://camo.githubusercontent.com/bc97787df7b513a0f0cd8ae6f447f38f790bf2ee1b5cbd844984969c425dcc45/68747470733a2f2f706f7365722e707567782e6f72672f74616c6d6972612f656e76656c6f7068702f762f756e737461626c65)](//packagist.org/packages/talmira/envelophp)[![Total Downloads](https://camo.githubusercontent.com/b067f4b8bce733cf4342b6746221521b3f183b8289670278f099d51b2c8430f8/68747470733a2f2f706f7365722e707567782e6f72672f74616c6d6972612f656e76656c6f7068702f646f776e6c6f616473)](//packagist.org/packages/talmira/envelophp)

[![GitHub code size in bytes](https://camo.githubusercontent.com/fe0f7a8204783129797198d40cd6cf923e1944dd93d11093a810b0271357207c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f74686561686d65646c617469662f656e76656c6f706870)](https://camo.githubusercontent.com/fe0f7a8204783129797198d40cd6cf923e1944dd93d11093a810b0271357207c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f74686561686d65646c617469662f656e76656c6f706870)[![License](https://camo.githubusercontent.com/f9afda3376b0f5bf195b22963750a8d64a42207d9e66742bf7aafbaf457a3e9e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737570706f72742d6d7973716c2d626c7565)](https://camo.githubusercontent.com/f9afda3376b0f5bf195b22963750a8d64a42207d9e66742bf7aafbaf457a3e9e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737570706f72742d6d7973716c2d626c7565)

What is envelophp?
==================

[](#what-is-envelophp)

*This package will help you to keep your database in one place and use them across your native php application.*

*envelophp use .env file to store database credentials and parse its content to be used in database connection.*

***Currently, envelophp supports mysql databases only.***

Installation
============

[](#installation)

Simple installation using [Composer](https://getcomposer.org/):

```
composer require talmira/envelophp
```

Setup
=====

[](#setup)

- #### Create .env file:

    [](#create-env-file)

Navigate to your project root folder then create .env file using one of the following methods:

1- Use curl to create .env file

```
  curl -LJ -o ".env" https://gist.github.com/theahmedlatif/3c5c7fd454f48898d7660bef555aca31/raw
```

2- Use wget to create .env file

```
   wget --output-document=.env --no-check-certificate --content-disposition https://gist.github.com/theahmedlatif/3c5c7fd454f48898d7660bef555aca31/raw
```

**YOU MUST ADD .env TO YOUR .gitignore FILE TO AVOID PUBLISHING YOUR CREDENTIALS TO THE PUBLIC**

- #### Modify .env file:

    [](#modify-env-file)

```
#Database#
HOST = "localhost"
DATABASE_DSN = "mysql"
DATABASE_NAME = "sample_db"
DATABASE_USERNAME = "sample_username"
DATABASE_PASSWORD = "sample_password"
```

Test
====

[](#test)

envelophp provides its own unit test cases:

- #### Fetch information from .env:

    [](#fetch-information-from-env)

this test case validate .env file location is the pointed location by Envelope Class and ability to read variables.

```
php vendor/talmira/envelophp/test/FetchDotEnv.php
```

- #### Test database connection:

    [](#test-database-connection)

this test case test database connection using .env variables.

```
php vendor/talmira/envelophp/test/MysqlDBTest.php
```

Usage
=====

[](#usage)

#### 1- Create Database

[](#1--create-database)

- So if you don't have a created Database you can use this secondary feature of envelophp, `createDatabase()` uses database\_name mentioned in .env file to create Mysql Database.

```
