Skip to content

[FrameworkBundle] Split "var/build" from "var/cache" when compiling for the "prod" env #57556

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* Derivate `kernel.secret` from the decryption secret when its env var is not defined
* Make the `config/` directory optional in `MicroKernelTrait`, add support for service arguments in the
invokable Kernel class, and register `FrameworkBundle` by default when the `bundles.php` file is missing
* Split "var/build" from "var/cache" when compiling for the "prod" env

7.1
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader as ContainerPhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\Loader\PhpFileLoader as RoutingPhpFileLoader;
use Symfony\Component\Routing\RouteCollection;
Expand Down Expand Up @@ -120,6 +121,9 @@ public function getBuildDir(): string
if (isset($_SERVER['APP_BUILD_DIR'])) {
return $_SERVER['APP_BUILD_DIR'].'/'.$this->environment;
}
if ('prod' === $this->getEnvironment() && Kernel::class === (new \ReflectionMethod(parent::class, 'getCacheDir'))->class) {
return $this->getProjectDir().'/var/build/'.$this->environment;
}
Comment on lines +124 to +126
Copy link
Contributor

@ro0NL ro0NL Jun 27, 2024

Choose a reason for hiding this comment

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

it feels a bit dirty ... what about a new (temporary?) configuration env? to be used upstream:

// Returns $this->getCacheDir() for backward compatibility
return $this->getCacheDir();

which brings me to; can we get rid of the parent calls in a trait, by making the envs defacto config envs

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand your proposal sorry (nor its "why"). Please expand if you want.

Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. APP_USE_BUILD_DIR=1 so we dont hardcode the prod env and rely on reflection

also im wondering handling the APP_ envs like APP_CACHE_DIR can be dealt with in Kernel as a firt clas feature

Copy link
Member Author

Choose a reason for hiding this comment

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

An alternative implementation might be to define APP_BUILD_DIR in .env.prod in a recipe.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 i tend to prefer a pure configuration solution

but isnt the bigger goal to eventually swap the current implementation?

public function getBuildDir(): string
{
// Returns $this->getCacheDir() for backward compatibility
return $this->getCacheDir();
}


return parent::getBuildDir();
}
Expand Down
Loading