-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[HttpKernel] Add $kernel->getBuildDir() to separate it from the cache directory
#36515
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
| public function getTmpDir() | ||
| { | ||
| // Returns $this->getCacheDir() for backward compatibility | ||
| return $this->getCacheDir(); |
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.
Here is the core of the PR :)
For backward compatibility, I return the current cache directory.
In future versions, this could be for example var/build. In the meantime, users can override this method to set it to a different path, for example /tmp.
61bd29e to
fee57fb
Compare
$kernel->getTmpDir() to separate it from the cache directory$kernel->getTmpDir() to separate it from the cache directory
|
This solution probably makes a lot of sense ... but at first seems confusing: Problem:
Solution:
|
|
@javiereguiluz yes, this was brought up in #23354 (comment) and I think that's a valid alternative: keep cache as-is, introduce a new I'm waiting for feedback on this new approach, I started looking into it a pull request as well but haven't opened it yet. |
|
This is a good move IMHO. Reading the related issue, I think we should get the naming right. Keeping the |
$kernel->getTmpDir() to separate it from the cache directory$kernel->getBuildDir() to separate it from the cache directory
|
Great! I have updated the PR. Note that after struggling for a while I did not succeed running the tests locally ( Review is welcome! |
fabpot
left a comment
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.
LGTM (minor comment)
WDYT @symfony/mergers?
|
@mnapoli are you using the |
|
This makes a lot of sense to me. And the fact that the new Very nice! |
| } | ||
|
|
||
| $io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true))); | ||
| $this->cacheClearer->clear($realBuildDir); |
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.
Shouldn't this command avoid removing the build dir by default? What about adding a --build option?
For the ones not overriding KernelInterface::getBuildDir(), this option won't do anything more.
But for the ones overriding, you might want to call this command to clear the read-write cache, but not the read-only build dir, right?
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.
As a first step, we must clear everything like today.
|
@stof thanks for the tip, I didn't. Still, when I use it the tests crash with:
Anyway, I don't really want to pollute the discussion with this. |
|
Thank you @mnapoli. |
In order to support deploying on read-only filesystems (e.g. AWS Lambda in my case), I have started implementing #23354.
This introduces
$kernel->getBuildDir():$kernel->getBuildDir(): for cache that can be warmed and deployed as read-only (compiled container, annotations, etc.)$kernel->getCacheDir(): for cache that can be written at runtime (e.g. cache pools, session, profiler, etc.)I have probably missed some places or some behavior of Symfony that I don't know. Don't consider this PR perfect, but rather I want to help move things forward :)
TODO: