-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Proposing Flex-specific error messages in the controller shortcuts #25133
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
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.
Really nice!
@@ -326,7 +326,7 @@ protected function createFormBuilder($data = null, array $options = array()): Fo | |||
protected function getDoctrine(): ManagerRegistry | |||
{ | |||
if (!$this->container->has('doctrine')) { | |||
throw new \LogicException('The DoctrineBundle is not registered in your application.'); | |||
throw new \LogicException('The DoctrineBundle is not registered in your application. Try running "composer require orm"'); |
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.
I'd change this one. The error message mentions something about "DoctrineBundle", but then it tells you to install a strange "orm" thing. Could we change it to Try running "composer require doctrine"
?
@@ -372,7 +372,7 @@ protected function getUser() | |||
protected function isCsrfTokenValid(string $id, string $token): bool | |||
{ | |||
if (!$this->container->has('security.csrf.token_manager')) { | |||
throw new \LogicException('CSRF protection is not enabled in your application.'); | |||
throw new \LogicException('CSRF protection is not enabled in your application. Enable it with the "csrf_protection" key in "config/packages/framework.yaml"'); |
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.
Flex should be auto-enabling it when requiring the security-csrf
package, no ? If yes, the right advice is to require it too
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.
That seems logical to me, bit I actually don't think it's enabled by default. It looks like it's always disabled unless you explicitly enable it: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php#L107-L116
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.
😢 why making FrameworkBundle auto-enable all components except one ?
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.
Looks like something we need to fix.
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.
Anybody willing to submit a PR on that one? Would be cool to have it for 3.4/4.0 before final.
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.
8bbf48d
to
d377b15
Compare
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.
Nice idea.
@@ -372,7 +372,7 @@ protected function getUser() | |||
protected function isCsrfTokenValid(string $id, string $token): bool | |||
{ | |||
if (!$this->container->has('security.csrf.token_manager')) { | |||
throw new \LogicException('CSRF protection is not enabled in your application.'); | |||
throw new \LogicException('CSRF protection is not enabled in your application. Enable it with the "csrf_protection" key in "config/packages/framework.yaml"'); |
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.
Enable them in config/packages/framework.yaml.
vs. Enable it with the "csrf_protection" key in "config/packages/framework.yaml"
always be specific/generic?
Thank you @weaverryan. |
… shortcuts (weaverryan) This PR was merged into the 4.1-dev branch. Discussion ---------- Proposing Flex-specific error messages in the controller shortcuts | Q | A | ------------- | --- | Branch? | 4.0 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | not needed This is to help discoverability when you try to use a feature that's not installed. It's opinionated about Flex being installed, which is why this is done on 4.0. Two of the options relate to configuration. An alternative (if we don't like the short description) is to include a link instead (which could be some short URL - e.g. `http://symfony.com/docs/sessions` would be pretty cool). Commits ------- d377b15 Proposing Flex-specific error messages in the controller shortcuts
This change is not present on the 4.0 branch. Backport needed? |
Oh, maybe! If so, can you create a PR? |
Sure #25636 |
…tcuts to 3.4 (weaverryan) This PR was merged into the 3.4 branch. Discussion ---------- Backport Flex-specific error messages in controller shortcuts to 3.4 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25133 (comment) | License | MIT | Doc PR | n/a Commits ------- 419e934 Proposing Flex-specific error messages in the controller shortcuts
…tcuts to 3.4 (weaverryan) This PR was merged into the 3.4 branch. Discussion ---------- Backport Flex-specific error messages in controller shortcuts to 3.4 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#25133 (comment) | License | MIT | Doc PR | n/a Commits ------- 419e93465f Proposing Flex-specific error messages in the controller shortcuts
This is to help discoverability when you try to use a feature that's not installed. It's opinionated about Flex being installed, which is why this is done on 4.0.
Two of the options relate to configuration. An alternative (if we don't like the short description) is to include a link instead (which could be some short URL - e.g.
http://symfony.com/docs/sessions
would be pretty cool).