Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
export PHPLIST_DATABASE_PASSWORD=${{ env.DB_PASSWORD }}
export PHPLIST_DATABASE_PORT=${{ job.services.mysql.ports['3306'] }}
export PHPLIST_DATABASE_HOST=127.0.0.1
export PHPLIST_DATABASE_PATH=
vendor/bin/phpunit tests/Integration/
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running static analysis
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
/var/
/vendor/
.phpunit.result.cache
.env
.env.dist
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"require": {
"php": "^8.1",
"phplist/core": "dev-main",
"phplist/core": "dev-dev",
"friendsofsymfony/rest-bundle": "*",
"symfony/test-pack": "^1.0",
"symfony/process": "^6.4",
Expand Down Expand Up @@ -85,6 +85,7 @@
"PhpList\\Core\\Composer\\ScriptHandler::createGeneralConfiguration",
"PhpList\\Core\\Composer\\ScriptHandler::createBundleConfiguration",
"PhpList\\Core\\Composer\\ScriptHandler::createRoutesConfiguration",
"PhpList\\Core\\Composer\\ScriptHandler::createDotenvConfiguration",
"PhpList\\Core\\Composer\\ScriptHandler::createParametersConfiguration",
"PhpList\\Core\\Composer\\ScriptHandler::clearAllCaches"
],
Expand Down
3 changes: 2 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.2/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="error_reporting" value="-1"/>
<server name="KERNEL_CLASS" value="PhpList\Core\Core\ApplicationKernel"/>
<server name="APP_ENV" value="test" force="true"/>
</php>
</phpunit>
2 changes: 1 addition & 1 deletion tests/Integration/Common/Routing/RoutingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RoutingTest extends WebTestCase
public function testRootUrlHasHtmlContentType()
{
$client = self::createClient();
$client->request('get', '/api/v2');
$client->request('GET', '/api/v2', server: ['HTTP_ACCEPT' => 'text/html']);

$response = $client->getResponse();

Expand Down
4 changes: 1 addition & 3 deletions tests/Integration/Composer/ScriptsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ private function getAbsolutePublicDirectoryPath(): string
public static function publicDirectoryFilesDataProvider(): array
{
return [
'production entry point' => ['app.php'],
'development entry point' => ['app_dev.php'],
'testing entry point' => ['app_test.php'],
'entry point' => ['index.php'],
'.htaccess' => ['.htaccess'],
];
}
Expand Down
11 changes: 11 additions & 0 deletions tests/bootstrap.php
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');
}
Comment on lines +9 to +11

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.

Loading