NAME
CMS::Drupal -- Perl interface to the Drupal CMS
VERSION
version 0.092
SYNOPSIS
use CMS::Drupal;
my $drupal = CMS::Drupal->new();
my $database_handle = CMS::Drupal->dbh(
'database' => "my_db",
'driver' => "mysql",
'username' => "my_user",
'password' => "my_password",
'host' => "my_host",
'port' => "3306",
'prefix" => "myapp_"
);
DESCRIPTION
This module provides a Perl interface to a Drupal CMS website.
Since you can't do anything with Drupal until you can talk to the database, this module doesn't do anything with the constructor but return a new object. You can get a database handle to your Drupal by calling ->dbh() with your database credentials as parameters.
You will need the appropriate DBI driver installed to connect to your database. The DBI will hint at what you need if you don't have it, so long as you set the 'driver' parameter correctly.
FUNCTIONALITY
As of this writing, all the author needs is a DB handle in order to use other CMS::Drupal::* modules. You are welcome to contribute code if you want this module to do anything else. For example, many CMS interfaces allow you to put the CMS into "maintenance mode," so you can work on the database with the site off-line. It would be relatively simple to add methods for tasks such as that.
USAGE
Use the module as shown in the Synopsis above.
METHODS
dbh
Returns a database handle connected to your Drupal DB.
Parameters
database The name of your Drupal database. Required.
driver The DBI driver for your database. Required, from [mysql|Pg|SQLite].
username The database username. Optional. Must be a string if supplied.
password The database password. Optional. Must be a string if supplied.
host The server where the DB lives. Optional. Must be a string if supplied.
port The port on which to connect. Optional. Must be an integer if supplied.
prefix The prefix that you set in Drupal for your DB table names (if any). Optional. Must be at least two characters and end with a "_").
Testing
The following is taken from t/Drupal02.t and explains how to have this module test against your actual Drupal installation.
B<Quote>
This is t/Drupal02.t It tests the CMS::Drupal module against a real Drupal
database. It looks in your environment to see if you have provided
connection information.
So if you want to test against your Drupal DB, you must set the variable
DRUPAL_TEST_CREDS
in your environment, exactly as follows:
required fields are
database - name of your DB
driver - your dbi:driver ... mysql, Pg or SQLite
optional fields are
user - your DB user name
password - your DB password
host - your DB server hostname
port - which port to connect on
prefix - your database table schema prefix, if any
All these fields and values must be joined together in one string with no
spaces, and separated with commas.
Examples:
database,foo,driver,SQLite
database,foo,driver,Pg
database,foo,driver,mysql,user,bar,password,baz,host,localhost,port,3306,prefix,My_
You can set an environment variable in many ways. To make it semi permanent,
put it in your .bashrc or .bash_profile or whatever you have.
If you just want to run this test once, you can just do this from your
command prompt:
$ DRUPAL_TEST_CREDS=database,foo,driver,SQLite; perl ./Drupal_02.t
B<End Quote>
AUTHOR
Author: Nick Tonkin (tonkin@cpan.org)
COPYRIGHT
Copyright (c) 2015 Nick Tonkin. All rights reserved.
LICENSE
You may distribute this module under the same license as Perl itself.