Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Class 'WHMCS\Module\Addon\AddonModule\Admin\AdminDispatcher' not found #5

Open
nh314 opened this issue May 30, 2017 · 9 comments

Comments

@nh314
Copy link

nh314 commented May 30, 2017

Hello, i try to test Sample Addon Module and meet this problem in my online server,
but in localhost, everything is ok.
How can i fix this problem.
Fatal error: Class 'WHMCS\Module\Addon\AddonModule\Admin\AdminDispatcher' not found in .../modules/addons/addonmodule/addonmodule.php on line 222

This is my server information

OS

Distributor ID: CentOS
Description: CentOS release 6.7 (Final)
Release: 6.7
Codename: Final

Apache

Server version: Apache/2.4.17 (Unix)
Server built: Oct 18 2015 11:30:27

MySQL

Server version: 5.5.31 MySQL Community Server (GPL)

PHP

PHP 5.6.29 (cli) (built: Dec 9 2016 12:10:23)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v6.0.7, Copyright (c) 2002-2016, by ionCube Ltd.

@stevepapas
Copy link

Hi,

In the lib folder, you need to rename the namespaces in all the files.

namespace WHMCS\Module\Addon\AddonModule\Client;

AddonModule needs to be renamed to the same as the addon folder you have created.

@idotnetdev
Copy link

Hi,
I renamed the files to same folder but still i get the error:
Fatal error: Class 'WHMCS\Module\Addon\AddonModule\Admin\AdminDispatcher' not found in C:\xampp\htdocs\whmcs\modules\addons\addonmodule\addonmodule.php on line 222

I installed whmcs on Xampp.

@stevepapas
Copy link

Hi DS,

In addonmodule.php,
has addonmodule in the following lines been renamed to the same as the folder directory?

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

@idotnetdev
Copy link

Yes, I renamed that names but has errors not found class.

@professorhaseeb
Copy link

its because the lib files are not being loaded in the module. @liumapp 's proposed PR is the solution.
see: 88335d5

@playmono
Copy link

playmono commented Oct 21, 2020

This is issue could be resolved if you change all your classes like:

-WHMCS\Module\Addon\AddonModule\Admin\AdminDispatcher
+WHMCS\Module\Addon\Addonmodule\Admin\AdminDispatcher

or you change the module path like:

-/modules/addons/addonmodule/addonmodule.php
+/modules/addons/addon_module/addonmodule.php

Note that capital letters are matching the first letter after underscore. Check how works this example: https://docs.whmcs.com/Module_Class_Autoloading

playmono referenced this issue Oct 21, 2020
In whmcs v7.1.2 , addonmodule.php on line 222 can't found class AdminDispatcher  , and here is the solution , for more detail , plz contact me
@SajadFahimian
Copy link

I also encountered this problem while playing with the sample code of the addon module.
in addonmodule.php add this line in top:

require_once("lib/Admin/AdminDispatcher.php");

and in AdminDispatcher.php after namespace :

require_once("Controller.php");

@quitam
Copy link

quitam commented Jul 30, 2024

You can use vendor/autoload.php, and use namespace for all class in lib directory

@eugenefvdm
Copy link

Yep the documentation in the demo module is clear:

/**
 * Require any libraries needed for the module to function.
 * require_once __DIR__ . '/path/to/library/loader.php';
 *
 * Also, perform any initialization required by the service's library.
 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants