Last Updated: February 25, 2016
·
1.075K
· 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/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

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.