www.drupaleurope.org axelerant.com 1 Lesser known perks of using - - PowerPoint PPT Presentation

drupaleurope org
SMART_READER_LITE
LIVE PREVIEW

www.drupaleurope.org axelerant.com 1 Lesser known perks of using - - PowerPoint PPT Presentation

www.drupaleurope.org axelerant.com 1 Lesser known perks of using composer Drupal Europe 2018 axelerant.com 2 Drupal + Technology TRACK SUPPORTED BY axelerant.com 3 Special Thanks to.. axelerant.com 4 Mohit Aghera Drupal developer


slide-1
SLIDE 1

1 axelerant.com

www.drupaleurope.org

slide-2
SLIDE 2

2 axelerant.com

Lesser known perks of using composer

Drupal Europe 2018

slide-3
SLIDE 3

3 axelerant.com

Drupal + Technology

TRACK SUPPORTED BY

slide-4
SLIDE 4

4 axelerant.com

Special Thanks to..

slide-5
SLIDE 5

5 axelerant.com

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

slide-6
SLIDE 6

6 axelerant.com

Quick Introduction

  • Why do we need it?
  • How do we use it?
slide-7
SLIDE 7

7 axelerant.com

Drupal Composer initiative

Follow updates here: https://www.drupal.org/project/ideas/issues/2958021

slide-8
SLIDE 8

8 axelerant.com

Composer scripts

  • Define script in composer.json and run
  • Helps to automate tasks
  • Supports various events.
slide-9
SLIDE 9

9 axelerant.com

Composer Scripts

slide-10
SLIDE 10

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

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

12 axelerant.com

Composer Plugins

drupal- composer/drupal

  • scaffold
slide-13
SLIDE 13

13 axelerant.com

Composer Plugins

slide-14
SLIDE 14

14 axelerant.com

Patching

  • Requirement to update core of system
  • Bugs that are not merged
slide-15
SLIDE 15

15 axelerant.com

Patching

slide-16
SLIDE 16

16 axelerant.com

Keeping data up to date

  • Pull and process remote data automatically
  • Implement Composer Plugins
slide-17
SLIDE 17

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

18 axelerant.com

Commit Hooks

slide-19
SLIDE 19

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

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

21 axelerant.com

slide-22
SLIDE 22

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

23 axelerant.com

Automatting project structure

slide-24
SLIDE 24

24 axelerant.com

Example from “ScriptHandler.php”

slide-25
SLIDE 25

25 axelerant.com

Thank you..

slide-26
SLIDE 26

26 axelerant.com

Become a Drupal contributor, Friday from 9 AM

  • First timers workshop
  • Mentored contribution
  • General contribution

26