Drupal configurations such as .info, .make appear to follow common structure. There must be Drupal API for reading these configurations from code.

How does one load and read these configurations in his code?


You want drupal_parse_info_format.

Data should be in an .ini-like format to specify values. White-space generally doesn't matter, except inside values.

  key = value
  key = "value"
  key = 'value'
  key = "multi-line
  key = 'multi-line

Arrays are created using a HTTP GET alike syntax:

  key[] = "numeric array"
  key[index] = "associative array"
  key[index][] = "nested numeric array"
  key[index][index] = "nested associative array"

PHP constants are substituted in, but only when used as the entire value. Comments should start with a semi-colon at the beginning of a line.

I actually know this because the Profiler module uses it to parse out its .info file for profile configurations.

| improve this answer | |
  • Thank You Tenken. This very helpful. p.s. I have not got to Profiler, yet, but from your answer i also found useful drupal_parse_info_file() – latvian Jan 8 '14 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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