In our last article, we have discussed how to enable content versioning in Joomla. And today we are going to learn how to enable Debug and error reporting in Joomla 4.
Debug in Joomla 4 is very powerful and important when it comes to figuring out what’s going on with blank pages and or other errors within your Joomla site.
Here is our default Joomla screen.
I am going to create an error in one of the Joomla files and we will use the debug and error reporting to navigate and fix through the error.
To create an error. I am going to open up the index.php file and write anything down that’s isn’t valid PHP code.
After saving the file, if I try visiting the frontend of the website, we should see the blank page:
Let’s go ahead and enable error reporting real quick and we should start seeing our errors here:
To enable error reporting: Navigate to System >> Global Configuration.
Inside the Global Configuration screen, click the Server tab. And then change error reporting to Maximum (your current value might be System Default or none).
Once done, hit Save.
Now go back and refresh the frontend and you should see an error similar to the one below.
This is very useful for PHP fatal errors where Joomla isn’t able to run at all and you have to fix beforehand in order to even see the Joomla screen working.
Sometimes, you may start experiencing blank or broken pages after installing an extension or upgrading/downgrading PHP version on your server or some similar change, to debug errors like those the Joomla debug would be very very useful.
To create an error like that, I am going to modify the file templates/cassiopeia/index.php.
I am going the following one from
use Joomla\CMS\Factory;
To
use Joomla\CMS\Factory1;
This is just a very small change that calls for a Library that doesn’t exist (just like your outdated extension might be calling for depreciated or removed Joomla code).
Now, immediately after making this change, If I go ahead and refresh the homepage of my website, I can see the following error screen:
You can see Joomla notifying an error but not much info about where the error is appearing from, this can be very frustrating when working with extensions, where they have hundreds of files but we don’t see an exact location of the file that is causing the error.
The debug in Joomla is very useful at this point.
Go ahead and enable the debug using the System >> Global Configuration >> System tab.
Hit Save refresh the frontend.
You will see a whole trace log of the file that is causing the error and how Joomla got to that file.
You can now go to the exact file and add your fix. That’s it, debug and error reporting can be very useful when it comes to debugging blank pages or other Joomla errors.