I have some include files (.inc) that have classes in them that are used by multiple modules. Where should these be stored so that they are accessible to files[] in a modules .info file? Preferably without having to store copies of the files in each modules directory.

1 Answer 1


Probably the sanest way to do this would be to create a new module which has little to no functionality, but includes the .inc files; then make your other modules dependent on that module. As you develop the other modules and find other functionality you want to share between them, just implement it in the "parent" module, and away you go.

If adding another module is objectionable for some reason, you could implement it as a "library" and use the Libraries API module - but that's intended for Drupal-external third-party PHP libraries like TinyMCE, not things you've built yourself.

  • This is fine, I can see how that would work, but it seems silly to have to create a module that's only purpose is to serve as a wrapper for my classes. Can a modules .info files[] option only look inside that modules directory for files? Or can it look elsewhere? Dec 18, 2013 at 19:32
  • It will only find include files within the module directory itself (even if that's not technically true, that is the convention). And at any rate, this sort of thing is not unprecedented; for example, the Token module doesn't really do anything by itself, but provides functionality for other modules that depends on it. Dec 18, 2013 at 19:38
  • If adding a new module is something you really want to avoid, you could also implement it as a library; I added another paragraph to my answer about that. I think the module approach makes more sense for your own code, though. Dec 18, 2013 at 19:41
  • Libraries API is intended for any 3rd party library. Who's to say I didn't write TinyMCE myself, for example? ;)
    – Clive
    Dec 18, 2013 at 19:42
  • Hehehe, I definitely did not write TinyMCE. But as an addition to this line of thinking. If I do go the way you are suggesting, creating a module for this purpose. Do I even need to write a .module file for it? If the entire purpose is just to provide a link to the .inc files using the .info files[] declaration? And if so, what exactly needs to be in it then? Dec 18, 2013 at 19:43

Your Answer

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

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