Last Updated: February 25, 2016
·
1.308K
· 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.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#php
#drupal
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside