Jump to content

Fatal error: Uncaught Error: Class 'WHMCS\Module\Addon\AddonModule\Admin\AdminDispatcher' not foun


wtools

Recommended Posts

I was trying to do an addon, in the addon php file, i used AdminDispatcher class as

use WHMCS\Module\Addon\AddonModule\Admin\AdminDispatcher;

 

And then tried to call functions of that class. But getting an error like
Fatal error: Uncaught Error: Class 'WHMCS\Module\Addon\AddonModule\Admin\AdminDispatcher' not found

 

I was able to fix it by adding

require_once __DIR__ . '/lib/Admin/AdminDispatcher.php';

 

But this class file won't be auto loaded?  What settings have to do for the autoload?

 

Link to comment
Share on other sites

  • 3 years later...

Hi,

I have the same issue , I have resolved it with the following steps.

  1. I have downloaded a sample addon module code from https://github.com/WHMCS/sample-addon-module
  2. Then i go to WHMCS FTP > addons > modules > make a new folder with the name zain_addon_module. (Please note that module name only contains letters or numbers with underscores).
  3. I have copied the folders named lang, lib, templates and files hooks,php, whmcs.json, and addon_module.php (i have rename this file to zain_addon_module.php  which is the name of my module.)
  4. In zain_addon_module.php file i have called AdminDispatcher and ClientDispatcher file as

    use WHMCS\Module\Addon\ZainAddonModule\Admin\AdminDispatcher;
    use WHMCS\Module\Addon\ZainAddonModule\Client\ClientDispatcher;


    Please note that every starting letter of module name is capital and without any underscore. 
  5. Then i go to lib > Admin > AdminDispatcher.php file and update namespace as namespace WHMCS\Module\Addon\ZainAddonModule\Admin;
  6. Then i go to lib > Admin > Controller.php file and update namespace as namespace WHMCS\Module\Addon\ZainAddonModule\Admin;
    please note that ZainAddonModule is my module name without underscores.
  7. You can do the same thing for ClientDispatcher files also.
  8. That's it an issue resolved!!

thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated