Creating custom error page in Symfony 2.5 - php

I am working with Symfony 2.5.3 and I am trying to create the custom error page so for example if someone lands on a page or try to access a page that does not exist the 404 error message should appear within the theme of the site.
I understand that default 404 error page sits inside the TwigBundle that comes with symfony and looking at some other answers on this site people are suggesting that in order to have the custom error page I need to copy them in directory ROOT app/Resources/TwigBundle/views/Exception so I copied over the error.html.twig and even created error404.html.twig but this does not work. I also looked into this solution but still no luck.
I tried to access my development site via http://127.0.0.1:8000/app.php/services to check may be in production i will see the correct template but I dont, please note that i have cleared the cache before accessing http://127.0.0.1:8000/app.php/services and I still see the default error template that comes with Symfony
I will really appreciate any help on this.

First double check this :
Check if you're custom error template is in app/Resources/TwigBundle/views/Exception folder
Then double check the name of you're custom error template if it is error.html.twig OR/AND error404.html.twig
Then create the custom error/template that you want users to see
You can see the custom error/page when you view the website via app.php which is a production environment.
Beetween each check
rm -rf app/cache/*
It should works now ;)
Another way to easily test your custom error template in dev mode is to use instead WebfactoryExceptionsBundle who provide a test controller for displaying your custom error page even when kernel.debug is set to true.

Related

Drupal custom theme info.yml files crashes site

I am exploring custom theming in Drupal 9. I'm using MAMP and a fresh local install of Drupal. I cannot find a solution online for the following problem.
I created contrib and custom folders in themes/. I can put themes in the contrib folder and they appear in admin/appearance. So far, correct behavior. In custom, I made test/test.info.yml. This is the code:
name: Test
type: theme
description: 'Test theme'
core_version_requirement: ^8 || ^9
That's it. Everything online says those are the basic required keys.
When I go back to admin/appearance, the site crashes with error "The website encountered an unexpected error. Please try again later." Console shows "GET http://localhost:8888/admin/appearance 500 (500 Service unavailable (with message))"
As soon as I delete test.info.yml and refresh the browser, admin/appearance reappears. Even putting the test folder into contrib causes it to crash. I also moved a contrib module into custom, and it appeared as long as there was no test.info.yml file anywhere.
MAMP's php error log showed the following: "Uncaught PHP Exception Drupal\Core\Extension\InfoParserException: "Missing required key ("base theme") in themes/custom/test/test.info.yml"
Once I added a base theme, the theme appeared in admin/appearance.
Everything I've read says those four lines are the only thing required in a theme info.yml file. So why am I getting this error? I want to understand.
The base theme property in theme .info.yml files is now required.
Here is a link to the change record

How to change default twig error templates in Symfony 4?

I am building an app using Symfony 4.4. I am trying to render custom 404 error page. I followed the documentation and created error.html.twig and error404.html.twig files in templates/bundles/TwigBundle/Exception. However I still get the 'Oops! An Error Occurred' with code 500 page that is by default from symfony.
Can someone point what can have I done wrong?
In dev mode I see that the app throws NotFoundHttpException but in prod mode I always get the page with code 500 even if I visit an undefined route.
This is what I get when I visit an undefiend route:
500 error
You can use the built-in Twig error renderer to override the default error templates. Both the TwigBundle and TwigBridge need to be installed for this
When the error page loads, Symfony\Bridge\Twig\ErrorRenderer\TwigErrorRenderer is used to render a Twig template to show the user.
This renderer uses the HTTP status code and the following logic to determine the template filename:
Look for a template for the given status code (like error500.html.twig);
If the previous template doesn’t exist, discard the status code and look for a generic error template (error.html.twig).
To override these templates, rely on the standard Symfony method for overriding templates that live inside a bundle and put them in the templates/bundles/TwigBundle/Exception/ directory.

404 route not found exception handling in symfony

I want to create a template for page not found. whenever 404 no route found exception is throwing need to redirect to page. As that is not in proper UI way. I tried steps from this URL
https://symfony.com/doc/current/controller/error_pages.html
I am new to symfony . followed steps until service.yml and created customExceptionController.php and I dont know what to do next step and I am getting error like
How to fix this issue.Please anyone help me to get out of this issue. Thanks in advance
In the dev environment, you will always see the default exception page which is meant to ease debugging issues. If you want to see how a certain error page looks like in the prod environment (because you maybe created a custom template for it), you need to access a special URL that is only available for this purpose in the dev enviromnent (see https://symfony.com/doc/current/controller/error_pages.html#testing-error-pages-during-development). In your case, this URL is http://127.0.0.1:8000/_error/404

How to edit the view of "The page has expired due to inactivity" in Laravel 5.5

In Laravel 5.5, When you are using CSRF protection (by default) and you send a post request after long inactivity you'll get this error page (Screenshot).
I'm ok with this error however, I need to change the view/text of this error to match my application style and my language for sure.
Any Ideas in how to edit this view?
You can override the default view by placing a 419.blade.php file in the resources/views/errors folder.
If you're using an editor with global search capabilities, you can search for the error message inside your project. For example, in Visual Studio Code you can press Ctrl + Shift + F to search inside the project.
I use it all the time to find the files which are part of the framework that I need to customize.
More on overriding the error views in this section of the official docs.
You can override the default view by placing a 419.blade.php file in the resources/views/errors folder.

magento 1.9 signup form

I have been cracking my head about this for two days on. I inherited some magento 1.9 Multi vendor website and just need to bolden some text on the customer create account field. I have searched every where in my template directory Customer/form/register.phtml and Persitent/form/register.phtml yet I am not successfully able to identify the line that prints
'wants to become a vendor?'
Here is a link to the form please.
http://store.min-trade.com/index.php/customer/account/create/
Could someone point me in the right direction. I pretty much understand the project structure of Magento I do believe. Please help!
Are you sure you are looking in the correct template folder?
You are using the rwd/default template, so have a look here;
app/design/frontend/rwd/default/template/persistent/customer/form/register.phtml
If there isn't a file called register.phtml in that location, then Magento will fall back to the base folder, so try;
app/design/frontend/base/default/template/persistent/customer/form/register.phtml
If you still cannot find the text, it could be a custom login form using another template. Login to your server with ssh/putty and run this command;
grep -nr 'Wants to become a Vendor?' /path/to/magento/*
Just make sure you set the correct path.
You can easily check by enabling path hints from magento admin.
If you dont know how to enable file path hint then refer this link enter link description here
second thing that if you have installed any vendor extension then register form will be displayed from that module.
You can also install this path hint module for check file.

Categories