Tag Archives: Drush

Drupal 7 – Add validation on your Drush command

Previously:

 

We could add validation to our drush command. What we need to do is to add the validation function. Let’s once again update our eureka_drush.drush.inc. Continue reading Drupal 7 – Add validation on your Drush command

Advertisement

Drupal 7 – Write a Drush command which takes arguments input

Previously:

 

So it would be more useful if our drush command could take input arguments. Let’s modify the eureka_drush.drush.inc a bit.

eureka_drush.drush.inc

<?php

/**
 * Implementation of hook_drush_command().
 */
function eureka_drush_drush_command() {
  $items = array();
  
  $items['say-hello'] = array(
    'description' => 'Say Hello to someone',
    'arguments' => array(
      'whom' => 'Someone you want to say hello to. Defaults to "Kit".',
    ),
    'drupal dependencies' => array('eureka_drush'),
  );
  
  return $items;
} 

/**
 * Callback function for say-hello.
 * The function name is drush_<module_name>_<command_in_underscore>
 */
function drush_eureka_drush_say_hello($whom = "Kit") {
  $msg = 'Hello ' . $whom;
  drush_print("\n" . $msg . "\n");
}

Continue reading Drupal 7 – Write a Drush command which takes arguments input

Drupal 7 – Write your first Hello World Drush command

1. Create a new custom module. In this example, the module name is eureka_drush.

2. Create the eureka_drush.info.
eureka_drush.info

name = Eureka Drush
description = Custom drush command example.
core = 7.x
package = Eureka

 

3. Create the eureka_drush.module. Even if you do not have any implementation, leave it with just the PHP open tag.
eureka_drush.module

<?php

Continue reading Drupal 7 – Write your first Hello World Drush command

Drupal – Run Drush in Windows PowerShell

1. Install the Drush Windows Installer.
 

2. Open the DrushEnv.bat in a text editor. The default location should be C:\Program Files (x86)\Drush. You should see the ENV variable setting as follow.

@ECHO Command Prompt shell optimized for Drush 
@SET PATH=%PATH%;C:\ProgramData\Drush\
@SET PATH=%PATH%;C:\Program Files (x86)\Drush\GnuWin32\bin
@SET PATH=%PATH%;C:\Program Files (x86)\Drush\Php

Continue reading Drupal – Run Drush in Windows PowerShell

Drupal 7 – Export data using Views data export module with Drush command

Yesterday we talked about exporting data using the Views data export module.
Drupal 7 – Export view data CSV, XML, XLS by Views data export module

The module also provides a Drush command such that you can run the export command in the server which is convenient for backend integration.

The following command is stated in the project page.

  • drush views-data-export [view-name] [display-id] [output-file]

Continue reading Drupal 7 – Export data using Views data export module with Drush command

Drush – The command line tool for Drupal development

In Drupal development, we spend quite a lot of time on module management.

  1. Browser: Go to the module page
  2. Browser: Copy the download link
  3. Shell: Go to the sites/all/modules directory
  4. Shell: Download the module using the wget command with the copied link
  5. Shell: Extract the module by the tar command
  6. Shell: Remove the extracted archive
  7. Browser: Login to the Drupal instance and go to the module page
  8. Browser: Enable the module

 

A typical Drupal website requires about twenty modules. That means you need to repeat the above tedious steps for twenty times. Besides, you have to move your focus between the browser and the shell prompt.
Continue reading Drush – The command line tool for Drupal development