[contact-form-7 id="24078" title="Feedback EN"]

Featured templates

Joomla 3.x. How to deal with “Fatal error: Cannot redeclare class Mobile_Detect”

This tutorial will show you how to handle the Fatal error: Cannot redeclare class Mobile_Detect in Mobile_Detect.php (), which can show up on your website right after the installation or in your Joomla administration panel.

Joomla 3.x. How to deal with “Fatal error: Cannot redeclare class Mobile_Detect”

  1. One of the following errors may appear on the item page or right after the installation:

    Fatal error: Cannot redeclare class Mobile_Detect in /templates/theme###/includes/mobile_detect.php
    Warning: require_once(\templates\theme####\includes\Mobile_Detect.php): failed to open stream: No such file or directory in /templates/theme####/html/modules.php on line 5
    Fatal error: require_once(): Failed opening required '\templates\theme####\includes\Mobile_Detect.php' (include_path='.:/opt/php54/lib/php') in /templates/theme####/html/modules.php on line 5

    how to deal with Fatal error.1

  2. In order to get rid of the issue, you need to locate modules.php file of your theme in \templates\theme####\html directory via FTP or File manager and replace the code on line 5:

    require_once JPATH_SITE . '\templates\\'.$template.'\includes\Mobile_Detect.php';

    with:

    require_once JPATH_SITE . '/templates/'.$template.'/includes/Mobile_Detect.php';

    how to deal with Fatal error.2

    how to deal with Fatal error.3

  3. Save the changes. There shouldn’t be any issue now.

NOTE: the code may be different in your file, but its correct structure is as listed above.

Feel free to check the detailed video tutorial below:

Joomla 3.x. How to deal with “Fatal error: Cannot redeclare class Mobile_Detect”