-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Allow manipulation of base path when warming cache #3079
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
Comments
I was thinking on implementing similar feature for deployment of sf2 based app. Simple sed-replacing was not actually an option, as most of the paths were stored in php-serialized files. This feature would take much time to test and implement, as it depends not on single bundle. |
Actually we are doing it with sed currently, maybe this is of use for you:
|
@samuelvogel so, there are no serialised files and nothing gets corrupted? |
Nothing gets corrupted, we are using this in production! |
then add entry to manual please ;) |
Same Issue, I can't run both web and console together. Any solutions ? |
I found solution without coding in php side. Steps
Then path will be changed to absolute path. |
@johnrivelt: Well this is not really a solution, you are just disabling the chroot of PHP-FPM... What we are doing currently is emptying the |
Your solution will work for web access but not from console command in my I confirmed that problem is Because the cache generated from web has web root path is same with SAPI My solving way is to make php-fpm root path same with CLI root. I am assuming your case might be related chroot path or cache folder John Cho
|
…tainer (fabpot) This PR was merged into the 2.3 branch. Discussion ---------- [HttpKernel] removed absolute paths from the generated container | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | first step to resolve #6484, #3079, and #9238 | License | MIT | Doc PR | n/a This PR converts absolute paths to relative ones in the dumped container. The code is a bit "ugly", but it gets the job done and I'm not sure that there is a more elegant way without breaking everything. Commits ------- c1450b4 [HttpKernel] removed absolute paths from the generated container
…e generated container (nicolas-grekas) This PR was merged into the 2.3 branch. Discussion ---------- [DependencyInjection] make paths relative to __DIR__ in the generated container | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6484, #3079, partially #9238, #10894, #10999 | License | MIT | Doc PR | n/a This is an alternative approach to #10999 for removing absolute paths from the generated container: instead of trying to fix the container file after it has been dumped, telling to the PhpDumper where its output will be written allows it to replace parts of strings by an equivalent value based on `__DIR__`. This should be safe, thus the PR is on 2.3. Commits ------- edd7057 [DependencyInjection] make paths relative to __DIR__ in the generated container
Fixed by #12784 |
@fabpot, @nicolas-grekas, this issue was not fully fixed by #12784. Specifically, |
I agree. Currently we're running into problems having absolute paths in We're building release packages during a Jenkins build on a dedicated build machine which we then deploy to production machines. But the cache file We can omit the |
I agree, too. There are still absolute paths in |
It should be possible to adopt the same strategy than @nicolas-grekas on #12784 : after generating absolute path, match the result with DIR to make it relative. |
…s cache (tgalopin) This PR was merged into the 3.2-dev branch. Discussion ---------- [FrameworkBundle] Use relative paths in templates paths cache | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #3079 | License | MIT | Doc PR | - This implements the usage of relative paths instead of absolute ones in `var/cache/*/templates.php`, important for ability to build the cache in a different context than where it will be used. This PR transforms the following `templates.php`: ``` php <?php return array ( ':default:index.html.twig' => '/home/tgalopin/www/symfony-standard/app/Resources/views/default/index.html.twig', '::base.html.twig' => '/home/tgalopin/www/symfony-standard/app/Resources/views/base.html.twig', ); ``` Into: ``` php <?php return array ( ':default:index.html.twig' => __DIR__.'/../../../app/Resources/views/default/index.html.twig', '::base.html.twig' => __DIR__.'/../../../app/Resources/views/base.html.twig', ); ``` I also added tests for the TemplateCachePathsWarmer and improved tests for the TemplateLocator. Commits ------- 6f6139c [FrameworkBundle] Use relative paths in templates paths cache
Should be fixed now, if you have an issue don't hesitate to report it here. |
Why has #19687 not been released yet? |
It is merged into master, and master will be tagged as 3.2 by the end of november, according to the release policy. |
Ah ok, I see. Thank you very much! |
It makes sense to allow a manipulation of the base path for cache warming for several reasons:
The problem is when you warm the cache in a directory that is later moved or only accessible by a different path, then paths in
app/cache/prod/templates.php
for example will be wrong, and Twig imports will break.The text was updated successfully, but these errors were encountered: