Skip to content

Refactor: env - #170

Merged
TatevikGr merged 3 commits into
devfrom
env
Jul 29, 2026
Merged

Refactor: env#170
TatevikGr merged 3 commits into
devfrom
env

Conversation

@TatevikGr

@TatevikGr TatevikGr commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Configuration
    • Updated CI integration testing to export PHPLIST_DATABASE_PATH.
    • Refreshed the PHPUnit setup to bootstrap from the test harness and force APP_ENV=test.
    • Extended setup to generate dotenv configuration and adjusted the core package version source.
  • Testing
    • Updated integration assertions for routing content negotiation.
    • Updated checks for generated public-directory entry-point contents.
  • Chores
    • Excluded local .env files from version control.

Thanks for contributing to phpList!

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The project now uses the dev-dev branch of phplist/core and runs its dotenv configuration handler during update-configuration. Dotenv files are ignored, PHPUnit loads tests/bootstrap.php with APP_ENV=test, and the bootstrap loads .env when supported. CI exports an empty PHPLIST_DATABASE_PATH, while integration tests update request headers and expect index.php as the public entry point.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is related to environment-related changes but too vague to convey the main update. Use a clearer title like "Add dotenv-based test environment setup" to describe the primary change.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch env

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@TatevikGr
TatevikGr force-pushed the env branch 3 times, most recently from a92ccc0 to cf5ea66 Compare July 26, 2026 08:49
@TatevikGr
TatevikGr changed the base branch from main to dev July 29, 2026 17:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/bootstrap.php`:
- Around line 9-11: Update the Dotenv initialization around bootEnv() to ensure
.env is loaded when bootEnv() is unavailable. Prefer the supported fallback
loading method for older Dotenv versions, while preserving the existing
bootEnv() path when available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ec43875d-c5a8-42f3-87ce-650546553274

📥 Commits

Reviewing files that changed from the base of the PR and between a672b87 and a15a9c7.

📒 Files selected for processing (5)
  • composer.json
  • phpunit.xml.dist
  • tests/Integration/Common/Routing/RoutingTest.php
  • tests/Integration/Composer/ScriptsTest.php
  • tests/bootstrap.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • composer.json

Comment thread tests/bootstrap.php
Comment on lines +9 to +11
if (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
}

Copy link
Copy Markdown

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:

#!/bin/bash
set -euo pipefail

echo "== candidate files =="
git ls-files | rg '(^|/)(composer\.json|tests/bootstrap\.php|phpunit\.xml|\.env)' || true

echo
echo "== bootstrap.php =="
if [ -f tests/bootstrap.php ]; then
  cat -n tests/bootstrap.php
fi

echo
echo "== composer dotenv declarations =="
for f in $(git ls-files | rg 'composer(\.lock)?\.json$'); do
  echo "--- $f ---"
  python3 - <<'PY' "$f"
import json, sys
p=sys.argv[1]
data=json.load(open(p))
for sec in ("require","require-dev"):
    deps=data.get(sec,{})
    hits={k:v for k,v in deps.items() if "dotenv" in k.lower() or k=="php" or k=="symfony/console" or k=="laravel/framework"}
    if hits:
        print(sec,hits)
PY
done

echo
echo "== dotenv usages =="
rg -n "Dotenv|bootEnv|load\(|dotenv" -S --glob '!vendor/**' . || true

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 manual bootstrap.php logic by checking for a compiled .env.local.php file before falling back to loadEnv() [4][5]. If you are seeing deprecation warnings related to Dotenv, they are likely referring to the Dotenv constructor rather than the bootEnv() 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 .env files and optimized .env.local.php files [4][5]. 2. Dotenv Constructor (Deprecated Usage): If you are passing a boolean argument to the new 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 the Dotenv::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 manual config/bootstrap.php files in favor of the bootEnv() 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.php file if it exists, or fall back to standard .env files otherwise [4][1][2]. If you are encountering issues related to bootEnv in 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 $usePutenv argument from the Dotenv constructor; instead, you must use the Dotenv::usePutenv() method [5]. It is recommended to verify your implementation against the current official Symfony documentation, which continues to feature bootEnv() 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 the symfony/dotenv component [1][2][3]. This feature was implemented to check for the existence of an optimized .env.local.php file before falling back to the standard .env loading process via Dotenv::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 .env files on every request [2][3]. The introduction of bootEnv() also served to standardize and simplify the bootstrapping logic in Symfony applications, effectively replacing the manual config/bootstrap.php file that was previously used in Symfony project skeletons [4][7]. The method is typically invoked in entry points such as public/index.php and bin/console using 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]. The loadEnv() method was introduced in Symfony 4.2 [1][2] as a replacement for the earlier loadForEnv() method (which had been introduced in version 4.1 via pull request #28533 [3]). The loadEnv() 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 in loadForEnv() [4][5]. If you are working with a Symfony application using a Dotenv version earlier than 4.2, you cannot use loadEnv() and must rely on the standard load() 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 .env load entirely and leave tests without the project defaults. Fall back to the available loading method, or constrain Dotenv to a version that provides bootEnv().

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/bootstrap.php` around lines 9 - 11, Update the Dotenv initialization
around bootEnv() to ensure .env is loaded when bootEnv() is unavailable. Prefer
the supported fallback loading method for older Dotenv versions, while
preserving the existing bootEnv() path when available.

@TatevikGr
TatevikGr merged commit f9ee62d into dev Jul 29, 2026
9 checks passed
@TatevikGr
TatevikGr deleted the env branch July 29, 2026 17:44
@coderabbitai coderabbitai Bot mentioned this pull request Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants