Download the PHP package allysonsilva/laravel-multienv without Composer

On this page you can find all versions of the php package allysonsilva/laravel-multienv. 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 laravel-multienv

Laravel Multi ENVs

PHP Version Laravel Version CI Status PHPCS - GitHub Workflow Status PHPMD - GitHub Workflow Status PHPStan - GitHub Workflow Status Coverage Status Latest Version

Use multiple .envs files and have a chain of precedence for the environment variables in these different .envs files. Use the .env file in a custom way to manipulate environment variables by domain (multi-tenant).

๐Ÿš€ Installation

Requirements

The package has been developed and tested to work with the following minimum requirements:

Laravel version Compatibility

Laravel PHP Package
9.x 8.0 ^2.0
8.x 7.4 ^1.0

Install the Package

You can install the package via Composer:

Publish the Config

You can then publish the package's config file by using the following command:

๐Ÿ”ง Configuration

  1. Add trait to kernel console app/Console/Kernel.php:

  2. Add trait to kernel http app/Http/Kernel.php:

๐Ÿ“– Usage

The use of this package happens by manipulating the .envs files in the project.

Using multiple .env files in the project root

See it in action

Assuming we have 3 .env files in the root of the application with their environment variables as follows:

Obs: The envs folder in the application structure below will be explained later.

Each .env file has its environment variables set as follows:

.envA:

.envB:

.envC:

As it is, the .envC file is the last one listed in the structure above, so it will override any environment variables defined in the preceding .env files, and the environment variables that exist in the other files. more is not in the last (priority), it will continue to be used normally, the result / consolidated of the environment variables of the three files are:

Using the configuration of config('envs.sorted'), you can customize the default order of file priorities:

As above, the result of the environment variables of the 3 files would be:

Using multiple .env files per domain

In the same way that you use multiple envs files in the root of the application, it is possible to use .env files per domain:

See it in action

Using the same structure as the previous example, if the request / domain is site1.test, and there is a file .env.site1.test inside the envs folder, then the environment variables in that file will override all the other environment variables.

Assuming that the .env.site1.test file has the following variables:

When environment variables are used in the project, they will have the following results:

To see the examples in action, let's use this laravel application.

Domain custom .env file name

When the domain's .env filename is different from the default which is: .env.<domain>, then set the env key in the domain configs in config('envs.domains'), as follows:

Using config:cache and route:cache per domain

You can cache configs and routes by domain.

Caching configs by domain - config:cache

A new --domain option is available in the command. Using this option, the environment variables from the domain's .env file in the envs folder will override and take precedence over all others.

Use the config('envs.domains') configuration to customize the .php file that will be saved and used as a cache of configs. This ensures that multiple configuration files per domain can exist and be used in the same project.

To generate and use the .php file with a custom name of the domain cache settings, use the following code as an example:

Caching routes by domain - route:cache

As in the section above, the command to create the route cache file has a new --domain option, which will be used to filter only the routes that have the domain according to the option value.

It is also possible to have a custom name for the routes cache file, such as the configuration cache, is through the APP_ROUTES_CACHE key, as in the example below:

๐Ÿงช Testing

๐Ÿ“ Changelog

Please see CHANGELOG for more information about the changes on this package.

๐Ÿค Contributing

Please see CONTRIBUTING for details.

๐Ÿ”’ Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

๐Ÿ† Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-multienv with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
laravel/framework Version ^9.32
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 allysonsilva/laravel-multienv contains the following files

Loading the files please wait ....