如果需要,您可以使用该结构,但请记住以下几点:
您必须将每个用户的目录定义为模块位置:
// application/config/config.php
$config['modules_locations'] = array(
// Absolute path // Relative from default application dir
APPPATH.'modules/userABC/' => '../modules/userABC/',
APPPATH.'modules/userDEF/' => '../modules/userDEF/',
APPPATH.'modules/userGHI/' => '../modules/userGHI/',
// etc.
);
您可能可以动态地执行此操作,但请记住它config.php很早就加载了,因此您可能需要一个pre_system hook。
另一件事,如果您希望所有用户的模块都可以访问,而不管哪个子域处于活动状态,这一点很重要:顺序很重要!
如果 userA 有一个名为“blog”的模块,userB 也有,则只有 userA 的模块会被加载(假设您首先定义了 userA 的模块路径)。如果您确定没有两个模块将共享相同的名称,那么这并不重要,但是您可能会遭受性能损失,因为加载器将遍历整个模块位置堆栈,直到找到请求的位置。
听起来您应该module_location根据加载的用户站点(子域)定义一个。就像是:
// Get this value dynamically (not sure how you need to do it)
$current_user = 'userABC';
$config['modules_locations'] = array(
APPPATH.'modules/'.$current_user.'/' => '../modules/'.$current_user.'/'
);