You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The article uses different naming conventions for environment variables. In the examples, both camelCase (JOOMLA_SITE_NAME) and snake_case (JOOMLA_ERROR_REPORTING) are used. Consistency should be verified.
While the article mentions that environment variables enhance security, it doesn't provide guidance on securing .env files themselves or warn about not committing them to version control.
Using environment variables allows developers to separate configuration from code, making it easier to manage different environments without modifying the application's source code. This approach enhances security because sensitive information, like database passwords, can be excluded from version control systems.
Remove quotes around the site name value. In .env files, quotes are typically treated as part of the value rather than string delimiters, which could cause unexpected behavior when the value is used.
```env title=".env"
JOOMLA_DEBUG=true
JOOMLA_ERROR_REPORTING=maximum
-JOOMLA_SITE_NAME='My Cool Site'+JOOMLA_SITE_NAME=My Cool Site
- [ ] **Apply / Chat** <!-- /improve --apply_suggestion=0 -->
<details><summary>Suggestion importance[1-10]: 7</summary>
__
Why: Good catch - quotes in `.env` files are typically treated as literal characters rather than string delimiters, which could cause unexpected behavior when `JOOMLA_SITE_NAME` is used.
</details></details></td><td align=center>Medium
</td></tr><tr><td>
<details><summary>Add error handling</summary>
___
**Add error handling for environment variable access. Direct access to <br>superglobals can cause undefined index errors if the environment variable <br>doesn't exist. Use isset() checks or null coalescing operators for safer access.**
[docs/general-concepts/dotenv.md [23-25]](https://github.com/joomla/Manual/pull/480/files#diff-a6da5b2d9feb0c624c74763e893ca70d110f89bf6299534b4696f6d477831e6eR23-R25)
```diff
-$foo = $_SERVER['FOO'];
-$bar = $_ENV['BAR'];
-$baz = getenv('BAZ');
+$foo = $_SERVER['FOO'] ?? null;
+$bar = $_ENV['BAR'] ?? null;
+$baz = getenv('BAZ') ?: null;
Apply / Chat
Suggestion importance[1-10]: 4
__
Why: While technically correct, adding error handling complicates simple documentation examples meant for illustrative purposes. The basic examples are appropriate for introductory documentation.
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
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.
User description
For: joomla/joomla-cms#45523
This is an updated version of #432
PR Type
Documentation
Description
Adds a comprehensive article explaining
.envfiles and environment variables.Documents how to configure Joomla using environment variables.
Provides code examples for both PHP and
.envusage.Highlights best practices and references for further reading.
Changes walkthrough 📝
dotenv.md
New documentation article on dotenv and environment variablesdocs/general-concepts/dotenv.md
.envfiles and their purpose.