Slide 1

Slide 1 text

Comparing Composer Things you might not know about composer

Slide 2

Slide 2 text

Hi, my name is Hannes.

Slide 3

Slide 3 text

madewithlove

Slide 4

Slide 4 text

MongoDB Belgium

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

• Developer • madewithlove • MongoDB Belgium • php.gent ABOUT ME

Slide 7

Slide 7 text

Comparing composer

Slide 8

Slide 8 text

1. Dependency managers 2. Composer 3. Improve ecosystem

Slide 9

Slide 9 text

1. Dependency
 managers

Slide 10

Slide 10 text

DEPENDENCY MANAGERS

Slide 11

Slide 11 text

DEPENDENCY MANAGERS - PACKAGE.XML 5.1.0 6.0.0 6.0.0 1.4.0b1 …

Slide 12

Slide 12 text

DEPENDENCY MANAGERS - PECL “platform requirements”

Slide 13

Slide 13 text

DEPENDENCY MANAGERS apt

Slide 14

Slide 14 text

DEPENDENCY MANAGERS - APT PACKAGES … Package: mongodb-org-server Version: 2.6.7 Installed-Size: 23291 Depends: libc6 (>= 2.3.2), libgcc1 (>= 1:4.1 …

Slide 15

Slide 15 text

DEPENDENCY MANAGERS - APT (Peer) Dependencies

Slide 16

Slide 16 text

DEPENDENCY MANAGERS - APT The following packages have unmet dependencies: package1 : Depends: package2 (>= 1.8) but 1.7.5-1ubuntu1 is to be installed

Slide 17

Slide 17 text

DEPENDENCY MANAGERS pip

Slide 18

Slide 18 text

DEPENDENCY MANAGERS - PIP pip freeze > requirements.txt

Slide 19

Slide 19 text

DEPENDENCY MANAGERS - PIP No dependency resolver

Slide 20

Slide 20 text

DEPENDENCY MANAGERS Bundler

Slide 21

Slide 21 text

DEPENDENCY MANAGERS - BUNDLER Gemfile Gemfile.lock

Slide 22

Slide 22 text

DEPENDENCY MANAGERS - BUNDLER Dependency tree resolving

Slide 23

Slide 23 text

DEPENDENCY MANAGERS - BUNDLER Separate Lock file

Slide 24

Slide 24 text

DEPENDENCY MANAGERS npm

Slide 25

Slide 25 text

DEPENDENCY MANAGERS - NPM node_modules/gulp/node_modules/…

Slide 26

Slide 26 text

DEPENDENCY MANAGERS - NPM Hierarchical installation

Slide 27

Slide 27 text

DEPENDENCY MANAGERS - NPM require.js

Slide 28

Slide 28 text

DEPENDENCY MANAGERS - NPM No locking needed

Slide 29

Slide 29 text

DEPENDENCY MANAGERS - NPM v3.0: only hierarchical when conflicts

Slide 30

Slide 30 text

DEPENDENCY MANAGERS - RECAP Platform requirements Dependencies Resolving + Separate Lock files Hierarchical

Slide 31

Slide 31 text

2. Composer

Slide 32

Slide 32 text

COMPOSER Too basic: Version constraints Semver(.org)

Slide 33

Slide 33 text

COMPOSER --(no-)dev

Slide 34

Slide 34 text

COMPOSER - DEV { "require-dev": {} "autoload-dev": {} }

Slide 35

Slide 35 text

COMPOSER - DEV Not for my production Not for other people’s production

Slide 36

Slide 36 text

COMPOSER - GLOBAL composer global require

Slide 37

Slide 37 text

COMPOSER - SCRIPTS { "scripts": {…} }

Slide 38

Slide 38 text

COMPOSER - SCRIPTS pre-install-cmd post-install-cmd pre-update-cmd post-update-cmd post-create-project-cmd

Slide 39

Slide 39 text

COMPOSER - SCRIPTS php-cs-fixer src/ --level=symfony --fixers=short_array_syntax

Slide 40

Slide 40 text

COMPOSER - SCRIPTS { "scripts": { "fix-cs": "php-cs-fixer src/ — } }

Slide 41

Slide 41 text

COMPOSER - SCRIPTS { "scripts": { "fix-cs": "php-cs-fixer src/ — "misc": "MyClass::method" } }

Slide 42

Slide 42 text

COMPOSER - SCRIPTS { "config": { "bin-dir": "vendor/bin" }, "scripts": {…} }

Slide 43

Slide 43 text

COMPOSER Virtual packages

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

COMPOSER - VIRTUAL PACKAGES “Depend on abstractions”

Slide 46

Slide 46 text

COMPOSER - VIRTUAL PACKAGES "require": "psr/log-implementation" "provide": "psr/log-implementation"

Slide 47

Slide 47 text

COMPOSER - VIRTUAL PACKAGES "psr/cache-implementation" "psr/http-message"

Slide 48

Slide 48 text

COMPOSER - VIRTUAL PACKAGES container-interop

Slide 49

Slide 49 text

COMPOSER - VIRTUAL PACKAGES Would be useful streams store/repository event dispatcher

Slide 50

Slide 50 text

COMPOSER More keywords: replace conflict suggest

Slide 51

Slide 51 text

COMPOSER - REPLACE Replace subsplit packages: symfony/symfony zendframework/zendframework laravel/framework

Slide 52

Slide 52 text

COMPOSER - CONFLICTS conflict means: “Do not install together with”

Slide 53

Slide 53 text

COMPOSER - SUGGEST Suggest used for: PHP extensions (eg: for extra speed) Adapter packages

Slide 54

Slide 54 text

COMPOSER - OTHER STUFF --prefer-lowest --ignore-platform-reqs --prefer-source --prefer-dist .gitattributes

Slide 55

Slide 55 text

COMPOSER - RECAP dev scripts virtual packages subsplits conflict suggest

Slide 56

Slide 56 text

3. Improve ecosystem

Slide 57

Slide 57 text

SemVer IMPROVE ECOSYSTEM - SEMVER

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

~1.4: >=1.4.0 and < 2.0.0 ~1.4.3: >=1.4.3 and < 1.5.0 ^1.4.3: >=1.4.3 and < 2.0.0 IMPROVE ECOSYSTEM - SEMVER

Slide 60

Slide 60 text

If all packages - Use Semver - Correctly define version constraints IMPROVE ECOSYSTEM - SEMVER

Slide 61

Slide 61 text

“Depend on abstractions” IMPROVE ECOSYSTEM - ABSTRACTIONS

Slide 62

Slide 62 text

PSR interface packages Virtual packages IMPROVE ECOSYSTEM - ABSTRACTIONS

Slide 63

Slide 63 text

Adapter packages IMPROVE ECOSYSTEM - ABSTRACTIONS

Slide 64

Slide 64 text

Looking at Flysystem IMPROVE ECOSYSTEM - ABSTRACTIONS

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

Flysystem contains AdapterInterface IMPROVE ECOSYSTEM - ABSTRACTIONS

Slide 69

Slide 69 text

class AwsS3Adapter implements AdapterInterface IMPROVE ECOSYSTEM - ABSTRACTIONS

Slide 70

Slide 70 text

Flysystem Gaufrette Omnipay … IMPROVE ECOSYSTEM - ABSTRACTIONS

Slide 71

Slide 71 text

“Depend on High level package, Let others decide the adapter” IMPROVE ECOSYSTEM - ABSTRACTIONS

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

http:/ /php-and-symfony.matthiasnoback.nl/2014/10/ composer-provide-and-dependency-inversion/ http:/ /php-and-symfony.matthiasnoback.nl/2014/04/ theres-no-such-thing-as-an-optional-dependency/ IMPROVE ECOSYSTEM - ABSTRACTIONS

Slide 74

Slide 74 text

Follow Semver “Depend on abstractions” IMPROVE ECOSYSTEM - RECAP

Slide 75

Slide 75 text

RECAP 1. Dependency managers 2. Composer 3. Improve ecosystem

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

Questions?

Slide 78

Slide 78 text

Thank you! https:/ /joind.in/13680 @hannesvdvreken

Slide 79

Slide 79 text

• http:/ /mwl.be • http:/ /getcomposer.org/doc • http:/ /slides.seld.be/?file=2015-02-19+Composer+... • https:/ /hannesvdvreken.com/2015/01/14/gitattr... • https:/ /hannesvdvreken.com/2015/01/18/comp... • https:/ /hannesvdvreken.com/2015/01/28/autol... • https:/ /packagist.org/search/?q=psr%2Flog • https:/ /leanpub.com/principles-of-package-design • http:/ /php-and-symfony.matthiasnoback.nl/2014/... • http:/ /php-and-symfony.matthiasnoback.nl/2014/... REFERENCES