I am developing a custom Drupal 8 module on my local VM. When I first created and enabled my module, it did not have a .module file (just a controller). Now I have added a .module file so I can add an implementation of hook_entity_insert() but Drupal is not discovering it. I have tried going to Configuration > Performance > 'Clear all caches' but no joy!

How can I get Drupal 8 to discover the .module file in my custom module?


Just clearing cache is not enough, you need to uninstall and then re-install your module in order for the .module file to be discovered.

In the Admin panel go to Extend and select the Uninstall tab. Select your custom module and click the Uninstall button. Now go back to the List tab and re-enable your module as before. Your implementation of hook_entity_insert() should now be recognised.

  • With the Devel module enabled you can simply use drush dre MYMODULE. – leymannx Aug 14 '18 at 18:42

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.