-
Notifications
You must be signed in to change notification settings - Fork 14
Refactor: env #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Refactor: env #170
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,5 @@ | |
| /var/ | ||
| /vendor/ | ||
| .phpunit.result.cache | ||
| .env | ||
| .env.dist | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| use Symfony\Component\Dotenv\Dotenv; | ||
|
|
||
| require dirname(__DIR__) . '/vendor/autoload.php'; | ||
|
|
||
| if (method_exists(Dotenv::class, 'bootEnv')) { | ||
| (new Dotenv())->bootEnv(dirname(__DIR__) . '/.env'); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: phpList/rest-api
Length of output: 3664
🌐 Web query:
Symfony Dotenv 5 bootEnv deprecated load API💡 Result:
The
bootEnv()method in the Symfony Dotenv component is not deprecated [1][2][3]. It was introduced in version 5.1 as a feature to replace manualbootstrap.phplogic by checking for a compiled.env.local.phpfile before falling back toloadEnv()[4][5]. If you are seeing deprecation warnings related toDotenv, they are likely referring to theDotenvconstructor rather than thebootEnv()method itself [6][7]. Key points regarding these APIs: 1. Dotenv::bootEnv (Not Deprecated): This method is the standard, supported way to initialize environment variables in modern Symfony applications [1][2][3]. It is designed to be called in your entry points (e.g.,public/index.php) and handles both standard.envfiles and optimized.env.local.phpfiles [4][5]. 2. Dotenv Constructor (Deprecated Usage): If you are passing a boolean argument to thenew Dotenv()constructor (e.g.,new Dotenv(false)), this has been deprecated since Symfony 5.1 [6][5][7]. - Instead of passing a boolean to the constructor, you should use theDotenv::usePutenv()method to configure this behavior if needed [6][5][7]. If you are upgrading an older Symfony application, it is recommended to update your project recipes to match current standards, which typically involve moving away from manualconfig/bootstrap.phpfiles in favor of thebootEnv()logic managed by Symfony Flex or the Symfony runtime component [4][6][7].Citations:
🌐 Web query:
Symfony Dotenv 6 remove bootEnv load method💡 Result:
The
Dotenv::bootEnv()method has not been removed in Symfony 6, nor in any subsequent version up to and including Symfony 8.1 [1][2][3]. The method remains a core part of the Symfony Dotenv component, designed to load environment variables from a.env.local.phpfile if it exists, or fall back to standard.envfiles otherwise [4][1][2]. If you are encountering issues related tobootEnvin Symfony 6, they are likely not due to the method's removal, but rather to other breaking changes introduced in the major version transition, such as signature changes or removed constructor arguments. For instance, Symfony 6 removed the$usePutenvargument from theDotenvconstructor; instead, you must use theDotenv::usePutenv()method [5]. It is recommended to verify your implementation against the current official Symfony documentation, which continues to featurebootEnv()as the standard way to handle application bootstrapping [6][7].Citations:
🌐 Web query:
Symfony Dotenv bootEnv introduced Symfony 5.1 Dotenv.php💡 Result:
The
Dotenv::bootEnv()method was introduced in Symfony 5.1.0 as part of thesymfony/dotenvcomponent [1][2][3]. This feature was implemented to check for the existence of an optimized.env.local.phpfile before falling back to the standard.envloading process viaDotenv::loadEnv()[4][5][6]. Its primary purpose was to improve application performance by allowing developers to dump environment variables into a PHP file, thereby avoiding the overhead of parsing multiple.envfiles on every request [2][3]. The introduction ofbootEnv()also served to standardize and simplify the bootstrapping logic in Symfony applications, effectively replacing the manualconfig/bootstrap.phpfile that was previously used in Symfony project skeletons [4][7]. The method is typically invoked in entry points such aspublic/index.phpandbin/consoleusing the following syntax: (new Dotenv)->bootEnv(dirname(DIR).'/.env'); [4][8]Citations:
🌐 Web query:
Symfony Dotenv loadEnv isAlias method before 5.1💡 Result:
The
loadEnv()method does not exist in versions of the Symfony Dotenv component prior to version 4.2 [1]. TheloadEnv()method was introduced in Symfony 4.2 [1][2] as a replacement for the earlierloadForEnv()method (which had been introduced in version 4.1 via pull request#28533[3]). TheloadEnv()method was designed to provide a more streamlined way to load environment-specific files—specifically.env,.env.local,.env.$env, and.env.$env.local—without the "chicken-and-egg" issues present inloadForEnv()[4][5]. If you are working with a Symfony application using a Dotenv version earlier than 4.2, you cannot useloadEnv()and must rely on the standardload()method to manually load your environment files [1][6].Citations:
🌐 Web query:
Symfony Dotenv component loadEnv load aliases deprecated bootEnv 6.2💡 Result:
In Symfony 6.2, neither the Dotenv::loadEnv nor the Dotenv::bootEnv methods are deprecated [1][2][3]. Both methods remain active and recommended for configuring application environment variables [4][5]. The Dotenv::loadEnv method is used to load environment variables from.env files, while Dotenv::bootEnv acts as an optimized, environment-aware wrapper that checks for a precompiled.env.local.php file before falling back to loading standard.env files [1][5][6]. Because bootEnv handles both the loading of environment variables and the configuration of the APP_DEBUG setting, it is the standard approach used in modern Symfony bootstrapping (typically called in public/index.php or bin/console) [7][6]. If you are encountering warnings or deprecation messages related to the Dotenv component, they often stem from outdated constructor usage (such as passing a boolean to the constructor, which was deprecated in 5.1) rather than the loading methods themselves [3][8]. Ensure your application is using the modern, non-deprecated constructor signature (e.g., using Dotenv::usePutenv instead of passing a boolean) [8].
Citations:
Require
bootEnv()or fall back to loading.env.bootEnv()is the intended Symfony Dotenv bootstrap method, but older Dotenv versions before its introduction will skip the.envload entirely and leave tests without the project defaults. Fall back to the available loading method, or constrain Dotenv to a version that providesbootEnv().🤖 Prompt for AI Agents