How do I run hook_views_data_alter()? So I have already read and followed everything I could find on that issue:


putting my_module_views_data_alter(array &amp;$data) in my_module.views.inc file in the root directory of my_module,
disabling cache for my view,
clearing caches million times,


but still I can never stop at a breakpoint inside this hook, nor can I see any effects of the code I have put in it.

What am I missing?

EDIT: updating with some code

In my_module I have already created a computed field user_age, calculating user age from a custom user profile field with date of birth.

my_module/my_module.module

function my_module_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type-&gt;id() === 'user') {
    $fields = [];
    $fields['user_age'] = BaseFieldDefinition::create('user_age_field')
      -&gt;setName('user_age')
      -&gt;setLabel(t('User age'))
      -&gt;setComputed(TRUE)
      -&gt;setClass('\Drupal\my_module\UserAgeIntegerItemList')
      -&gt;setDisplayConfigurable('view', TRUE)
      -&gt;setDisplayOptions('view', [
        'label' =&gt; 'hidden',
        'weight' =&gt; -5,
      ]);

    return $fields;
  }
}
function my_module_field_formatter_info_alter(array &amp;$info) {
  $info['number_integer']['field_types'][] = 'user_age_field';
}


This field is working and is accessible in my user profile template.

Knowing that since Drupal 8.4


  Computed fields can now be displayed by Views


I wanted to use field user_age as an exposed filter in my search_users view:

my_module/my_module.views.inc

/**
 * Implements hook_views_data_alter().
 */
function my_module_views_data_alter(array &amp;$data) {
  if (isset($data['users_field_data'])) {
    $data['users_field_data']['user_age'] = [
      'title' =&gt; t('User age'),
      'field' =&gt; [
        'id' =&gt; 'my_module_view_user_age',
      ],
    ];
  }
}


my_module/src/Plugin/views/field/MyModuleViewUserAge.php

&lt;?php

namespace Drupal\my_module\Plugin\views\field;

use Drupal\views\ResultRow;
use Drupal\views\Plugin\views\field\FieldPluginBase;

/**
 * A handler to provide proper displays for user user_age.
 *
 * @ingroup views_field_handlers
 *
 * @ViewsField("my_module_view_user_age")
 */
class MyModuleViewUserAge extends FieldPluginBase {

  /**
   * {@inheritdoc}
   */
  public function render(ResultRow $values) {
    $relationship_entities = $values-&gt;_relationship_entities;
    $age = '';
    // First check the referenced entity.
    if (isset($relationship_entities['user'])) {
      $user = $relationship_entities['user'];
    }
    else {
      $user = $values-&gt;_entity;
    }

    $type = get_class($user);
    if ($type === 'Drupal\user\Entity\User') {
      $age = $user-&gt;get('user_age')-&gt;getvalue();
    }

    return $age;
  }

  /**
   * {@inheritdoc}
   */
  public function query() {
    // This function exists to override parent query function.
    // Do nothing.
  }
}


but my_module_views_data_alter() seems to never be executed and user_age field is not present in the filter criteria for my view.
You can't xdebug in hook itself, you need to go to method calling this hooks which is in class ViewsData  path /core/modules/views/src/ViewsData.php
and put breakpoint in getData, clear cache and you will get what you need.