Khanh Hoang - Kenn
Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.
In this post, I will share my experience on trying to learn Drupal 8 during its alpha stage, talk about some of the challenges of keeping up with the ongoing changes while trying to learn it, and end with some tips and resources which proved useful for me.
During a few weeks, a group of colleagues and I embarked on a learning project to get up to speed on all things Drupal 8. We did not fully know what to expect given that we were starting this at a time when D8 was still in Alpha and changes (even big ones) kept coming daily.
So, my goals for the project were to at least gain some understanding of the new concepts while coming up with a simple "Hello World"-type module I could build on, to gather some hands-on experience with D8. Simple, right? There were certainly challenges though.
I started by reading up on the different bits around the modern programming patterns used in D8. Even though I have not yet grasped it all (and it was a long read), it was rather straightforward.
However, it turned out that D8 was at a point in time where major changes were still occurring--every day brought small and big changes to the main branch of D8, causing some or all of these when updating D8 to the latest version:
Even during writing my simple "Hello World" module proved a challenge. For example, I sought out 3 different tutorials on the web on how to write a simple module before finding one that actually worked--and even then I only got partial results.
I did not know how to quickly adapt to D8 module writing using my previous knowledge. For example, I knew of hook_menu() for D6-7, and I had added a hook_menu() to my new module... but my current code was just being ignored and I couldn't understand why.
So, some questions began to form in my head:
Bit by bit, consulting with my learning partners, I learned about a few resources and tips I could use and that adapted to my "learning Drupal while it's still changing" workflow (hopefully this workflow will slow down a bit in beta)
I will now share a few of the things that worked for me, and hopefully, will also help you get up to speed in learning D8. These are not meant as a summary of things you should know, but some tips and resources that help you find out what you don't know.
D.O keeps a list of all Change Records at https://drupal.org/list-changes/drupal, each of which summarizes any major change as it makes it into core, such as an API or other. Each record also indicates the work to be done post-change, e.g. whether the change now needs patches to the Examples project, requires additional documentation, etc.
A nice thing is that you can run searches across the change records, for example, for a particular function or topic. I also found it useful to add the RSS feed at https://drupal.org/changes/drupal/rss.xml to my feed reader so I can get an idea of the ongoing changes.
A good source of examples of how to code for D8 are any of the available D8 modules; especially any you already know from D7, or that are simple enough to follow (and, also, that you are lucky enough to have actually work the moment you install them on a current D8 setup).
A great resource for beginners learning any version of Drupal is the Examples project (https://drupal.org/project/examples). Thoroughly-documented, it contains a set of modules that you can read and hack on. Even though some of the submodules were broken under the latest D8 code, they still taught me a lot.
http://api.drupal.org , being generated from the codebase itself, contains the most up-to-date documentation. It's so useful, I have a Firefox keyword set up to find stuff in the site (This blog explains more here!).
One useful thing during my D8 learning that I came across is that you can find out whether a certain function has 'gone away' or has been replaced by something else in D8.
For example, the change record at https://drupal.org/node/2259297 mentions "form_options_flatten() is replaced by \Drupal\Core\Form\OptGroup::flattenOptions". If you then look at https://api.drupal.org/api/drupal/core!includes!form.inc/function/form_options_flatten/8 you can see the API docs mention this as well--at least for now! (I don't know if there is a transition period at the end of which this will disappear from api.drupal.org).
I downloaded the latest stable D7 and the latest D8 HEAD and compared a few of the core files using a diff viewer (my favorite is Meld). For example, comparing D7 and D8 versions of bootstrap.inc and common.inc gave me a good idea of some general changes in programming patterns:
All of these I had probably read about and had the general idea, but seeing the actual changes flagged via the diff viewer onscreen helped me understand them.
I've grown amazingly fond of PHPStorm as a Drupal IDE. It offers code completion, code inspection (e.g. "Hey, you defined this variable which you are not using anywhere!") and other features which makes you question How You Ever Got Along Without It.
And now, with D8 and all those classes extending classes, interfaces and whatnot, you can very easily:
I hope the above gives you some ideas on how to use a few of the mentioned resources to help you learn D8. Even though you might feel overwhelmed at first, keep going! You will eventually start grasping the new patterns and will start coming up with your own workflow to deal with learning it.