Skip to content

Conversation

@alexander-schranz
Copy link
Contributor

@alexander-schranz alexander-schranz commented Oct 31, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? no
Deprecations? no
Issues Fix #...
License MIT

If I work on a Sulu project its common sometimes to debug things that I switch between dev, stage (sulu specific), prod envs. And if we put our storage and indexes directory into %kernel.share_dir% that path should not include the %kernel.environment%.

So uploads and search index in sulu are stored in var/share/storage and var/share/indexes, not including the current ENV.

With the change in #62204 it make possible to know that and only add %kernel.environment% to the caches where its relevant. But we could still use %kernel.share_dir%/storage in the cloud template here:
symfonycorp/cloud-templates#43 (comment)

So what changed:

Before:

 - var/share
    - dev
       - pools
       - http_cache
       - indexes
       - storage
    - stage
       - pools
       - http_cache
       - indexes
       - storage
    - prod
       - pools
       - http_cache
       - indexes
       - storage

Now:

 - var/share
    - app_cache
       - dev
       - stage
       - prod
    - http_cache
       - dev
       - stage
       - prod
    - indexes (none env dir)
    - storage (none env dir)

This should not as in #62187 break something as with #62204 we now know if there is kernel.share_dir configured or not.

@carsonbot
Copy link

Hey!

To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done?

Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review.

Cheers!

Carsonbot

@alexander-schranz alexander-schranz marked this pull request as ready for review October 31, 2025 11:16
@carsonbot carsonbot added this to the 7.4 milestone Oct 31, 2025
@carsonbot carsonbot changed the title Exclude Env from Share dir Parameter Exclude Env from Share dir Parameter Oct 31, 2025
@nicolas-grekas
Copy link
Member

Can you please remove everything from #62249 so that we can have only the patch about your proposal?

@alexander-schranz alexander-schranz force-pushed the enhancement/exclude-env-from-share-dir-parameter branch from c841415 to e7d402d Compare October 31, 2025 11:43
@alexander-schranz
Copy link
Contributor Author

@nicolas-grekas done!

@alexander-schranz
Copy link
Contributor Author

Okay I was thinking that in 7.4 we never define now kernel.share_dir aslong APP_SHARE_DIR is not defined.

But as you stated thats not the case its always there now.
#62204 (comment)
But can be removed via APP_SHARE_DIR=false, if I understand correctly?

As we still fallback to getCacheDir? Which I had expected would not longer be the case my suggestion, won't work or would require lot of more magic logic, so I'm lost.

I personally would have make the share dir opt-in and defined it in the recipe. That would also make bundles automatically fail as the share dir is then not defined automatically for all bundles running tests against the Kernel.php. Was thinking that was what @Seldaek suggested. I think this way we maybe run into issue that bundles use %kernel.share_dir% and so make problems in multi region setups @Seldaek mentioned.

@nicolas-grekas
Copy link
Member

be removed via APP_SHARE_DIR=false, if I understand correctly? As we still fallback to getCacheDir ?

Yes, then No, see https://github.com/symfony/symfony/pull/62204/files#diff-ee9b2c16aec8aa80f67e6b3925791d7b092fc097651bcc2df21b70e7dc8bef12R130

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would work for me. I don't have a strong opinion on the topic. What do others think?

@nicolas-grekas nicolas-grekas added the ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" label Oct 31, 2025
@stof
Copy link
Member

stof commented Oct 31, 2025

@alexander-schranz we want the cache.app pools to have a working configuration by default in a new project. That's why the default is not to have no share directory (locally, any directory is shared among your single running server by definition). And we cannot make cache.app default to a Redis storage to avoid using the share dir.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me

Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
@carsonbot carsonbot changed the title Exclude Env from Share dir Parameter [HttpKernel] Exclude Env from Share dir Parameter Oct 31, 2025
@alexander-schranz alexander-schranz changed the title [HttpKernel] Exclude Env from Share dir Parameter [HttpKernel] Restructure Share Dir for using kernel.share_dir without env variable Oct 31, 2025
Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
@alexander-schranz alexander-schranz changed the title [HttpKernel] Restructure Share Dir for using kernel.share_dir without env variable [HttpKernel] Restructure Share Dir for using kernel.share_dir without environment specific directory Oct 31, 2025
@alexander-schranz
Copy link
Contributor Author

@stof Understand make sense. Then its definitly good choice to use kernel.share_dir for our storage and indexes. As the rule also make sense there if you multi region like for caches using redis, you want for indexes use Elasticsearch and for file storage a S3 or similar.

@nicolas-grekas
Copy link
Member

Alternative thought:

it might be safer to have per-env by default
this doesn't prevent use cases that need to be env-less: those could use %kernel.share_dir%/../storage for example

@alexander-schranz
Copy link
Contributor Author

@nicolas-grekas that would end in the strange directory we had before in the discussion:

 - var/share
    - dev
       - app_cache
       - http_cache
    - indexes (none env dir)
    - prod
       - app_cache
       - http_cache
    - stage
       - app_cache
       - http_cache
    - storage (none env dir)

@nicolas-grekas
Copy link
Member

Yes of course. However, I don't see this as "strange" :)
Having share split per env by default might be safer.

@alexander-schranz
Copy link
Contributor Author

alexander-schranz commented Nov 3, 2025

Okay, you need to maintain it if you see it as safer I understand it, we will discuss it what we do on our side in @sulu if we maybe keep our own parameters and directories, as %kernel.share_dir%/../ is to unsafe for my point of view.

But one question will Symfony Cloud also keep the APP_ENV in mind when set the new APP_SHARE_DIR? So its APP_SHARE_DIR = var/share/{$APP_ENV}?

@nicolas-grekas
Copy link
Member

APP_SHARE_DIR = var/share/{$APP_ENV}?

The env var won't contain the env since it's the responsibility of the kernel to add it when desired - that's only a default when using MicroKernelTrait.

@alexander-schranz
Copy link
Contributor Author

@nicolas-grekas okay Thx, that would atleast avoid us using the %kernel.share_dir%/../storage and we could go with %env(APP_SHARE_DIR)%/storage if we decide to go with var/share.

@alexander-schranz alexander-schranz deleted the enhancement/exclude-env-from-share-dir-parameter branch November 3, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HttpKernel ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" Status: Reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants