Download the PHP package mirazmac/dotenvwriter without Composer

On this page you can find all versions of the php package mirazmac/dotenvwriter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dotenvwriter

DotEnvWriter

A PHP library to write values to .env (DotEnv) files

Installation

DotEnvWriter can be installed with Composer.

Usage

API

Methods

__construct(?string $sourceFile = null)

Constructs a new instance.

Arguments

string|null $sourceFile The environment file path to load values from, optional.

set(string $key, string $value, bool $forceQuote = false) : self

Set the value of an environment variable, updated if exists, added if doesn't. The values must be passed as string, even if you are setting values like TRUE FALSE. This method is chainable.

Arguments

string $key The key

string $value The value

bool $forceQuote By default the whether the value is wrapped in double quotes is determined automatically. However, you may wish to force quote a value.

delete(string $key) : self

Delete an environment variable if present. This method is chainable.

Arguments

string $key The key

hasChanged() : bool

States if one or more values has changed

getContent() : string

Returns the current content

write(bool $force = false, ?string $destFile = null) : bool

Write the contents to the .env file.

Arguments

bool $force By default we only write when something has changed, but you can force to write the file by setting this to TRUE.

string|null $destFile Destionation file. By default it's the same as $sourceFile is provided

F.A.Q

What can this do?

DotEnvWriter is a PHP library that can write (add, update, delete) values to .env files.

And how is this done?

Well.. I'm glad you asked.. it uses some bleeding edge AI algorithm.. just kidding, RegEx.. it uses RegEx to replace the values with proper quoting and escaping and writes them back to the filesystem. While RegEx is not the best solution but it gets the job done.

What if this corrupts my .env file?

Well, it shouldn't. It uses proper quoting and escaping before writing the values. If you want to make sure it generates a valid file, well, that's why tests are for. You can clone the repo and run composer install and then phpunit to run the tests. The goal of this library is to generate a .env file that can be parsed without any errors using: vlucas/phpdotenv

How does it handle invalid .env files?

It doesn't. You see, it doesn't concern itself with validation of existing values. It simply replaces them via RegEx, and makes sure the changes that it has made is valid. But if you have an existing invalid file, it can do nothing to validate or fix that.

Can I use this to read values from an .env file?

Yes, you can. But you really shouldn't. Thus they aren't documented. This library is for writing to the file. To properly read and load values from .env files, use something robust like: vlucas/phpdotenv .

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

The library is inspired by and uses some RegEx from the msztorc/laravel-env package and is based on the same MIT license.


All versions of dotenvwriter with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mirazmac/dotenvwriter contains the following files

Loading the files please wait ....