May 2014

Map of BuildAModule Members

Orders come into BuildAModule daily from all over the world, but I wanted to get a sense of just how broad the our user base was. So, I put together a quick interactive map using AMCharts, pulling data directly form our orders database to see just how much of the world has been BuildAModuled. here's what that looks like, with countries having made a purchase in blue:

I created this map to visualize our membership, but I wonder if maybe this map has more to offer. While this just illustrates one company's order activity, it also might be generally representative of where Drupal is most popular and also which countries might have issues making purchases for US-based products. While the two causes might be unrelated, it seems likely that the process of learning Drupal would be hindered if one can't take advantage of books or video training distributed from the US.

So, if you are from any of the countries not highlighted above, let us know what we can do to help get training to your area. Is it an issue with the US dollar exchange rate? Does Drupal not have a solid foothold yet? Is English not widely spoken in your area? Is there generally poor internet access? We'd like to do what we can to help Drupal communities grow, so let us know what you need by responding to this email or filling out our contact form.

And just in case you're curious, here's a map of purchases made in the US, broken down by state (yeah, that's all of them):

You can take a look at these live maps in higher resolution and interactivity on our maps page.

Upcoming FREE day for DrupalCon Sprints!

We're offering BuildAModule for FREE to anyone around the world who wants to help with the DrupalCon sprints, or just wants to beef up your knowledge so you can help with the sprints next time. On June 5th, just go to https://buildamodule.com/free and claim a free 24-hour pass.

Meet me at DrupalCon Austin

In addition to organizing and mentoring at the BuildAModule training at DrupalCon Austin, I (Chris Shattuck) will be wandering around the hallways of the Austin Convention Center, hoping to meet you! Feel free to pull me aside to let me know what you really think about BuildAModule or just say hello. I'll likely be wearing an orange BuildAModule T-shirt and will look something like this:

A few squashed bugs on BuildAModule.com

A recent update to the Chrome browser caused the videos on BuildAModule to play erratically. If you ran into this problem, please accept my apologies. But we spent some time working on this and got it fixed! So, if you love Chrome and had to switch to a different browser, feel free to come on back. Along the way we fixed a couple other issues that may have been bugging you (so to speak):

Transcript links now work. So, you can right-click on any part of a transcript, copy the link and visit it later to start playing the video back at exactly that position. This is great for personal bookmarks.

The count above the transcript which should tell you where you are in the collection now shows the right number (sorry about that!).

Images in video updates are now clickable. When we released the big update to our site recently, it broke the ability to view larger versions of the images in the video updates. No longer!

As always, if there's anything you'd like to see added or updated on BuildAModule, please just let us know.

Recent updates to Chrome are resulting in video playback issues. Please accept our apologies, but in the meantime you should be able to use Firefox, Safari or the latest versions of Internet Explorer to use the site without any issues. We will make an announcement as soon as we've resolved the problem. Thank you for your patience!

BuildAModule is FREE on May 30th for Drupal Global Training Days

Drupal companies and user groups around the world will be hosting free Drupal trainings around the globe on May 30th as part of the Drupal Global Training Days initiative. To support the trainings and also help anyone who can't attend a physical training, we're offering the full 1100+ video library on BuildAModule for FREE on that day.

If you didn't plan a training, but you'd like to do something to help, think about organizing a Mentored Training for your Drupal user group. It takes very little planning and is a lot of fun.

If you can't attend a training, but want to learn some Drupal, then sign up for a free 24-hour pass on May 30th and work through as much material on BuildAModule as you can. It's not as good as hooking up with live trainers, but it's the next best thing!

A few new videos on using a Dependency Injection Container

This week we dive into using a Dependency Injection Container (DIC), which ultimately serves as a backbone to Drupal 8 and its APIs. First we talk about what a Dependency Injection Container is, and then demonstrate how to create one with Symfony 2.

Now that we’ve moved some of our front controller code into our framework, our framework is now creating a number of objects, making it harder to test and less flexible. This is the perfect transition for talking about how a dependency injection container can help manage exactly this type of problem.

In this video we create a dependency injection container that allows us to manage a single instance of each one of our classes and allows us to load them only when needed. Along the way we explore what a singleton pattern is.

Last chance to get 25% off!

Nearly every developer uses this technique to find the code responsible for some output that they want to modify. It's simple:

Find a string in the UI that seems like it would be unlikely to occur elsewhere in the UI. Something like "Settings for the Image Toolkit".

Search the entire project code base for the string using grep or an IDE. If you get few enough matches, you can probably figure out what code is responsible for the output.

Adjust the string slightly and rebuild the UI to see if the change takes effect. If it does, BAM! You know where to get started. (note that you may need to rebuild your application or clear the application's caches to see the change take effect).

You revert the change you just made so you don't forget about it.

Where to find a unique string

Finding a unique string becomes easier the more familiar you are with the application you're working with. At first, you may find yourself searching for strings and getting hundreds or thousands of results. Over time you'll get a sense of the usual suspects and try to find other strings that aren't as common.

While the text in the UI can provide a good source, the "id" and "class" properties of HTML is also a good place to look if you're building a browser-based app. Sometimes these are automatically generated, or the string is added to with prefixes or suffixes, but you can search parts of these properties to see if anything shows up.

If a search doesn't turn anything up

If you search the code base for the string and nothing comes up, here are some tips:

Source is in a database: The string could be being pulled from a database, rather than code. If so, then you can do a database dump and search the database dump file. It will probably be harder to track down exactly how that string came to end up where it is, but it's still a useful clue.

String has quotes: If there are any quotes in the string, then they may be escaped with a backslash, meaning that you're not searching for exactly the right string. To get around this, you can search for one side or the other of the string. For the string "you're in my searches!', you could search for "re in my searches".

String has hidden whitespace: There my be some extra white space that you're not aware of. If you're searching HTML, you can look at the source code to see if there are extra spaces between words, or even extra lines. If you can just grab a single line to search for, you can avoid trying to add the white space to your search (adding white space to search is tricky). Again, you can use the approach of just searching for part of the string.

Searching the wrong case: CSS or your backend code may be adjusting the case of the string, adding capitals or lowercase where it isn't in the source code. So, try searching with the "match case" box unchecked.

String has been altered: The text could be being modified through various process. In particular, unique IDs may be prefixed or suffixed, so try searching for bits between underscores or dashes.

What to do once you've found the source

Typically, finding the source of the string you're looking for is the beginning of your search. The goal is to find the right place to adjust or add to what you see in the UI, and there might be several layers between this entry point and where you'll ultimately add your own code.

Use a debugger: Using a debugger like Xdebug is really useful here, so you can see the full stack of method or function calls leading up this specific point in the code.

Copy and paste: If you're dealing with something modular like a CMS where chunks of code and groups of files follow the same pattern for extending the application, you can probably start copying and pasting entire files or parts of code from various sources and replacing unique identifiers in function and variable names until you get something that can work in parallel with the original code you discovered.

Is there some other name for this approach?

If you know of a name for this technique (one that I didn't make up), please let me know so I can delete this page.

Last week we finished up talking about event dispatching in Symfony - a fun way to add easy-to-use hooks in your code - and this week we're tightening up the framework we've been building by adding error reporting and a controller that can return content directly without a response object wrapper. Next, we'll be talking about how a dependency injection container (DIC) can form an important backbone of objects in your project, so stay tuned!

When we instantiate our framework now, we use two different types of dependency injection. We pass two objects in through the constructor, and another through a method in our framework class. We talk briefly about why you would inject dependencies one way or the other here.

In our earlier framework code, we wrapped the execution of our framework in a try … catch block to figure out how and when to display an error on the page. Our new Framework class gives us the same tool, and in this video we look at how to leverage it.

Having a small front controller means that it’s easier to use multiple front controllers in different environments. Now that we have a clean Framework class, let’s explore putting some of our front controller code into it and see if we can’t tighten up our front controller a bit.

Only 3 weeks left to sign up!

That's right, the clock is ticking. If you're coming to Austin and want to get immersed in Drupal in a fun and ultra productive way, come join us at our training.

This week we're wrapping up our coverage of the Symfony Event Dispatcher - the component that mirrors (and could someday replace) the Drupal hook system. We then look into Symfony's built-in caching and finally trash a huge chunk of our code to instead use Symfony's HTTP Kernel component. It's always fun getting rid of code, especially when you can do the same thing with fewer lines. :)

When you have multiple listeners that will always be bundled together, or that will take the same parameters no matter which application will use them, it makes sense to refactor to us a ‘subscriber’ instead. As we discuss this, we also explain what a ‘code smell’ is.

If you’ve worked with Drupal a bit, you probably understand how caching pages in certain situations can really save on processing power. In this video we explore how to add caching to our Symfony application.

In this video, we replace all of the custom code in our Framework class with a single class definition using the Http Kernel component. Here it becomes clear that much of what we’ve been doing so far is building up to the point of understanding how the Http Kernel component can be useful.

It looks like there might be an issue playing videos in this browser. We're working on better cross-brower experience, but in the meantime please try the latest Chrome or Firefox browsers. Or, you may be able to watch the video directly without progress tracking or transcript: