-
-
Notifications
You must be signed in to change notification settings - Fork 60
Add .env file support and consolidate all configuration to root directory #418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
src/DotEnvLoader.php
Outdated
| * Simple .env file loader for non-Docker environments. | ||
| * Loads environment variables from a .env file. | ||
| */ | ||
| final class DotEnvLoader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good enough one or is it better to use vlucas/phpdotenv as in yiisoft/app-api#253?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The custom implementation is lightweight (60 lines) with zero dependencies and handles the basic use case (key=value, comments, quotes). It's sufficient for this app's needs.
However, vlucas/phpdotenv offers more features (variable expansion, multi-line values, better validation). If you prefer the library approach for consistency with app-api, I can switch to it. Let me know your preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot switch to using vlucas/phpdotenv.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to vlucas/phpdotenv in commit c23af10:
- Added
vlucas/phpdotenv^5.6 to composer.json - Updated
src/autoload.phpto useDotenv::createImmutable()andsafeLoad() - Removed custom
DotEnvLoaderclass and its tests - Updated README to remove reference to DotEnvLoader
The implementation now uses the industry-standard library for better compatibility and feature support (variable expansion, multi-line values, better validation).
Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
|
@copilot I don't like the fact that there are too many I'd move these into the root directory. |
Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
To clarify: this PR only adds Are you asking me to move those existing Docker .env files to the root? That would be a larger refactoring beyond this PR's scope. Could you clarify what you'd like me to do? |
|
@copilot yes. |
Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Done in commit d63ad5c. All Docker .env files have been moved to the root directory:
The compose files now reference the root directory, and all subdirectory .env files and .gitignore files have been removed. |
|
@copilot move compose files and Dockerfile from docker directory to the root as well. |
Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Done in commit c10ede9. All Docker files moved to root:
Updated all compose files with correct paths (dockerfile, context, env_file), updated Makefile references, and updated README documentation. The docker directory now only contains the |
|
@copilot move the rest from |
…ectory Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Done in commit d43eb99. The docker directory has been completely removed:
The docker directory is now completely gone. All Docker configuration files are at the root level. Users should copy Note: There was no |
Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #418 +/- ##
============================================
- Coverage 76.96% 75.40% -1.56%
Complexity 29 29
============================================
Files 11 11
Lines 178 183 +5
============================================
+ Hits 137 138 +1
- Misses 41 45 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
Enables local development with
.envfiles while maintaining production security through sensible defaults. Completely consolidates all environment and Docker configuration files to the root directory, eliminating the docker subdirectory entirely for a clean, flat project structure.Implementation:
vlucas/phpdotenv- Industry-standard .env parser library.envif presentEnvironment defaults -
APP_ENVnow defaults toprodwhen unset.envwithAPP_ENV=dev.envrequired, defaults toprod.envPerformance optimization - Skips
.envloading entirely whenAPP_ENVis already setConsolidated environment files - All
.envfiles at root directory.env.example- General local development configuration.env.docker.example- Docker-specific variables (stack name, ports, image names).env.dev.example- Docker development environment.env.prod.example- Docker production environment.env.test.example- Docker test environment.env.override.example- Custom local overrides exampleConsolidated Docker configuration - All Docker files at root directory
Dockerfile- Moved fromdocker/Dockerfilecompose.yml- Moved fromdocker/compose.ymlcompose.dev.yml- Moved fromdocker/dev/compose.ymlcompose.prod.yml- Moved fromdocker/prod/compose.ymlcompose.test.yml- Moved fromdocker/test/compose.ymlDocker directory completely removed
docker/.env→.env.docker.example-include .env.docker.gitignore- Excludes all.envfiles from version controlUsage:
Changes from original scope:
.envfiles fromdocker/dev/,docker/prod/, anddocker/test/to root directorydocker/subdirectories to root directorydocker/.envto.env.docker.exampleat rootBenefits:
Backward compatible with existing Docker and CI/CD workflows, with optimized performance for environments where
APP_ENVis already set.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.