Showing posts from March, 2017

My First Drupal 8 Module.

Lots of reading and reading ... How about trying some coding ?? Huhh !!! Coding in drupal 8.

Frightened ?? Me too :)

But what I exactly feel here is that this is just the fear of the unknown. And everything we want is

on the other side of fear. I replace my fear of the unknown with curiosity. Give it a shot, who

knows if this works out for you too :)

Let's start together with a simple stuff like "Printing a Drupal 8 welcome message" by creating a

small module.

Taking a deeep breath, let's dive in.

As we must have seen or read that Drupal 8 follows a very strict directory structure, so let's start

with looking for the directory structure followed by custom modules in Drupal 8.

1. Directory structure: It is advised to keep our custom modules by creating a folder 'custom'

under 'modules' folder in the root directory of our site.

So, our custom module 'first_d8_module' will have directory structure something like this.
<root directory>/mo…

Request to Response in Drupal 8

Here ? So, I am assuming we have some idea of Symfony2 and it's components used in Drupal 8

by now.

Great, let's move ahead. Every web interaction as we know starts with a request and ends with a

response, same goes here with Drupal 8. We send a request and receive some response from

Drupal but what goes internally ? Let's dive in and find out.

Of all the important components of Symfony2 being used in Drupal 8, HTTPKernel and

HTTPFoundation plays an important role in handling a page request but this time the proces uses

an object oriented way.

Ohh.. big names :) Let's know something more about these.

HTTPKernel: This component consists of an HTTPKernelInterface which provides a method,

handle(). This method accepts $request object as parameter and returns $response object.

HTTPFoundation: This component is responsible for creating and managing the $request and

$response objects. We can say that, it's an object oriented replacement of superglobals being

generally used…

Drupal 8 with Symfony2

And here, I am set for Drupal 8. But wait ... Symfony2 ?? Now who's this ?? We shouldn't ignore

somebody who meets us on our way, right ? So, let's have a short introduction.

What is Symfony2 ? states that Symfony is a set of PHP Components, a Web Application framework, a

Philosophy, and a Community — all working together in harmony.

I am not a Symfony Developer yet what I understand about it is that Symfony is a PHP framework

build on top of reusable, decoupled and cohesive symfony components which serves a lot of web

applications. Symfony shares some of the concepts of the MVC pattern--such as layer separation

yet it's more of an HTTP framework--it’s a Request/Response framework focusing on returning a

response in an optimized and effective way.

Why Symfony2 in Drupal 8 ?

Pushing Drupal forward

As the momentum of GoPHP5 was not kept, there was a need in Drupal to start embracing the

changes happening in the wider development communities. For an instance, b…

Drupal 8 ... Bring it on !!

Back after a loooonnggg gap so, need a bang to get started again, isn't it ?

Well, I have something in store :)

Yet not very comfy with Drupal 7 but does that allow me to keep my friend, Drupal 8 waiting at the

door ? Will he really wait for me to be done with Drupal 7 ? Nooo way, he is running in his own

pace ... so what are we waiting for friends, need to catch up. So, from here on let's dive into the

ocean of Drupal 8.

It's about a month or even more, just thinking that it's high time I introduce myself with Drupal 8 or

say the other way round ;) Friends, I know most of us might be thinking not to skip steps while

climbing up but at times even three dots are enough to define an area, so why not let's get

started. We may get stuck, not an issue, will keep adding dots so as to get closer to our perfect


Let's begin with the Getting Started guide of Will be back soon with my way of moving

ahead with Drupal 8.

Till then keep connecting you…

404 Expenses Not Found !!

Everyone out there on web must have come across "404", "Page Not Found" messages. The

most important thing with these 404s is that they will happen, they are inevitable.

Before moving into complexities, lets recollect what a 404 error means.

In simple words, 404 is that our server is not able to find what we have requested, so it says

“Sorry buddy, I give up." in the form of page-not-found messages.

Keeping in mind this inevitability of these 404s, you can wonder what problems it can pose to our

site and what these 404 errors can cost us.

Imagine a website, trying to fetch dynamic resources for each of it's page request, some of which

may result in a 404. Such requests, resulting in a 404 on a heavy traffic site can eventually add up

to be actually troublesome.

Hold on ... there is more to it.

Let's see what happens when Drupal comes into picture.

Even while serving a 404 page in Drupal, it does the full "bootstrap", loading all settings, mo…

Know Your Customers !!!

A user landed on a web page and started filling a form. After going half way, he/she got distracted

or suddenly felt not interested in the same and tried to leave the page by either closing the tab or

by closing the browser itself. In either case, we (a company) lost a prospective client and as the

user didn't submit the form we have no info of the user in order to contact them and get the details

of them not being interested.

Is this your story too ??

Congratulations my friend ... you found the solution for yourself. Please continue reading...

To start with let's modularize our requirement.

There's a web page containing a form, a user lands on it and started filling the form:

1. As soon as the user tries to leave the page, ask them if they are ok with sharing their

unsubmitted data with you and leave the page.

2. If a user chooses to stay on the page, simply allow him to be there.

3. If a user opts for leaving the page without submitting the form, save unsubmitted data.


Catch the Batch !

Are you a developer ?

Are you facing PHP timeouts, memory exhausts while dealing with huge data sets ?

YES ??? ... WELCOME ! you are at the right place. If this is such a common problem, Drupal

must be having some solutions in store for us. Let's find out who's the life saver this time...

Drupal's Batch API.

'Serious' wikipedia 'boringly' explains general batch processing as execution of series of programs

on a computer without manual intervention and the same definition holds true in Drupal as well.

Performing series of operations with large data sets often results in timeouts or memory

exhausted errors but then how does Drupal's Batch API manage all these?

What's the mystry behind Drupal's Batch API which handles such situations without errors?

Well, breaking long tasks into smaller batches and spreading out series of programs over different

page requests is the key. This ensures that our processing is not interfered by PHP timeouts or