Reputation: 1
I have a bash script, that executes command using Sentry cli for profiling.
#!/bin/bash
ENV_FILE="../../.env.local"
# Check if the .env.local file exists
if [ ! -f "$ENV_FILE" ]; then
echo "Error: $ENV_FILE file not found."
exit 1
fi
SENTRY_DSN=$(grep '^SENTRY_DSN=' "$ENV_FILE" | cut -d '=' -f 2-)
# Use the SENTRY_DSN from the environment variable
if [ -n "$SENTRY_DSN" ]; then
export SENTRY_DSN
else
echo "Error: SENTRY_DSN is not set in .env.local"
exit 1
fi
path-to-sentry-cli/sentry-cli monitors run command-name -- php bin/console app:somecommand
I have following symfony project structure.
my_project/
│── bin/
│ ├── ShellScripts
| │ ├── my-script.sh
│── config/
│── migrations/
│── public/
│── src/
│ ├── Command/
| | ...
│── templates/
│── translations/
│── var/
│ ├── cache/
│ ├── log/
│── vendor/
│── tests/
│── .env
│── .env.local
│── composer.json
│── symfony.lock
│── phpunit.xml.dist
│── README.md
I am getting following error after execution of bash script. This bundle is setted to dev only. In .env APP_ENV=dev
. In env.local it is setted to prod. This error is probably caused by the fact that only .env is imported, and .env.local where values from .env are overwritten is not read. Also env.local.php was not read in any way during the bin/console excution.
Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#78
#message: """
Attempted to load class "WebProfilerBundle" from namespace "Symfony\Bundle\WebProfilerBundle".\n
Did you forget a "use" statement for another namespace?
"""
#code: 0
However when I am directly executing php bin/console app:somecommand everything works fine as it should as well as a rest of the project. What could be causing this behavior? If I understand Sentry Cli correctly, it should generally have no direct effect on the .env reading in Symfony, because it just executes given command.
Upvotes: 0
Views: 45