-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Config] Fixing GlobResource when inside phar archive #26845
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
Conversation
is it really a bc break? looks like a bug fix for me |
Actually, this should not be an issue if you warmup the prod cache (and thus build the container) before building your phar (and bundling As I answered @c33s on Slack, I use the following https://github.com/humbug/box config with no issue to bundle a Symfony app in a phar: {
"files": ["config/bundles.php"],
"finder": [
{ "in": "src" },
{ "in": "var/cache/prod" },
{
"name": ["*.php"],
"exclude": ["Tests", "Tester", "Test", "test", "tests"],
"in": "vendor"
}
],
"main": "bin/phar-app",
"output": "legacy-importer.phar",
"compression": "GZ",
"stub": true
} where |
@ogizanagi you are of course right, if pre-warming the cache is an option this can be used to work around the issue. Nevertheless I think the current behavior is not intended and leads to confusion as well as bad DX. And once someone might want to run a packaged app in debug mode for whatever reason, the pre-warmed cache may not be sufficient anymore. |
Could you add a test case please? |
example.zip
|
Could it also be that the application is executed in the wrong environment? I.e. when booting inside the PHAR, it detects that the dumped container is outdated and tries to dump it again (which will fail) |
When packaging an Sf4 application as a PHAR archive using globs at various locations (`Kernel`, `services.yaml`) most glob files are not found because the `glob()` PHP method [does not support PHAR streams](https://stackoverflow.com/questions/8203188/unexpected-problems-with-php-phar). Using the regex fallback instead when operating inside PHAR archives fixes the behavior for me.
Thank you @vworldat. |
…rldat) This PR was merged into the 3.4 branch. Discussion ---------- [Config] Fixing GlobResource when inside phar archive | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | yes if old broken behavior counts as stable | Deprecations? | no | Tests pass? | no tests yet | Fixed tickets | | License | MIT | Doc PR | N/A When packaging an Sf4 application as a PHAR archive using globs at various locations (`Kernel`, `services.yaml`) most glob files are not found because the `glob()` PHP method [does not support PHAR streams](https://stackoverflow.com/questions/8203188/unexpected-problems-with-php-phar). Using the regex fallback instead when operating inside PHAR archives fixes the behavior for me. ## Examples: `src/Kernel.php::configureContainer()`: ```php $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); ``` Expected behavior: `config/services.yaml` inside PHAR archive is found and parsed Actual behavior: the file will not be loaded `config/services.yaml` (hard-coded in Kernel without using glob pattern) ```yaml App\: resource: '../src/*' exclude: '../src/{Entity,Migrations,Tests,Kernel.php}' ``` Expected behavior: service classes in `src/` will be found and auto-wired Actual behavior: services are not auto-wired because the class files are not found Commits ------- e336ebe Fixing GlobResource when inside phar archive
…source (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [Config] Fix looking for single files in phars with GlobResource | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - `Finder::in()` only accepts directories as arguments, but `GlobResource` can feed it with files when looking inside a phar file (see #26845) or when using `/**/` in the pattern. This PR fixes it. Commits ------- d4ea072 [Config] Fix looking for single files in phars with GlobResource
When packaging an Sf4 application as a PHAR archive using globs at various locations (
Kernel
,services.yaml
) most glob files are not found because theglob()
PHP method does not support PHAR streams.Using the regex fallback instead when operating inside PHAR archives fixes the behavior for me.
Examples:
src/Kernel.php::configureContainer()
:Expected behavior:
config/services.yaml
inside PHAR archive is found and parsedActual behavior: the file will not be loaded
config/services.yaml
(hard-coded in Kernel without using glob pattern)Expected behavior: service classes in
src/
will be found and auto-wiredActual behavior: services are not auto-wired because the class files are not found