drupal

Dual DB Schema Setup with Drupal

Submitted by Sergey Cheban on Mon, 07/28/2014 - 20:47

Anyone that has worked on an enterprise level Drupal application knows that having the transactional consumer data separate from your content will save you time and headaches during a release. With Drupal this is very much possible and it's fairly easy to setup. This can be setup with the DB on a separate server or on the same server where you currently have your Drupal DB residing.

The first thing that you will need to do is edit your "settings.php" file for you drupal installation and add the following array block to configure your second schema:

Drupal Module Folder Organization

Submitted by Dan Slater on Mon, 07/28/2014 - 15:16

Organization is important for any Drupal site larger than the simplest of blogs. It is paramount for multi-site installations that are already bulky with numerous site folders, themes and subthemes. I have observed that if I don’t maintain a good organizational format within my multisite structure, I can very quickly become lost locating specific files and lose precious productive time.

Choosing between PHP, Lua, Go

Submitted by Jitesh Doshi on Fri, 06/27/2014 - 18:59

I have recently spent quite a bit of time trying to come up with a better way to implement RESTful service that serve data in JSON. This is because most of our work these days involves writing client-side JavaScript apps that present a rich UI in the browser and then do all server-side interactions via AJAX. In pursuit of the best way to implement RESTful service on the backend, I have tried my hands at Go programming language, D programming language, Lua and of course Java and PHP. I was assuming that the Go or Lua would be much faster than PHP. Well, it turns out that at least without special optimizations, that is not the case.

I wrote the following programs to compare their performance:

<?php

header('Content-Type: application/json');

$db = new PDO('mysql:host=localhost;dbname=db;charset=utf8', 'user', 'pass');
$stmt = $db->query("SELECT * FROM node");
$result = array();
$result['list'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($result);

 

<?php

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
// drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

header('Content-Type: application/json');

$stmt = db_query("SELECT * FROM node");
$result = array();
$result['list'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($result);

 

json = require "cjson"

function json_result(key, data)
  local result = {}
  result[key] = data
  ngx.say(json.encode(result))
end

function json_error(...)
  local result = {}
  result["message"] = string.format(...)
  ngx.status = ngx.HTTP_INTERNAL_SERVER_ERROR
  ngx.say(json.encode(result))
end

mysql = require "resty.mysql"

local db, err = mysql:new()
if not db then
  json_error("failed to instantiate mysql: %s", err)
  return
end

db:set_timeout(1000) -- 1 sec

local ok, err, errno, sqlstate = db:connect{
  host = "127.0.0.1",
  port = 3306,
  database = "db",
  user = "user",
  password = "pass",
  max_packet_size = 1024 * 1024
}

if not ok then
    json_error("failed to connect: %s: %d %d", err, errno, sqlstate)
    return
end

result, err, errno, sqlstate = db:query("SELECT * FROM node")

if not result then
  json_error("failed to query: %s: %d %d", err, errno, sqlstate)
end

json_result("list", result)

 

The above programs simply query a table and return all rows and columns from that table as a JSON array.

And then I hit the above programs with a bit of load using 'ab' HTTP load testing command. Following are the results ...

Tags

Integrating Apache Solr with Drupal Autocomplete

Submitted by Sergey Cheban on Fri, 06/07/2013 - 17:00

Although Drupal has a good built-in search functionality that coumes out of the box, sometimes a client wants something more advanced and feature rich that scales well for a quickly growing website.  This is where Apache Solr comes into play.  Apache Solr is an open source project that is used on many high traffic websites like Zappos.com and is well integrated into Drupal.

Drupal jQuery behaviors

Submitted by Jitesh Doshi on Sun, 05/12/2013 - 14:49

In this article, I try to explain "Drupal Behaviors". Drupal provides a very clean way of attaching JavaScript code to HTML components. It includes jQuery library with it. So you have to do nothing to add jQuery to your app. But on top of it, you also don't have to attach onload event handlers in JavaScript. Instead you simply write "Drupal JS behaviors" which are JavaScript functions that get invoked when attached (document loaded) or detached (document unloaded).

Let's take a look at an example:

Automating Drupal user login and maintaining session in curl

Submitted by Jitesh Doshi on Thu, 04/04/2013 - 22:04

Using the services module in Drupal to expose CRUD operations on nodes is a great way to expose RESTful service from Drupal. All you have to do is to enable rest_server sub-module and create a REST server in it. Now you start fetching your nodes in XML, JSON or many other formats. Now for testing, the 'curl' command line browser was used to make HTTP requests in an automated fashion. Making read-only requests to fetch nodes as JSON was easy.

Drupal Zen theme and SASS

Submitted by Jitesh Doshi on Fri, 02/15/2013 - 21:26

Zen is one of the best themes (in terms of solid, clean foundation) out there. And 7.x-5.x release is even better than previous ones. It comes with a drush command to create Zen subthemes in seconds. It also has very clearly laid out and documented CSS stylesheets in the css folder that allow easy modification of styles.

SpinSpire releases top-level Drupal project - Popular Tags

Submitted by Jitesh Doshi on Fri, 11/09/2012 - 06:22

I'm very pleased to announce that SpinSpire has released and published on drupal.org as top-level project - popular tags (http://drupal.org/project/popular-tags), Drupal module for better taxonomy tag selection (details below).

I now also have the rights to create and promote new top-level projects. In Drupal community, it is considered a significant badge of honor.

Tags
Subscribe to drupal