Using different .inc files with same function names in .module file In our project, we have this module meant strictly for our custom API endpoints for our mobile applications to use. Currently, this is handled in a single .module file like so:

my_project_mobile_api.module

&lt;?php

function my_project_mobile_api_menu() {
  return array(
    'api/v1/user/register' =&gt; array(
      'page callback' =&gt; 'account_register',
      'access callback' =&gt; 'user_is_logged_in'
      'type' =&gt; MENU_CALLBACK
    ),
    ...
  );
}

function account_register() {
  ... logic to create an account
}


Up until now, this has worked great for us, but now we need to add a V2 of the API. My idea was to extract all of the page callback functions (like account_register) into their own .inc file. This would look like this:

my_project_mobile_api.module

function my_project_mobile_api_menu() {
  return array(
    'api/v1/user/register' =&gt; array(
      'page callback' =&gt; 'account_register',
      'access callback' =&gt; 'user_is_logged_in'
      'type' =&gt; MENU_CALLBACK
    ),
    'api/v2/user/register' =&gt; array(
      'page callback' =&gt; 'account_register',
      'access callback' =&gt; 'user_is_logged_in'
      'type' =&gt; MENU_CALLBACK
    ),
    ...
  );
}


my_project_mobile_api.v1.inc

function account_register() {
  ... logic to create an account
}


my_project_mobile_api.v2.inc

function account_register() {
  ... logic to create an account (this logic differs from that of V1)
}


How can I make sure that my .module uses the right account_register function from the correct .inc file? Is there a way to specify the file in  the api/v1/user/register array?
You can use file key in your menu like:  

I assume you have a includes directory contain both files my_project_mobile_api.v1.inc and my_project_mobile_api.v2.inc and both files contain account_register function. 

Your hook_menu should be like the following.

function my_project_mobile_api_menu() {
  return [
    'api/v1/user/register' =&gt; [
      'page callback'   =&gt; 'account_register',
      'access callback' =&gt; 'user_is_logged_in',
      'type'            =&gt; MENU_CALLBACK,
      'file'            =&gt; 'includes/my_project_mobile_api.v1.inc',
    ],
    'api/v2/user/register' =&gt; [
      'page callback'   =&gt; 'account_register',
      'access callback' =&gt; 'user_is_logged_in',
      'type'            =&gt; MENU_CALLBACK,
      'file'            =&gt; 'includes/my_project_mobile_api.v2.inc',
    ],
  ];
}


You can also use 'file path' if you files not in the same module take a look at this example.