What are the files necessary for building a Drupal 7 module? What are the requirements for constructing a basic .info file? The essence of this question is to provide a skeleton for building a basic Drupal 7 module from scratch.

  • If you downvote the question please post a reason so it can be addressed. May 1, 2012 at 21:21

2 Answers 2


Minimum files needed:

Normally, the minimum files needed for a module is the following:

sites/all/modules/{name of your module}

  • {your module}.info
  • {your module}.module

Or use the examples module:

The examples module on drupal.org provides you skeleton modules to develop custom/contrib modules. Just use that to copy and create your modules off of.

Check out the project page:

This project aims to provide high-quality, well-documented API examples for a broad range of Drupal core functionality.

(Interested in other, non-core examples?)

Developers can learn how to use a particular API quickly by experimenting with the examples, and adapt them for their own use.

Link to the git repository: http://drupalcode.org/project/examples.git/tree/refs/heads/7.x-1.x

Code from the examples module:

I've also just pasted in the code you could get from the examples module.

example.info file:

name = Examples For Developers
description = A variety of example code for you to learn from and hack upon.
package = Example modules
core = 7.x

example.module file:


 * @file
 * This file serves as a stub file for the many Examples modules in the
 * @link http://drupal.org/project/examples Examples for Developers Project @endlink
 * which you can download and experiment with.
 * One might say that examples.module is an example of documentation. However,
 * note that the example submodules define many doxygen groups, which may or
 * may not be a good strategy for other modules.

 * @defgroup examples Examples
 * @{
 * Well-documented API examples for a broad range of Drupal 7 core functionality.
 * Developers can learn how to use a particular API quickly by experimenting
 * with the examples, and adapt them for their own use.
 * Download the Examples for Developers Project (and participate with
 * submissions, bug reports, patches, and documentation) at
 * http://drupal.org/project/examples

 * Implements hook_help().
function examples_help($path, $arg) {
  // re: http://drupal.org/node/767204
  // 5. We need a master group (Examples) that will be in a main
  // examples.module.
  // The examples.module should be mostly doxy comments that point to the other
  // examples.  It will also have a hook_help() explaining its purpose and how
  // to access the other examples.

 * @} End of 'defgroup examples'.

1) Decide on a name for the module (for example: mymodule).

2) Create a folder inside sites/all/modules with your module's name.

3) Inside the folder create a mymodule.module file with a opening php tag (<?php) - the closing tag (?>) should be omitted.

4) Create a mymodule.info file (inside your module's folder) with the following 3 lines:

 name = Mymodule
 description = Description for the module
 core = 7.x

With this much you already have a Drupal 7 module that you can enable via the GUI (it doesn't do anything as long as you haven't added any functions/code inside the mymodule.module file). Note that all the mymodule instances used here should be replaced with your actual module's name and 'Description for the module' should be a proper description.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.