Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Multienv

Laravel Multienv Laravel Package

allysonsilva/laravel-multienv

Laravel Multienv lets one Laravel installation run with multiple environment files, automatically selecting the right .env per domain or request. Ideal for multi-domain or multi-tenant apps sharing a single codebase, it keeps configuration isolated and manageable without duplicating the application.

View on GitHub
Deep Wiki
Context7

A Laravel package that allows you to use multiple ".env" files in a precedent manner. Use ".env" files per domain (multi-tentant)!

Frequently asked questions about Laravel Multienv
How do I install allysonsilva/laravel-multienv in a Laravel app?
Install the package with Composer using composer require allysonsilva/laravel-multienv. Standard Laravel package discovery should register the service provider, but you should still publish or configure its env-file mapping for your domains. For v2.1.0, confirm your application runs Laravel 9.32 or newer before installing.
What Laravel versions are supported by laravel-multienv?
Version 2.1.0 requires Laravel 9.32 or newer. Applications on older Laravel 9 releases or Laravel 8 cannot adopt v2.1.0 without upgrading the framework first. If you cannot upgrade immediately, evaluate v2.0.0 or defer adoption until your Laravel version is compatible.
How does laravel-multienv select the correct .env file per domain?
Laravel Multienv operates at Laravel’s environment and bootstrap layer to choose among multiple .env files. You define the env-file naming and precedence rules, then the package selects the appropriate file for the domain or request. Test the mapping in staging because precedence mistakes can load the wrong configuration.
Can laravel-multienv be used for multi-tenant Laravel applications?
Yes, the package is intended for multi-domain and multi-tenant applications that share a single Laravel codebase. It lets each domain or tenant resolve its own .env file so configuration stays isolated without duplicating the application. This is useful for tenant-specific services, but secrets and database isolation still need careful review.
Does laravel-multienv support php artisan optimize and optimize:clear?
Version 2.1.0 added support for optimize and optimize:clear, which helps account for Laravel’s config and route cache lifecycle. That reduces the risk of stale configuration after an environment change, but it does not remove the need for testing. Exercise optimize, optimize:clear, and config:cache in your actual deployment pipeline before production rollout.
Does laravel-multienv change APP_ENV resolution or just .env file precedence?
The package works at Laravel’s environment and bootstrap layer, but the exact effect on APP_ENV resolution versus .env file precedence should be confirmed for your version and configuration. Treat it as infrastructure-level plumbing rather than a normal feature dependency. Verify the resolved environment values and selected env file in local, staging, and CI before relying on it.
What risks should I consider before using multiple .env files in Laravel production?
Environment manipulation has a high blast radius because the wrong .env file can expose secrets, connect to the wrong database, or send production traffic to non-production services. Test cache clearing, queue worker restarts, and environment switching after every change. Teams should also audit custom bootstrap code, Docker entrypoints, and non-standard env loading before rollout.
How does laravel-multienv behave with Laravel Octane, queue workers, and scheduled tasks?
You must audit how the package interacts with Laravel Octane, queue workers, and scheduled tasks because those processes may boot before or after environment switching. A worker that started under one env file may not automatically pick up a later switch. Include worker restarts and long-running process checks in your runbook and staging tests.
How do I roll back laravel-multienv to a single .env file?
Document a rollback path before broad rollout, including removing the package configuration and returning to Laravel’s standard single .env workflow. Verify that config cache is cleared and queue workers are restarted after rollback. Keep the rollback procedure in your deployment runbook so it can be executed quickly during an incident.
What deployment sequence is recommended for laravel-multienv?
Start by inventorying all environment variables and secrets, then define the env-file strategy and precedence rules. Install and test in local and staging, exercise optimize and optimize:clear in CI, and update deploy scripts and worker restart procedures. Canary one non-critical service before broad rollout, and document rollback to single-env behavior first.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource