How to Enable Debug and Error Reporting in Joomla 4 and What Does it do?

Joomla Views: 1186 Added Date: September 05, 2018 joomdev Like
Joomla News: How to Enable Debug and Error Reporting in Joomla 4 and What Does it do?

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.

Default Joomla 4 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.

Adding Invalid PHP Code

After saving the file, if I try visiting the frontend of the website, we should see the blank page:

Blank Joomla 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

Joomla 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).

 

Joomla Server Setting

Once done, hit Save.

Now go back and refresh the frontend and you should see an error similar to the one below.

Broken Joomla Page with Errors

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:

 

Joomla 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.

 

Enable Debug settings

 

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.

Joomla Debug and Error Reporting

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.

This Joomla 4 tutorial originally appeared on www.joomdev.com

Visit Joomdev for more Joomla tutorials and tips. 

 

 

 

 

 


Reviews (0):

Rate this: 
Send