5

I'm developing a custom module for Drupal on my local machine.

When I edit my code, the changes are never applied right away. So, I go to Administer Modules, and uninstall, and then reinstall my module. This is cycle of uninstall-install-develop-repeat is slow and tedious.

Is there a better way to do it?

My module makes extensive use of Drupal framework so I'm not sure developing it exclusively in PHP first is an option.

rlb.usa
  • 14,942
  • 16
  • 80
  • 128

5 Answers5

6

I would highly recommend installing the Devel module. It is very useful while developing for Drupal. Once installed, you can enable the Devel block which is extremely useful. It has a list of links to perform somewhat tedious tasks faster, such as emptying the cache, reinstalling modules, rebuilding the menus, etc.

Many of the changes to your module should not require visiting the modules page. You mostly see the need to do this when you are changing the menu with hook_menu() in your module, as the menus are only rebuilt when visiting that page (or using Devel block "Rebuild Menus" link ;) )

Laxman13
  • 5,226
  • 3
  • 23
  • 27
  • 2
    In addition, I can strongly suggest Drush, which leverages these devel commands to the commandline. `$ drush cc all` to flush all cache. – berkes Mar 24 '11 at 17:33
  • Using the devel module with Drush gives you `drush devel-reinstall myModule` which effectively disables, uninstalls, re-installs, enables, and clears the cache (I think) for the modules that you specify. – zkent May 28 '15 at 16:13
3

When uninstall/install, the only things that is executed is what is in .install file.

If you don't change this file, you don't have to uninstall/install the module.

Maybe your problem is just a cache issue. Drupal strongly cache a lot a things. And when you enable a module, the cache is cleared. You can clear you cache manually.

On an other hand, I recommand to look on Drush that allow you to do those things faster. (clear cache, enable/disable a module/...)

Matt V.
  • 9,703
  • 10
  • 35
  • 56
Haza
  • 2,991
  • 1
  • 16
  • 13
  • 1
    Note that during *disabling* the uninstall intructions in `.install` are **not** ran. Only during uninstallation. Disabling is when you uncheck a module on its module page and press save. uninstalling is then possible trough the "uninstall" tab on that same module page. – berkes Mar 24 '11 at 17:32
1

The Drupal admin menu (http://drupal.org/project/admin_menu) along with devel comes in very handy if you have to flush caches.

Gokul N K
  • 2,428
  • 2
  • 32
  • 40
BetaRide
  • 16,207
  • 29
  • 99
  • 177
0

Just drop cache on each time when you edit your code

Administer->Site perfomance

dobeerman
  • 1,354
  • 15
  • 27
0

How can re-install module using Drush commands ?
Run command
drush dre cars_api
For details visit
https://drushcommands.com/drush-9x/devel/devel:reinstall/

======================== Drush For Drupal ========================

What is Drush ?
Ans : Drush is a command line shell and scripting interface for Drupal,
and it is work like Laravel-Artisan, and Angular CLi etc.
It is very Help-full for fast development on Drupal.
Official Website -> http://www.drush.org/
Official composer repository -> https://packagist.org/packages/drush/drush#dev-master
Official Drupal Repository -> https://www.drupal.org/project/drush

What is the Installation Process ?
Ans : There is following steps.
1.Step
Install new and latest version of composer
2. Step
Run in vscode Terminal
composer global require drush/drush:9.x-dev
check the installation in terminal via following command
drush version
For more details visit
https://packagist.org/packages/drush/drush#dev-master
And also helpful
http://docs.drush.org/en/master/
3. Step
Visite following link and see Drush All conads details and documentation
https://drushcommands.com/drush-9x/
https://www.drupal.org/docs/user_guide/en/prevent-cache-clear.html

How can resolve Drush Errors ?
Run command in vscode terminal
Composer require drush/drush

How can see drush commands list in terminal ?
Just type in vscode terminal in project dir
Drush

and enter
So all commands will be listed with summary

Uninstallation process for Drush ?
Just change in command ‘require’ to ‘remove’
composer global remove drush/drush:9.x-dev

  • (Review) Thanks for this answer, but please do not simply copy external documentation snippets into your answer. Especially not items that are not directly relevant to the question. And in general: please have a look at the formatting help near the input box to make your answer more readable ;) – creinig Jul 24 '19 at 10:36
  • 1
    Thanks for appreciate ! i will try my best in next contribution to the community. – Ejaz UL Haq Jul 24 '19 at 13:24