Php 安装prestashop模块时出现问题:mymodule(类在/…中丢失)
我对prestashop模块开发还不熟悉,但我似乎无法让它正常工作。我一步一步地学习了教程,但是当我安装模块时,我总是得到这样一个“Mymodule(在/modules/Mymodule/test module.php中缺少类)” 我在网上查过,当php文件没有用UTF-8编码而没有BOM时,似乎会发生这个错误,但即使这样做也不起作用 这是我的代码,希望有人能找到问题所在:Php 安装prestashop模块时出现问题:mymodule(类在/…中丢失),php,prestashop,Php,Prestashop,我对prestashop模块开发还不熟悉,但我似乎无法让它正常工作。我一步一步地学习了教程,但是当我安装模块时,我总是得到这样一个“Mymodule(在/modules/Mymodule/test module.php中缺少类)” 我在网上查过,当php文件没有用UTF-8编码而没有BOM时,似乎会发生这个错误,但即使这样做也不起作用 这是我的代码,希望有人能找到问题所在: <?php if (!defined('_PS_VERSION_')) exit; class CookiesPr
<?php
if (!defined('_PS_VERSION_'))
exit;
class CookiesPresta extends Module {
public function __construct() {
$this->name = 'CookiesPresta';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'me myself';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.5');
$this->dependencies = array();
parent::__construct();
$this->displayName = $this->l('Bandeau Cookies');
$this->description = $this->l('Créez et personnalisez votre bandeau d\'information sur les cookies');
$this->confirmUninstall = $this->l('Voulez vous désinstaller le module Bandeau Cookies');
if (!Configuration::get('cookiespresta'))
$this->warning = $this->l('No name provided');
}
public function install() {
if (!parent::install()
|| !$this->registerHook('displayHeader')
|| !$this->registerHook('displayFooter')
)
return false;
return true;
}
public function uninstall() {
if(parent::uninstall())
return false;
return true;
}
}
?>
我建议您使用Prestashop创建一个标准模块如果您的模块作为类名CookiesPresta
您应该命名目录/CookiesPresta
和类文件/CookiesPresta/CookiesPresta.php
这应该是结构:模块/CookiesPresta/
,modules/cookiespresta/cookiespresta.php
,$this->name='cookiespresta'
。注意小写字母和文件名。你遵循这个命名标准吗?我已经这么做了,我想这就是它起作用的原因,也许。或者它也可能是丢失的.xml文件。。。无论如何,谢谢!xml文件仅用于BackOffice中的模块页面,它不会在前端抛出错误。如果这个答案解决了你的问题,你能接受吗?