NAME
CMS::Drupal - Perl interface to the Drupal CMS
VERSION
version 0.91
SYNOPSIS
use CMS::Drupal;
my $drupal = CMS::Drupal->new();
my $database_handle = $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.
METHODS
new
Instantiates an object in the CMS::Drupal class.
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
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/20_valid_drupal.t and explains how to have this module test against your actual Drupal installation.
Quote
This is t/20_valid_drupal.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 t/20_valid_drupal.t
End Quote
If you leave the environment variable set, in future you won't have to supply any credentials when calling this module's ->dbh() method:
my $drupal = CMS::Drupal->new;
my $dbh = $drupal->dbh; # fatal error usually
It is not recommended to keep your credentials for a production database in your environment as it's pretty easy to read it ...
USAGE
Use the module as shown in the Synopsis above.
SEE ALSO
AUTHOR
Nick Tonkin <tonkin@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Nick Tonkin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.