Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow user to set the project dir #30651
Currently, the project directory is defined by the location of the composer.json file.
That file is not required in production, which therefore breaks the method getProjectDir (who sends back null).
This does not fix the behaviour, but allows the developer to pass the project dir as a parameter.
While this solution does not include BC break or anything, it is important to notice that it includes
Object instantiation in the framework bundle recipe could be updated as follow (in another PR):
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG'], dirname(__DIR__));
Mar 23, 2019
I'm working on the changes needed for this in the docs ... and I wondered why do we need all this logic to calculate the project dir:
Do you consider making the
Well, the drawback of relying on a constructor argument is that it means that each place instantiating the kernel has to know which value to pass it.
Requiring all these places to provide a configuration setting for which you need to pass the same project root looks like a bad experience to me.
To me, a constructor argument here is actually a much worse DX than overriding the method.
referenced this pull request
Mar 27, 2019
This is nice ... because it solves the problem without forcing the user to look for or read any docs. Just read the great exception message, make the changes, and you're done!
While this solution work, it's not as decent from a software engineering point of view, as it's again hiding the setting somewhere rather than forcing the developer who calls it to think where it's root his.
Works for most symfony standard setup though, could be tricky if people do change the setup without understanding fully how things work.
Well it feels more logical to me to put it in the
It's true if you define it in the