phar-composer
phar-composer copied to clipboard
dotfiles are not included
Hi Clue, First of all: thanks a lot also for this amazing library!
I just tried to build a phar from a symfony5 console app, but struggled, since .env files are not included
I traced it down to https://github.com/clue/phar-composer/blob/e7b7730758ff7a90c677266b3dd20c1aabfccb6d/src/Clue/PharComposer/Package/Package.php#L89
And added
->ignoreDotFiles(false)
with that it works, do you consider this as something to be added, then i can happily create a PR, or are there other design considerations, why this was not added yet ?
@phiamo Thanks for reporting, I agree that this makes perfect sense!
I wonder what effect this has on existing projects though.
Does anybody feel like looking into this and filing a PR? :shipit:
Related (I think) issue here, during execution of compiled PHAR I get:
PHP Fatal error: Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the "phar:///[OBFUSCATED]/.env"] environment file. in phar:///[OBFUSCATED]/vendor/symfony/dotenv/Dotenv.php:505
Stack trace:
#0 phar:///[OBFUSCATED]/myApp.phar/vendor/symfony/dotenv/Dotenv.php(60): Symfony\Component\Dotenv\Dotenv->doLoad()
#1 phar:///[OBFUSCATED]/myApp.phar/vendor/symfony/dotenv/Dotenv.php(80): Symfony\Component\Dotenv\Dotenv->load()
#2 phar:///[OBFUSCATED]/myApp.phar/config/bootstrap.php(17): Symfony\Component\Dotenv\Dotenv->loadEnv()
#3 phar:///[OBFUSCATED]/myApp.phar/public/index.php(7): require('phar:///[OBFUSCATED]...')
#4 /[OBFUSCATED]/myApp.phar(12): require('phar:///home/ge...')
#5 {main}
thrown in phar:///[OBFUSCATED]/myApp.phar/vendor/symfony/dotenv/Dotenv.php on line 505
@phiamo Thanks for reporting, I agree that this makes perfect sense!
I wonder what effect this has on existing projects though.
Does anybody feel like looking into this and filing a PR? :shipit:
Hey @clue, what else would be to do then adding the one line? 😆 Is there a new status about this topic?
@Moskito89 I talked with @clue about this and we don't have a clear answer yet. It makes totally sense to also support dotfiles, but including them by default feels like a BC-break as it would change the current behavior and could lead to some unexpected behavior for other users. I'm interested in your opinion on this and happy to hear your ideas!
what else would be to do then adding the one line?
Adding the line is the easy part, we'd also need to confirm the new behavior through additional tests. I'm happy to take a look at contributions, but I think it makes sense to first discuss the best possible solution for this in here and then create a pull request.
@SimonFrings thanks for your reply! I too think, that adding dot files per default would be a risky behaviour. But it could be an option when building a PHAR, for example --include-dot-files. I'm not sure but I think there could also be a difference between dot files in the root directory and dot files anywhere else, so maybe there could be another option to include all of them or only the dot files in the root. IMHO the root dot files are the only important ones, so this could be the default setting when including them.
Hey @SimonFrings, how can we continue here? 😊
@Moskito89 I think adding this as an option avoids the current BC-break problem. I agree that the root files are a first good step for this, so I think it's best to focus on this first (also to not overload any PRs) and then add additional features for all other dot files elsewhere later on (if needed).
We're currently investing our work into Framework X and ReactPHP, so I don't think this has highest priority on our side. If you already have an idea for an implementation, we're also happy about pull requests. When contributing a new feature like this, it's important for us is that the pull request should not only focus on the implementation side of things, which is most often the "easy" part. We also have to make sure that any new additions are also covered by our test suite (unit tests) to confirm the suggested changes work as expected and it needs additional documentation on how to properly use it.
I'm happy to take a look at PRs or if you need this urgently you can also reach out to us or help us prioritizing by becoming a sponsor ❤️