-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Best way to override ServerRunCommand and ServerStartCommand? #20429
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
@pocky Hello, If you don't want to pass this option each time, here is a quick way to do it: <?php
namespace AppBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ServerRunCommand as BaseServerRunCommand;
class ServerRunCommand extends BaseServerRunCommand
{
protected function configure()
{
parent::configure();
$this->getDefinition()->getOption('docroot')->setDefault('your/custom/docroot');
}
} Like this, calling I may miss something but in my opinion having the |
@chalasr Correct! ;) But if I want to share my AppBundle with you (and your symfony-standard), this change will broke your |
Since the need is quite specific to your structure, you could register the command as a service and have the command in a place that cannot be published/reused (e.g. in |
…ntainer (chalasr) This PR was merged into the 3.3-dev branch. Discussion ---------- [WebServerBundle] Decouple server commands from the container | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20429 | License | MIT | Doc PR | maybe This removes the need for injecting the container in the new `server:*` commands, registering them as services when used in the framework and thus making them even more discoverable and extensible. It would then be easy to reconsider extracting them in a `WebServer` component instead of having a bundle only. IMHO it would make sense to use these commands outside of the framework. If the idea can be considered I'll add some tests at least ensuring that these commands are bootstrap-able. This must be done before that they are covered by the BC promise (3.3). Commits ------- 2e63025 [WebServerBundle] Decouple server:* commands from the container
Hello,
I am using a non-standard folder structure and I just discovered a "problem" with
server:run
andserver:start
(for me it's a DX) :For my distribution, the
$documentRoot
should be :$this->getContainer()->getParameter('kernel.root_dir').'/../../web'
I don't want to tell to each dev wich using my distribution to add the --docroot option (or using an alias via composer scripts/make) so I'm looking to the best way to change this.
Solutions :
1- ServerRunCommand and ServerStartCommand should be used as services to allow overriding
2- Add a getDocumentRoot option in Kernel and use the parameter instead of relative path (simpler)
3- Create a symfony/server-bundle with all related server commands as dependency of framework-bundle
What's your opinion?
The text was updated successfully, but these errors were encountered: