-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ErrorHandler] Add a command to dump static error pages #58769
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
2ce43b0
to
79cfa6e
Compare
src/Symfony/Bundle/FrameworkBundle/Tests/Error/PagesDumperTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Tests/Error/PagesDumperTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Command/ErrorDumpPagesCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
d6d7401
to
0fc7ceb
Compare
I have just moved the command in the Twig bundle, applied most of the review suggestions (and mark them as resolved) and answered to the remaining ones. I don't understand the psalm failure as the arrayNode method of the configuration is used elsewhere without issue. Did I miss something? |
62cd182
to
49aa562
Compare
I guess it can be ignored, Psalm does not know the exact type of the "rootNode" here.. and so type it as ParentNode|ArrayDefinition 🤷♂️ |
49aa562
to
ee919cc
Compare
The Psalm baseline seems to be build automatically so not sure if I have something to do on my side to "ignore" this error? -- Meanwhile I fixed latest review comments. Is there anything I can do to move forward with PR? 🙂 Thanks |
If we use semantic configuration to configure this command, we have to add a test in https://github.com/symfony/symfony/blob/7.3/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php FYI, we'll also have to update https://github.com/symfony/symfony/blob/7.3/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd. |
Is it linked to a missing The configuration will be: private function addErrorDumperSection(ArrayNodeDefinition $rootNode): void
{
$rootNode
->children()
->arrayNode('error_dumper')
->addDefaultsIfNotSet()
->children()
->scalarNode('path')
->info('The directory where error pages will be dumped.')
->defaultValue('%kernel.build_dir%/error_pages')
->end()
->arrayNode('status_codes')
->info('The error status codes to dump. By default, all 4xx and 5xx status codes will be dumped.')
->defaultValue([])
->integerPrototype()->end()
->end()
->end()
->end()
->end()
;
} |
ee919cc
to
8b04176
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.
Thanks 👍🏼
src/Symfony/Component/ErrorHandler/Command/ErrorDumpCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/ErrorHandler/Command/ErrorDumpCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/ErrorHandler/Command/ErrorDumpCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/ErrorHandler/Command/ErrorDumpCommand.php
Outdated
Show resolved
Hide resolved
afe2a22
to
c82e0f4
Compare
src/Symfony/Component/ErrorHandler/Command/ErrorDumpCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/ErrorHandler/Tests/Command/ErrorDumpCommandTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/ErrorHandler/Tests/Command/ErrorDumpCommandTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/ErrorHandler/Tests/Command/ErrorDumpCommandTest.php
Outdated
Show resolved
Hide resolved
6b9e6fe
to
37899b7
Compare
You can ignore it then. |
src/Symfony/Component/ErrorHandler/Command/ErrorDumpCommand.php
Outdated
Show resolved
Hide resolved
d1a8c60
to
b161e14
Compare
Thank you @pyrech. |
This PR was merged into the 7.3 branch. Discussion ---------- Add documentation for `error:dump` command <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `7.x` for features of unreleased versions). --> Fix #20704 PR introducing the command: symfony/symfony#58769 Commits ------- d976d0e Add documentation for error:dump command
When a web server cannot handle a request or trigger an error without calling the PHP application, it will return instead its default error pages, ignoring completly the error templates defined by the application (Symfony's default "Oops" error page or overriden one in user's app).
Take for example the case of the simple
/%
url : it will trigger an error on almost all web servers (nginx, apache, cloudflare, etc):In all these cases, web servers returned their default error page.
To avoid that, in some of our projects, we created a Symfony command to dump the application error pages in static HTML files that the web server can render when it encounters an internal error. The idea is to dump these pages at deploy time so there is nothing else to do at runtime.
Here is a sample on how we configured our nginx to use our beautiful error pages:
(Kudos to @xavierlacot for all the hard work and researches on this topic 💛)
We propose to add this command directly to Symfony so everybody can make use of it.
Usage