The best way to debug a custom token module development I'm building a custom module to build some tokens. I have added hook_token_info() and it works great. I haved added hook_tokens(), but I'm not able to debug with var_dump() or with dpm().

function mymoduletoken_token_info() {
  $info['tokens']['node']['seccion'] = array(
    'name' =&gt; t('Seccion'),
    'description' =&gt; t('Custon token to add to the G.A. script more optoins in seccion'),
  );

  $info['tokens']['node']['subseccion'] = array(
    'name' =&gt; t('Subseccion'),
    'description' =&gt; t('Custon token to add to the G.A. script more options into subseccion'),
  );
  return $info;
}

function mymoduletoken_tokens($type, $tokens, array $data = array(), array $options = array()) {
  dpm($type);
  dpm($token);
  dpm($data);
  dpm($options);
}


I would like to debug the different options to build the token with the information I need.
I think I'm following you...you want a way to invoke the tokens you've created outside of their natural context, so you can debug easily? If so, you can use the token_replace() function. As you're defining tokens that need a node object, you'll have to load an appropriate one up for the job:

// Load the node.
$node = node_load($appropriate_nid);

// Prepare the text string.
$text = 'something involving [node:seccion]';

// Set up some options. Your mileage may vary here.
$options['sanitize'] = FALSE;

// Get the replacement text.
$replacement = token_replace($text, array('node' =&gt; $node), $options);


That will invoke your module's implementation of hook_tokens(), and the dpm() calls will fire.

If you're doing a lot of token development it might make sense to wrap that functionality in a simple form.