I have a module I'm developing that will be used by several sites.

I have a "preview" site on the same server that I would like to be able showcase new features in before promoting to the production sites.

I thought I would be able to have the production version in the drupal/modules directory, and the preview version in the drupal/sites/preview_site/modules directory. I had expected Drupal would load the module from the site's directory and ignore the copy in the global modules directory.

However, when I do this, I get the following error:

PHP Fatal Error: Cannot redeclare

It would seem that Drupal is trying to load both copies!

Is there some way I can get it to only load the local copy?

Is there a better way to achieve this (I expect lots of people will say don't put the preview site on the production server.)

  • I'm thinking the solution will have to be a separate instance of Drupal for the preview sites. I might set it up using symbolic links pointing at the same files as the production sites. Or it might be an opportunity to run the preview site on 8.2.dev. Commented May 21, 2016 at 17:44

1 Answer 1


I have discovered that this wasn't a problem after all.

I think the error I initially got (on performing a "clear cache") was caused by the original version of my module already being loaded from global version, and loading again from the local version caused the "redeclare" error.

If I had just reloaded the page, Drupal would now know to load from the local copy, and ignore the global one.

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.