Estoy desarrollando un módulo de Prestashop con XAMPP (3.2.2, puerto 8080), NetBeans (8.2) y XDebug (2.5.5, incluido en XAMPP). El problema es que no se detiene en el punto de interrupción que establezco en el módulo.
He hecho una pequeña web en PHP (no Prestashop) para probar si se puede depurar y efectivamente se detiene en los puntos de interrupción.
Si configuro en NetBeans la opción "Stop at First Line" a True la depuración se detiene en index.php
y puedo depurar línea a línea con F7 en Prestashop. Pero no pasa por el módulo.
Esta es la configuración en php.ini
para XDebug en XAMPP:
[XDebug]
zend_extension="C:\xampp\php\ext\php_xdebug.dll"
xdebug.idekey=netbeans-xdebug
xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:\xampp\tmp"
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_log="C:\xampp\php\logs\xdebug_error_log"
xdebug.remote_port=9000
El log de XDebug no muestra errores e indica que se ha establecido el punto de interrupción:
<- breakpoint_set -i 4468 -t line -s enabled -f file:///C:/xampp/htdocs/prestashop_1_6_1_17/admin/modules/mymodule/mymodule.php -n 218
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4468" state="enabled" id="119560449"></response>
Este es código fuente (extraído de: http://doc.prestashop.com/display/PS16/Creating+a+first+module)
if (!defined('_PS_VERSION_')) {
exit;
}
class MyModule extends Module
{
public function __construct()
{
$this->name = 'mymodule';
$this->tab = 'shipping_logistics';
$this->version = '0.0.1';
$this->author = 'Oliver';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('My module');
$this->description = $this->l('Description of my module.');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
if (!Configuration::get('MYMODULE_NAME')) {
$this->warning = $this->l('No name provided');
}
}
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
if (!parent::install() ||
!$this->registerHook('leftColumn') ||
!$this->registerHook('header') ||
!Configuration::updateValue('MYMODULE_NAME', 'my module')
) {
return false;
}
return true;
}
public function uninstall()
{
if (!parent::uninstall() ||
!Configuration::deleteByName('MYMODULE_NAME')
) {
return false;
}
return true;
}
public function getContent()
{
$output = null;
if (Tools::isSubmit('submit'.$this->name)) {
$my_module_name = strval(Tools::getValue('MYMODULE_NAME'));
if (!$my_module_name
|| empty($my_module_name)
|| !Validate::isGenericName($my_module_name))
$output .= $this->displayError($this->l('Invalid Configuration value'));
else {
Configuration::updateValue('MYMODULE_NAME', $my_module_name);
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
}
return $output.$this->displayForm();
}
public function displayForm()
{
// Get default language
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
// Init Fields form array
$fields_form[0]['form'] = array(
'legend' => array(
'title' => $this->l('Settings'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Configuration value'),
'name' => 'MYMODULE_NAME',
'size' => 20,
'required' => true
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right'
)
);
$helper = new HelperForm();
// Module, token and currentIndex
$helper->module = $this;
$helper->name_controller = $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
// Language
$helper->default_form_language = $default_lang;
$helper->allow_employee_form_lang = $default_lang;
// Title and toolbar
$helper->title = $this->displayName;
$helper->show_toolbar = true; // false -> remove toolbar
$helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen.
$helper->submit_action = 'submit'.$this->name;
$helper->toolbar_btn = array(
'save' =>
array(
'desc' => $this->l('Save'),
'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.
'&token='.Tools::getAdminTokenLite('AdminModules'),
),
'back' => array(
'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'),
'desc' => $this->l('Back to list')
)
);
// Load current value
$helper->fields_value['MYMODULE_NAME'] = Configuration::get('MYMODULE_NAME');
return $helper->generateForm($fields_form);
}
}
Para depurar lo que he hecho es crear un Proyecto "PHP Application with Existing Sources" que apunte directamente a la web de Prestashop local "C:\xampp\htdocs\prestashop_1_6_1_17\admin" que se ejecuta en el navegador.
getContent
ydisplayForm
que son las que se encargan de mostrar la página de configuración del módulo. – Oliver el 22 dic. 17 a las 9:37