Alexei Rayu's blog

Anatomy of a Drupal 8 Module: Part 1. Overview.

The best way to get to know a technology closer is to study it's code. Drupal 8 is a huge step forward technologically from Drupal 7, and it has literally tons of code that I feel I need to review and learn from. And I welcome comments and crtiticism from the readers.

The module that I chose to start with is a simple one: the Ban module. It's used to ban IPs via interface and first appeared in Drupal 7, undergoing a rewrite for Drupal 8. Why I chose this module? Because it's simple. We'll take the Drupal 8 module as an example and lay out it's anatomy and of how a Drupal 8 module is built, and try to explain some new concepts with it. And, you can always get Drupal 8 from and see the code yourself, and play with it.

Drupal 8 and PHP 7 dev Input.

I have been watching / following the initiative to convert Drupal 8 to be compatible with PHP 7. This is so freaking exciting! Drupal community and some of the best Drupal devs are now actively contributing to the testing and development of PHP language itself, and the Symfony project, helping to file bug reports and run tests. This tells me, that Drupal 8 is very serious, and stands on a high and modern and rather professional level of implementation.

Drupal 7 vs Drupal 8 (beta 11) Performance Tests

It has been 3 months since March 25, when I publiched Drupal 7 vs Drupal 8 speed tests results. Now, after there has been a significant performance work on Drupal 8 caching, I am revisiting the issue, comparing Drupal 8 beta 11 to Drupal 7.37.

Tests were conducted my my work Lenovo ThinkPad E530c laptop with 8Mb RAM and SSD hard drive, with Ubuntu 14.10, LAMP stack with MariaDB 10.1 and PHP 5.6.9. No APC or any other cache except the build-in PHP's opcache and Drupal's native's cache. The ab test command ran 1000 requests with concurrency of 20. Because Drupal 8 now has caching turned on by default, I have also turned caching on for Drupal 7, to make sure that I test performance under the similar settings. All test results here are taken with Drupal 7 native caching on.

So, what's the result?

Drupal on HHVM

PHP 7 will be released soon, and Drupal comminuty is beginning to consider reworking Drupal's code in anticipation. It seems like much needs to be changed in Drupal code base, though. Community is hopeful to have the the necessary changes made in time for Drupal 8. PHP 7 promises significant boost in performance for OOP elements, which is desperately needed for Drupal 8. There has been a competition in performance between PHP and it's hack, called... well... Hack.

Drupal 8's Asset Management Rant

It has been about half a year since I wrote my Angulars Drupal 8 module and posted it on GitHub. The module actually did some easy manipulation with strings and inputs by AngularJS. Now that I have had some free time in a few months, I decided to revisit it and see if it still worked with all the changes being bundled into Drupal 8 daily. And surely it did not. One thing that changed in Drupal 8 recently (well, a few months ago) has made me especially ranty.

Quoting and Estimating Drupal Projects

How do you quote for a Drupal based project? How do you come up with a quote that is both fair and it does not end you up working for free? It has been usual for me to come up close to estimation for some years now, to the point where a few margin hours no longer matter for the larger projects. There are some steps and methods that I have been using, all taken from other freelancers and project managers, in Drupal field of application and outside. In this article, I will present this process, as I view it, and hopefully you find it helpful. So here are those quote steps.

Missing image_dimensions table

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'image_dimensions' doesn't exist: SELECT * FROM {image_dimensions}

It has been half a dozen times now that I have encountered this error. It happens with the Media's file_entity module (the version coming with the Media module) installed. There is an issue for it at as well. Sadly, the author has not been able to reproduce the bug. It is obvious, though, that a number of sites have been suffering from it. So, what do you do if yo have this issue? You need to run this code on your site, calling the update that corrects this:

('install', 'file_entity');

PHP PDF Library: tcPDF vs mPDF

Recently, I needed to create a simple Drupal-based solution, that would include mailing a PDF printout of a node to the client. My study of the available free PHP PDF libraries has yielded results - Google found about a dozen of them. After some research, these have been narrowed to just 2 - TCPDF and mPDF. After some more research and playing with the two, I ended up with the mPDF as the library of choice. And the reason, plainly - better HTML/CSS support.


Subscribe to RSS - Alexei Rayu's blog