I am using Symfony 3.1. I did follow below url for implementing the custom error page template.
(http://symfony.com/doc/current/controller/error_pages.html#custom-exception-controller).
I creates all files under the same location:
app/
└─ Resources/
└─ TwigBundle/
└─ views/
└─ Exception/
├─ error404.html.twig
├─ error403.html.twig
├─ error.html.twig # All other HTML errors (including 500)
├─ error404.json.twig
├─ error403.json.twig
└─ error.json.twig # All other JSON errors (including 500)
I did create a bundle with name "TwigBundle" and create controller folder and class with name "TwigBundle\Controller\ExceptionController.php"
Config.yml
Twig Configuration
twig:
exception_controller: TwigBundle:ExceptionController:showException
error.html.twig
<h1>Page not found</h1>
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
{# ... #}
{% endif %}
<p>
The requested page couldn't be located. Checkout for any URL
misspelling or <a href="{{ path('homepage') }}">return to the homepage</a>.
</p>
In case you need them, the Ex
i am getting following error message:
Fatal error: Uncaught exception 'Symfony\Component\Routing\Exception\ResourceNotFoundException' in D:\xampp\htdocs\PROJECT_NAME\var\cache\prod\appProdUrlMatcher.php:922 Stack trace: #0 D:\xampp\htdocs\PROJECT_NAME\var\cache\prod\classes.php(1744): appProdUrlMatcher->match('/jkhjjkohuioioi...') #1 D:\xampp\htdocs\PROJECT_NAME\var\cache\prod\classes.php(1613): Symfony\Component\Routing\Matcher\UrlMatcher->matchRequest(Object(Symfony\Component\HttpFoundation\Request)) #2 D:\xampp\htdocs\PROJECT_NAME\var\cache\prod\classes.php(2758): Symfony\Component\Routing\Router->matchRequest(Object(Symfony\Component\HttpFoundation\Request)) #3 [internal function]: Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher)) #4 D:\xampp\htdocs\PROJECT_NAME\vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\Debug\WrappedListener.php(61): call_user_func(Array, Object(Symfony\Component\HttpKernel\ in D:\xampp\htdocs\PROJECT_NAME\var\cache\prod\classes.php on line 3328
I have clear the cache and system is running in Prod ENV. But still i am not getting custom error template.
@TwigBundle/Resources/config/routing/errors.xml
into your dev routing file? You do not need to rewrite default exception controller. – Stephan Yamilov