Slide 1

Slide 1 text

1 axelerant.com www.drupaleurope.org

Slide 2

Slide 2 text

2 axelerant.com Lesser known perks of using composer Drupal Europe 2018

Slide 3

Slide 3 text

3 axelerant.com Drupal + Technology TRACK SUPPORTED BY

Slide 4

Slide 4 text

4 axelerant.com Special Thanks to..

Slide 5

Slide 5 text

5 axelerant.com Mohit Aghera Drupal developer @Axelerant Drupal.org: mohit_aghera Twitter: @mohit_rocks

Slide 6

Slide 6 text

6 axelerant.com Quick Introduction ● Why do we need it? ● How do we use it?

Slide 7

Slide 7 text

7 axelerant.com Drupal Composer initiative Follow updates here: https://www.drupal.org/project/ideas/issues/2958021

Slide 8

Slide 8 text

8 axelerant.com Composer scripts ● Define script in composer.json and run ● Helps to automate tasks ● Supports various events.

Slide 9

Slide 9 text

9 axelerant.com Composer Scripts

Slide 10

Slide 10 text

10 axelerant.com Composer Plugins ● Helps to overcome limitation of composer scripts ● Run independently - irrespective of root package ● Helps in creating distributable package

Slide 11

Slide 11 text

11 axelerant.com Composer Plugins { "name": "my/plugin-package", "type": "composer-plugin", "require": { "composer-plugin-api": "^1.1" }, "extra": { "class": "My\\Plugin" } } ● “type” : “composer-plugin” ● “extra” : Contains class name ● Add special package called “composer-plugin-api”

Slide 12

Slide 12 text

12 axelerant.com Composer Plugins drupal- composer/drupal -scaffold

Slide 13

Slide 13 text

13 axelerant.com Composer Plugins

Slide 14

Slide 14 text

14 axelerant.com Patching ● Requirement to update core of system ● Bugs that are not merged

Slide 15

Slide 15 text

15 axelerant.com Patching

Slide 16

Slide 16 text

16 axelerant.com Keeping data up to date ● Pull and process remote data automatically ● Implement Composer Plugins

Slide 17

Slide 17 text

17 axelerant.com Keeping data up to date Benefits: ● No need to have separate sync code ● Helps to solve problems in continuous integration as data will already be there Limitations: ● It is meant for retrieving and storing data - no live sync.

Slide 18

Slide 18 text

18 axelerant.com Commit Hooks

Slide 19

Slide 19 text

19 axelerant.com Commit Hooks ● GIT hooks helps to enforce code quality ● Ensure commit messages are proper ● Coding standards validation ● Sharing GIT hooks with composer has more advantages

Slide 20

Slide 20 text

20 axelerant.com Commit Hooks There are several libraries that supports this type of implementations: ● https://github.com/sebastianfeldmann/captainhook ● https://github.com/bruli/php-git-hooks ● https://github.com/php-composter/php-composter ● https://github.com/BrainMaestro/composer-git-hooks

Slide 21

Slide 21 text

21 axelerant.com

Slide 22

Slide 22 text

22 axelerant.com Automatting project structure ● Composer helps to generate essential files and other code ● Use case : drupal-composer/drupal-project

Slide 23

Slide 23 text

23 axelerant.com Automatting project structure

Slide 24

Slide 24 text

24 axelerant.com Example from “ScriptHandler.php”

Slide 25

Slide 25 text

25 axelerant.com Thank you..

Slide 26

Slide 26 text

26 axelerant.com Become a Drupal contributor, Friday from 9 AM ● First timers workshop ● Mentored contribution ● General contribution 26