PHP require_once() warning with hook_menu I'm writing a small module for learning purpose, where I try to create a module settings form using hook_menu() and form_api.
Everything look good in my code but I still getting this error message :


  Warning:
  require_once(/var/www/html/drupal/modules/system/demo_usernames_form.inc):
  failed to open stream: No such file or directory in
  menu_execute_active_handler() (line 515 of
  /var/www/html/drupal/includes/menu.inc). Warning:
  require_once(/var/www/html/drupal/modules/system/demo_usernames_form.inc):
  failed to open stream: No such file or directory in
  menu_execute_active_handler() (line 515 of
  /var/www/html/drupal/includes/menu.inc).


function demo_menu(){
    $items[]=array();
    $items['admin/config/people/usernames']=array(
        'title'=&gt;'bad usernames list',
        'description'=&gt;t('configure not allowed usernames'),
        'page_callback'=&gt;'drupal_get_form',
        'page arguments'=&gt;array('demo_usernames_form'),
        'access arguments'=&gt;array('administer site configuration'),
        'file'=&gt;'demo_usernames_form.inc',
        );
    return $items;




function demo_usernames_form($form,&amp;$form_state){
    $form['bad_usernames']=array(
        '#type'=&gt;'textfield',
        '#title'=&gt;'Bad usernames',
        '#default_value'=&gt;variable_get('bad_usernames'),
        '#description'=&gt;t('Enter a list of "bad usernames" separated by commas.  If a user tries to enter one of these usernames either on account creation or when editing their account, the form will display an error message.'),
        );
    return(system_settings_form($form));

}
If you look a bit closer at the path in the error message:


  /var/www/html/drupal/modules/system/demo_usernames_form.inc


You'll notice it's trying to find your include file in the system module.

It's happening because the user module's implementation of hook_menu() has this in it:

$items ['admin/config/people'] = array(
  'title' =&gt; 'People',
  'description' =&gt; 'Configure user accounts.',
  'position' =&gt; 'left',
  'weight' =&gt; -20,
  'page callback' =&gt; 'system_admin_menu_block_page',
  'access arguments' =&gt; array('access administration pages'),
  'file' =&gt; 'system.admin.inc',
  'file path' =&gt; drupal_get_path('module', 'system'),
);


Notice the file path at the bottom, explicitly setting the path Drupal should look for the included file in. 

Since properties are inherited from parent paths, and the path of your item sits nicely under that one, you get an implicit file path that you weren't expecting. The result: your module path is no longer consulted when the system tries to find the include file.

To fix, just add the correct file path to your hook_menu() code:

$items['admin/config/people/usernames']=array(
  'title'=&gt;'bad usernames list',
  'description'=&gt;t('configure not allowed usernames'),
  'page_callback'=&gt;'drupal_get_form',
  'page arguments'=&gt;array('demo_usernames_form'),
  'access arguments'=&gt;array('administer site configuration'),
  'file'=&gt;'demo_usernames_form.inc',
  'file path' =&gt; drupal_get_path('module', 'demo'),
);


And flush them caches.