Last Updated: February 25, 2016
· thezombieguy

Drupal standalone scripts

Say you need to update some stuff in the Drupal system, but you don't want to write a whole module. You can put a script in the Drupal root folder for Drupal goodness.

For example, lets say in Drupal root folder you create another folder called scripts.

And then inside scripts you place a script.php file like so:

define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/';

And now you can append whatever Drupal stuff you need. Moduel invoke into your modules, db api, etc. Ideally you can run this via the command line, but you could also run it directly at your web browser. Whatever works.