docs: add license
This commit is contained in:
61
README.md
61
README.md
@@ -1,45 +1,48 @@
|
||||
**Edit a file, create a new file, and clone from Bitbucket in under 2 minutes**
|
||||
# Gbili DotEnv
|
||||
|
||||
When you're done, you can delete the content in this README and update the file with details for others getting started with your repository.
|
||||
A simple PHP package to load environment variables from a `.env` file. Comments within the `.env` file, starting with a `#`, are supported.
|
||||
|
||||
*We recommend that you open this README in another tab as you perform the tasks below. You can [watch our video](https://youtu.be/0ocf7u76WSo) for a full demo of all the steps in this tutorial. Open the video in a new tab to avoid leaving Bitbucket.*
|
||||
## Installation
|
||||
|
||||
---
|
||||
You can include this class in your project by copying the file, or use Composer if it's part of a package.
|
||||
|
||||
## Edit a file
|
||||
## Usage
|
||||
|
||||
You’ll start by editing this README file to learn how to edit a file in Bitbucket.
|
||||
### Loading Environment Variables
|
||||
|
||||
1. Click **Source** on the left side.
|
||||
2. Click the README.md link from the list of files.
|
||||
3. Click the **Edit** button.
|
||||
4. Delete the following text: *Delete this line to make a change to the README from Bitbucket.*
|
||||
5. After making your change, click **Commit** and then **Commit** again in the dialog. The commit page will open and you’ll see the change you just made.
|
||||
6. Go back to the **Source** page.
|
||||
To load environment variables from a `.env` file located in the root directory of your project, use the `load` method:
|
||||
|
||||
---
|
||||
```php
|
||||
use Gbili\DotEnv;
|
||||
|
||||
## Create a file
|
||||
DotEnv::load(__DIR__);
|
||||
```
|
||||
|
||||
Next, you’ll add a new file to this repository.
|
||||
The `.env` file should contain one environment variable per line, in the format `VAR_NAME=value`. Comments can be included, starting with a `#`.
|
||||
|
||||
1. Click the **New file** button at the top of the **Source** page.
|
||||
2. Give the file a filename of **contributors.txt**.
|
||||
3. Enter your name in the empty file space.
|
||||
4. Click **Commit** and then **Commit** again in the dialog.
|
||||
5. Go back to the **Source** page.
|
||||
### Accessing Environment Variables
|
||||
|
||||
Before you move on, go ahead and explore the repository. You've already seen the **Source** page, but check out the **Commits**, **Branches**, and **Settings** pages.
|
||||
Once loaded, environment variables can be accessed using the `$_ENV` global variable:
|
||||
|
||||
---
|
||||
```php
|
||||
echo $_ENV['VAR_NAME']; // Outputs the value
|
||||
```
|
||||
|
||||
## Clone a repository
|
||||
### Handling Quotes
|
||||
|
||||
Use these steps to clone from SourceTree, our client for using the repository command-line free. Cloning allows you to work on your files locally. If you don't yet have SourceTree, [download and install first](https://www.sourcetreeapp.com/). If you prefer to clone from the command line, see [Clone a repository](https://confluence.atlassian.com/x/4whODQ).
|
||||
The `removeOuterQuotes` method in the class handles both single and double quotes around the values, allowing for flexibility in how you define your variables.
|
||||
|
||||
1. You’ll see the clone button under the **Source** heading. Click that button.
|
||||
2. Now click **Check out in SourceTree**. You may need to create a SourceTree account or log in.
|
||||
3. When you see the **Clone New** dialog in SourceTree, update the destination path and name if you’d like to and then click **Clone**.
|
||||
4. Open the directory you just created to see your repository’s files.
|
||||
## Methods
|
||||
|
||||
Now that you're more familiar with your Bitbucket repository, go ahead and add a new file locally. You can [push your change back to Bitbucket with SourceTree](https://confluence.atlassian.com/x/iqyBMg), or you can [add, commit,](https://confluence.atlassian.com/x/8QhODQ) and [push from the command line](https://confluence.atlassian.com/x/NQ0zDQ).
|
||||
- `loadFromFile($filepath)`: Loads environment variables from a given file path.
|
||||
- `removeOuterQuotes(string $string, $quote = "'")`: Removes outer quotes from a given string.
|
||||
- `MUTATE_ENV_addEnvVars(array $variables)`: Merges the given variables into the `$_ENV` superglobal.
|
||||
- `load(string $rootDir)`: Loads environment variables from a `.env` file in the given root directory.
|
||||
|
||||
## Contributing
|
||||
|
||||
Feel free to submit issues or pull requests if you find any problems or have suggestions for improvements.
|
||||
|
||||
## License
|
||||
|
||||
[MIT License](./LICENSE)
|
||||
Reference in New Issue
Block a user