Skip to content

Commit b398efb

Browse files
authored
Clarify env() behavior after config caching (laravel#10513)
Clarify env() behavior after configuration caching The current documentation states that “all calls to the env function will return null” once the configuration has been cached. However, this is only true for environment variables defined exclusively in the .env file. If the environment variable exists at the system level (e.g., via putenv(), server configuration, env() will still return a value after caching. This clarification helps developers understand that env() is not completely disabled after config:cache, but rather depends on the source of the environment variable.
1 parent f4b76d3 commit b398efb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

helpers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,7 @@ $env = env('APP_ENV', 'production');
24382438
```
24392439

24402440
> [!WARNING]
2441-
> If you execute the `config:cache` command during your deployment process, you should be sure that you are only calling the `env` function from within your configuration files. Once the configuration has been cached, the `.env` file will not be loaded and all calls to the `env` function will return `null`.
2441+
> If you execute the `config:cache` command during your deployment process, you should be sure that you are only calling the `env` function from within your configuration files. Once the configuration has been cached, the `.env` file will not be loaded and all calls to the `env` function will return external environment variables such as server-level or system-level environment variables or `null`.
24422442
24432443
<a name="method-event"></a>
24442444
#### `event()` {.collection-method}

0 commit comments

Comments
 (0)