Symfony2 : customize error pages for different bundles

前端 未结 2 2025
别跟我提以往
别跟我提以往 2021-02-04 08:48

I have several bundles and I\'d like to know if it is possible to customize for each bundle their own error pages.

I read the cookbook and the examples

2条回答
  •  遥遥无期
    2021-02-04 09:41

    There's a bundle i've made for catch different errors pages from routes regex configuration, it works from the "kernel.exception_listener" listener and the "kernel.exception" event as described in documentation (http://symfony.com/doc/current/cookbook/controller/error_pages.html#use-kernel-exception-event).

    With this bundle, you can:

    • Change the twig exception template from regex of the route you want
    • Change the twig exception template for certains http status code only
    • Enable / Disable the custom template for the debug mode

    Link to the bundle (MIT licence): https://github.com/Kwrz/TwigException

    Thanks for your idea Peter, I think add a feature in the next version of my bundle to define the template from the corresponding bundle namespace.

提交回复
热议问题