Download the PHP package spizian/laravel-env-set without Composer
On this page you can find all versions of the php package spizian/laravel-env-set. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spizian/laravel-env-set
More information about spizian/laravel-env-set
Files in spizian/laravel-env-set
Package laravel-env-set
Short Description A .env editor for Laravel
License MIT
Homepage https://spizian.github.io/laravel-env-set/
Informations about the package laravel-env-set
Laravel .env editor
Installation
Usage
Working with facade
Laravel Set Env has a facade with the name spizian\EnvSet\Facades\EnvSet
. You can perform all operations through this facade.
Example:
Using dependency injection
This package also supports dependency injection. You can easily inject an instance of the spizian\EnvSet
class into your controller or other classes.
Example:
Reading file content
Reading raw content.
Method syntax:
Example:
Reading content by lines.
Method syntax:
Example:
Note: This will return an array. Each element in the array consists of the following items:
- Number of the line.
- Raw content of the line.
- Parsed content of the line, including: type of line (empty, comment, setter...), key name of setter, value of setter, comment of setter...
Reading content by keys
Method syntax:
Example:
Note: This will return an array. Each element in the array consists of the following items:
- Number of the line.
- Key name of the setter.
- Value of the setter.
- Comment of the setter.
- If this key is used for the "export" command or not.
Determine if a key exists
Method syntax:
Example:
Get value of a key
Method syntax:
Example:
Note: To apply the changes to the file, you have to save it with the save method.
Writing content into a file
To edit file content, you have two jobs:
- First is writing content into the buffer
- Second is saving the buffer into the file
Add an empty line into buffer
Method syntax:
Example:
Add a comment line into buffer
Method syntax:
Example:
Add or update a setter into buffer
Method syntax:
Example:
Add or update multi setter into buffer
Method syntax:
Example:
Alternatively, you can also provide an associative array of keys and values:
Delete a setter line in buffer
Method syntax:
Example:
Delete multi setter lines in buffer
Method syntax:
Example:
Save buffer into file
Method syntax:
Example:
$file = EnvSet::save();