This is Part 1 of a blog series about my recent experiences of porting the Instagram Block module from Drupal 7 to Drupal 8. Since Drupal 8 is still in alpha, APIs are subject to change. Also I may not be using best practises so commenting is heavily appreciated!
First lets have a look and compare module layouts in Drupal 7 and 8:
Drupal 7 Module
Image: Drupal 7 Module Layout
Drupal 8 Module
Image: Drupal 8 Module Layout
We still have a *.module file as before, but the *.info file is now a *.info.yml file using the new drupal yml file type (https://drupal.org/node/2000204).
We also, rather than separate our extra code and class definitions into .inc files, put all of our object oriented code into the 'lib' directory.
Show me code!
Now before I go into any more detail, lets just get practical.
This is what our .info file looked like in drupal 7:
name = Instagram Block description = Creates a block that displays images from instagram. package = Social core = 7.x dependencies = block
And now it looks like this:
name: Instagram Block type: module description: 'Creates a block that displays images from instagram.' package: Social core: 8.x dependencies: - block configure: admin/config/content/instagram_block
- ':' instead of '='
- type needs to be set
- Drupal will not find the module unless type is set, no matter which directory you put it in.