How to trigger module install file ad hoc I am developing an install script for a custom module, but I can't figure out how to trigger the script once it has already been run once. I know that install scripts are by design intended to only be run once, but what do you do when you need to debug an install script?

I'm running Xdebug so I would prefer if I could trigger the script from the browser UI somehow as opposed to Drush, which will not pause for the debugger.
You can do different things depending on your use case.


If you really need to test your install script again you need to uninstall your module rather than just disabling it. You can do that by running drush dis mymodule &amp;&amp; drush pm-uninstall mymodule followed by drush en mymodule again. As @Clive mentions if you have the Devel module installed you can also drush dre mymodule (Devel reinstall). Or disable the module at http://example.com/admin/modules and then uninstall the module at  http://example.com/admin/modules/uninstall . You should probably have a hook_uninstall function set up to clean up after your install. For example you may need to drop some tables or delete temporary files. See the link below for hook_uninstall.
If you have an update to already the installed module you should use hook_update_n instead of hook_install. Then you can visit http://example.com/update.php or run drush updb
Link below.
Lastly, you can probably change the database table that records the installation. I don't recall exactly how to do that but I don't think its preferable.


Here are the docs on writing uninstall hooks.
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_uninstall/7

Here are the docs on writing update hooks. Basically the way I do it is make sure that hook_install runs the update functions after it runs itself.
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_update_N/7

eg:

/* 
 * Implements hook_install
 */
function mymodule_install() {
// do some things

// then run the updates
    mymodule_update_7000();
    mymodule_update_7001();
}

/* 
 * Implements hook_install
 */
function mymodule_update_7000() {
// do some other things
}

/* 
 * Implements hook_install
 */
function mymodule_update_7001() {
// do some more things
}