Starting with Drupal 5.x, the concept of a .info file was introduced to give Drupal's modules administration system information about your module. This .info file is used primarily for display and for providing criteria to control module enabling and disabling. The .info file is required for Drupal 5.x and up to recognize the availability of a module for enabling or disabling on your site.

The following is a sample .info file from the views_bonus module:

name = Bonus: panels, teasers, 2 col
description = "Show views as teasers in two columns."
dependencies = views panels
package = Views

The .info file should have the same name as the .module file and reside in the same directory. For example, if your module is named example.module then your .info file should be named example.info.

The .info file uses standard .ini file format which places items in key/value pairs separated by an equal sign. For the name and description elements, you may include the value in quotes. You must include the value in quotes if the value includes punctuation:

description = "Fred's crazy, crazy module; use with care!"

The .info file may contain comments. The comment character is the semi-colon and denotes a comment until the end of the line. A comment may begin at any point on the line, thus it is especially important that you use quotes around any string that contains a semi-colon which is not a comment.

The .info file can contain the following fields:

name (Required)
The displayed name of your module. It should follow Drupal's standard sentence case: only the first letter of the first word is capitalized ("Example module", not "example module" or "Example Module").
name = "Forum"
description (Required)
A short, preferably one line description that displays on the module administration page (Site building > Modules). Remember, long descriptions can make this page difficult to read, so please be concise. The description field is limited to 255 characters.
description = "Enables threaded discussions about general topics."

If your .info file's description (or other field) contains anything other than text or numbers don't forget you must use quotes. If you need to use a double quote (") in your text then you need to use the HTML entity " to display the double quote (") character.

Do this:

description = "This is my "crazy@email.com" email address"

Don't do this:

description = This is my "crazy@email.com" address

This will cause Drupal to display an error when displaying the modules administration page (Site building > Modules).

dependencies (Optional)
A space separated list of modules that your module requires to be present and enabled. The name of each required module uses the machine-readable name of the module in lowercase. For example, if your module requires the Revision Moderation module, use dependencies = revision_moderation in your .info file. Remember to use lowercase since the check on dependencies matches the machine readable name stored in the database. If the required modules are not present and enabled, your module cannot be enabled. If these modules are present, but not enabled, the Drupal will prompt you with a list of additional modules to enable. Choose to enable the required modules or cancel.
dependencies = taxonomy comment
package (Optional)
The package text is used to group modules together as fieldsets on the module administration display. The text must be the same as the fieldset name where you would like your modules to appear. It should be consistent (in spelling and capitalization) in all .info files in which it appears. It should not use punctuation and it should follow the Drupal 5 capitalization standard as noted above.

If your module comes with other modules or is meant to be used exclusively with other modules, enter the name of the package here. If left blank, the module will be listed as 'Other'. In general, this field should only be used by large multi-module packages, or by modules meant to extend others, such as CCK, Views, E-Commerce, Organic Groups and the like. All other modules should leave this blank. As a guideline, four or more modules that depend on each other (or all on a single module) make a good candidate for a package. Fewer probably do not.

package = Views

Suggested examples of appropriate items for the package field:

  • Audio
  • Bot
  • CCK
  • Chat
  • E-Commerce
  • Event
  • Feed parser
  • Organic groups
  • Station
  • Video
  • Views
  • Voting (if it uses or requires VotingAPI)
  • Location

The exception to this rule is the "Development" package, which should be used for any modules which are related to code development modules (Devel, Coder, Module Builder...).

version (Discouraged)
The version string will be added by drupal.org when a release is created and a tarball packaged. However, if your module is not being hosted on the drupal.org infrastructure, you can give your module whatever version string makes sense.

Users getting their modules directly from CVS will not have a version string, since the .info files checked into CVS do not define a version. These users are encouraged to use the CVS deploy module to provide accurate version strings for the modules administration page (Site building > Modules ) for modules in directories checked out directly from CVS.

Before the CVS deploy module existed, it was recommended to use this:

version = "$Name$"

It is no longer recommended. If you are a module developer, and have the above line in your .info files checked into the Drupal CVS repository, you should remove that line.

project (packaging use only)
Module maintainers should not use this. The packaging script on drupal.org will automatically place the proper text here to identify what project the module is from. The primary use is for the Update status module to monitor versions of installed packages and notify administrators when new versions are available.

For more information on .ini file formatting, see the PHP.net parse_ini_file documentation.

Comments

febbraro’s picture

I have not verified that this works just yet, but I was surprised to not see mention of it anywhere. If you write a custom module that is not hosted at drupal.org, it seems you have the ability to specify the base URL that update_status will check to see if there are subsequent releases of your modules. In looking at the code it appears in your .info file you will add something like

project status url = http://some.host.com/drupal-module-updates

For example the default URL for drupal.org is http://updates.drupal.org/release-history

The format is then baseurl/modulename/version, so the url to check versions of the views moduel for drupal release 5.x is http://updates.drupal.org/release-history/views/5.x

Anyway, just came across this and thought it might help someone.

aklump’s picture

I would like to add that you will have to also add the "project" key to the .info file, and that should mimick the filename of your module. So if your module is called my_module.info you would add this to your .info file as well as project status url...

project = "my_module"