The Dependency Management Problem
• App consists of many components
• Dependencies between components
• Optional components
• Compatibility of components
• Unique components per project
• Components management:
– Install
– Uninstall
– Update
No Dependency Manager / PEAR
First Magento CE Release!
2008
What’s Up with PEAR?
• PEAR – PHP Extension and Application Repository
• System-wide installation
• Strict package structure
• Bureaucracy
• PEAR channel hosting
• Dependency issues
• Usability issues
Magento 1.x Package Management
• Monolith release package
•
• Magento Connect Manager:
– Homegrown packaging format
– GUI for management
• PEAR for CLI management
• Vague module versioning
• Not versioned dependencies
Magento 1.x
release package
Feature Modules
Magento libraries
3rd party libraries
Design themes/skins
Localizations
Still No Dependency Manager
Module Manager “modman”
2010
Modman for Magento 1.x
• Modman – command line tool
• Keeps extensions separately from Magento
• Alternative packaging format
• CLI for management
• Use cases:
– Development
– Deployment
Magento 1.x
module package
Community module
modman
First Composer Release!
First Composer Use for Magento 1.x
Magento 2 Development in Progress
2012
Composer Overview
• Composer – dependency manager for PHP
• Composer – CLI tool
• Dependencies per project
• Versioned dependencies
• Package management:
– Install
– Uninstall
– Update
• Classes autoloading
Composer Basic Usage
1. Declaring project dependencies
composer.json
1. Installing dependencies
php composer.phar install
1. Autoloading dependencies
require 'vendor/autoload.php';
vendor/
autoload.php
Zend/…
…
my_project/
composer.json
Installation via Composer
1. Read composer.json
1. Read required packages
2. Read repositories
3. Append packagist.org to repositories
2. For each package:
1. Download from repository
2. Install dependencies recursively
3. Register plugin, if API implemented
Composer Adoption for Magento 1.x
• Composer plugin for Magento 1.x
magento-hackathon/magento-composer-installer
• Deployment strategies:
– Copy
– Move
– Symlink
• Modman packages support
• Composer packages repository
packages.firegento.com
Magento 1.x Composer Package Example
{
"name": "aoepeople/Aoe_Scheduler",
"type": "magento-module",
"description": "Magento Cron Scheduler",
"require": {
"magento-hackathon/magento-composer-installer": "*"
}
}
composer.json
Magento 1.x Composer Project Example
{
"require": {
"magento/core": "1.9.0.1",
"aoepeople/Aoe_Scheduler": "*",
"magento-hackathon/magento-composer-installer": "*"
},
"repositories": [
{
"type": "composer",
"url": "http://packages.firegento.com"
}
]
}
composer.json
Composer Adoption Obstacles in 1.x
• Monolith CE Composer package
• No strict versioning
• No module API version
• No theme version
• No locale version
• Files not in one directory:
– Module files
– Theme & skin files
magento/core
1.9.0.1
Feature Modules
Magento libraries
3rd party libraries
Design themes/skins
Localizations
composer.json
Composer is De Facto Standard
Projects Drop PEAR Support
Magento 2 Dev Beta Release
Composer Adoption for Magento 2
2014
Composer Adoption in Magento 2
• Prerequisites:
– Self-contained modules
– Self-contained themes
• Monolith Granular core packages
• Fork of the Composer plugin for 1.x
magento/magento-composer-installer
• Composer packages repository
packages.magento.com
Composer Package Types in Magento 2
• Package type defines files destination
• Implemented by the Composer plugin
• Custom package types:
magento2-module
magento2-theme
magento2-language
magento2-library
magento2-component
app/code/
app/design/
app/i18n/
lib/internal/
/
Composer Packages in Magento 2
magento/module-catalog
composer.json
Module
magento/theme-frontend-luma
composer.json
Theme
monolog/monolog
composer.json
3rd party library
magento/language-it_it
composer.json
Localization
Composer Packages in Magento 2
magento/zendframework1
composer.json
3rd party library fork
magento/magento2-base
composer.json
Application skeleton
magento/framework
composer.json
Framework
Magento 2 Module Package Example
{
"name": "magento/module-catalog",
"require": {
"php": "~5.5.0|~5.6.0",
"magento/module-store": "0.42.0-beta9",
"magento/framework": "0.42.0-beta9",
"magento/magento-composer-installer": "*"
},
"type": "magento2-module",
"version": "0.42.0-beta9",
"extra": {
"map": [
["*", "Magento/Catalog"]
]
}
}
composer.json
app/code/
Magento/Catalog/
Core Changes
for Composer Adoption
Module Versioning in Magento 2
• Composer requires semantic versioning
semver.org
• Adoption of Semantic Version 2.0.0
<major>.<minor>.<patch>[-<suffix>]
<major> – Incompatible API changes
<minor> – Add functionality in BC manner
<patch> – BC bug fixes
<suffix> – Stability
Module Version Declaration
Magento 1.x module
config.xml
etc/
Version, not semantic
DB schema version
API version, semantic
Magento 2 module package
module.xml
etc/
composer.json
Module Dependencies Declaration
Magento 1.x module
config.xml
etc/
Magento 2 module package
module.xml
etc/
composer.json
Dependencies
ordered, not versioned
Dependencies
not ordered, versioned
Modules order
Magento 2 Repositories
github.com
magento/magento2 – CE mainline
magento/magento2-community-edition – CE Composer project
magento/magento-composer-installer – Composer plugin
magento/zf1 – Fork of Zend Framework 1.x
Results of Composer Adoption
• Granular core packages
• Semantic versioning
• Versioned dependencies
• Theme dependencies
• Locale dependencies
• Validation of environment
– PHP version
– PHP libraries
Resources
• Magento 2
– devdocs.magento.com – Developer documentation
– github.com/magento/magento2 – CE mainline repository
– github.com/magento/magento2-community-edition – CE Composer
project
– github.com/magento/magento-composer-installer – Composer plugin
– packages.magento.com – Composer packages repository
• Magento 1.x
– github.com/magento-hackathon/magento-composer-installer – Composer
plugin
– packages.firegento.com – Composer packages repository
• Composer
– getcomposer.org – Composer tool
– packagist.org – Composer packages repository
– semver.org – Semantic versioning
Q: When is Magento 2 Release?
A: Magento 2 release schedule:
1. Q4 2014 – Dev Beta  Released Dec 17, 2014
2. Q1 2015 – Dev RC
3. Q3 2015 – Merchant Beta
4. Q4 2015 – Merchant GA
Thank You!
Q & A
Sergii Shymko
sergey@shymko.net

Sergii Shymko: Magento 2: Composer for Extensions Distribution

  • 2.
    The Dependency ManagementProblem • App consists of many components • Dependencies between components • Optional components • Compatibility of components • Unique components per project • Components management: – Install – Uninstall – Update
  • 3.
    No Dependency Manager/ PEAR First Magento CE Release! 2008
  • 4.
    What’s Up withPEAR? • PEAR – PHP Extension and Application Repository • System-wide installation • Strict package structure • Bureaucracy • PEAR channel hosting • Dependency issues • Usability issues
  • 5.
    Magento 1.x PackageManagement • Monolith release package • • Magento Connect Manager: – Homegrown packaging format – GUI for management • PEAR for CLI management • Vague module versioning • Not versioned dependencies Magento 1.x release package Feature Modules Magento libraries 3rd party libraries Design themes/skins Localizations
  • 6.
    Still No DependencyManager Module Manager “modman” 2010
  • 7.
    Modman for Magento1.x • Modman – command line tool • Keeps extensions separately from Magento • Alternative packaging format • CLI for management • Use cases: – Development – Deployment Magento 1.x module package Community module modman
  • 8.
    First Composer Release! FirstComposer Use for Magento 1.x Magento 2 Development in Progress 2012
  • 9.
    Composer Overview • Composer– dependency manager for PHP • Composer – CLI tool • Dependencies per project • Versioned dependencies • Package management: – Install – Uninstall – Update • Classes autoloading
  • 10.
    Composer Basic Usage 1.Declaring project dependencies composer.json 1. Installing dependencies php composer.phar install 1. Autoloading dependencies require 'vendor/autoload.php'; vendor/ autoload.php Zend/… … my_project/ composer.json
  • 11.
    Installation via Composer 1.Read composer.json 1. Read required packages 2. Read repositories 3. Append packagist.org to repositories 2. For each package: 1. Download from repository 2. Install dependencies recursively 3. Register plugin, if API implemented
  • 12.
    Composer Adoption forMagento 1.x • Composer plugin for Magento 1.x magento-hackathon/magento-composer-installer • Deployment strategies: – Copy – Move – Symlink • Modman packages support • Composer packages repository packages.firegento.com
  • 13.
    Magento 1.x ComposerPackage Example { "name": "aoepeople/Aoe_Scheduler", "type": "magento-module", "description": "Magento Cron Scheduler", "require": { "magento-hackathon/magento-composer-installer": "*" } } composer.json
  • 14.
    Magento 1.x ComposerProject Example { "require": { "magento/core": "1.9.0.1", "aoepeople/Aoe_Scheduler": "*", "magento-hackathon/magento-composer-installer": "*" }, "repositories": [ { "type": "composer", "url": "http://packages.firegento.com" } ] } composer.json
  • 15.
    Composer Adoption Obstaclesin 1.x • Monolith CE Composer package • No strict versioning • No module API version • No theme version • No locale version • Files not in one directory: – Module files – Theme & skin files magento/core 1.9.0.1 Feature Modules Magento libraries 3rd party libraries Design themes/skins Localizations composer.json
  • 16.
    Composer is DeFacto Standard Projects Drop PEAR Support Magento 2 Dev Beta Release Composer Adoption for Magento 2 2014
  • 17.
    Composer Adoption inMagento 2 • Prerequisites: – Self-contained modules – Self-contained themes • Monolith Granular core packages • Fork of the Composer plugin for 1.x magento/magento-composer-installer • Composer packages repository packages.magento.com
  • 18.
    Composer Package Typesin Magento 2 • Package type defines files destination • Implemented by the Composer plugin • Custom package types: magento2-module magento2-theme magento2-language magento2-library magento2-component app/code/ app/design/ app/i18n/ lib/internal/ /
  • 19.
    Composer Packages inMagento 2 magento/module-catalog composer.json Module magento/theme-frontend-luma composer.json Theme monolog/monolog composer.json 3rd party library magento/language-it_it composer.json Localization
  • 20.
    Composer Packages inMagento 2 magento/zendframework1 composer.json 3rd party library fork magento/magento2-base composer.json Application skeleton magento/framework composer.json Framework
  • 21.
    Magento 2 ModulePackage Example { "name": "magento/module-catalog", "require": { "php": "~5.5.0|~5.6.0", "magento/module-store": "0.42.0-beta9", "magento/framework": "0.42.0-beta9", "magento/magento-composer-installer": "*" }, "type": "magento2-module", "version": "0.42.0-beta9", "extra": { "map": [ ["*", "Magento/Catalog"] ] } } composer.json app/code/ Magento/Catalog/
  • 22.
  • 23.
    Module Versioning inMagento 2 • Composer requires semantic versioning semver.org • Adoption of Semantic Version 2.0.0 <major>.<minor>.<patch>[-<suffix>] <major> – Incompatible API changes <minor> – Add functionality in BC manner <patch> – BC bug fixes <suffix> – Stability
  • 24.
    Module Version Declaration Magento1.x module config.xml etc/ Version, not semantic DB schema version API version, semantic Magento 2 module package module.xml etc/ composer.json
  • 25.
    Module Dependencies Declaration Magento1.x module config.xml etc/ Magento 2 module package module.xml etc/ composer.json Dependencies ordered, not versioned Dependencies not ordered, versioned Modules order
  • 26.
    Magento 2 Repositories github.com magento/magento2– CE mainline magento/magento2-community-edition – CE Composer project magento/magento-composer-installer – Composer plugin magento/zf1 – Fork of Zend Framework 1.x
  • 27.
    Results of ComposerAdoption • Granular core packages • Semantic versioning • Versioned dependencies • Theme dependencies • Locale dependencies • Validation of environment – PHP version – PHP libraries
  • 28.
    Resources • Magento 2 –devdocs.magento.com – Developer documentation – github.com/magento/magento2 – CE mainline repository – github.com/magento/magento2-community-edition – CE Composer project – github.com/magento/magento-composer-installer – Composer plugin – packages.magento.com – Composer packages repository • Magento 1.x – github.com/magento-hackathon/magento-composer-installer – Composer plugin – packages.firegento.com – Composer packages repository • Composer – getcomposer.org – Composer tool – packagist.org – Composer packages repository – semver.org – Semantic versioning
  • 29.
    Q: When isMagento 2 Release? A: Magento 2 release schedule: 1. Q4 2014 – Dev Beta  Released Dec 17, 2014 2. Q1 2015 – Dev RC 3. Q3 2015 – Merchant Beta 4. Q4 2015 – Merchant GA
  • 30.
    Thank You! Q &A Sergii Shymko sergey@shymko.net

Editor's Notes

  • #4 Magento Community Edition 1.? Release
  • #5 PEAR – framework & distribution system PEAR – reusable general-purpose libraries System-wide installation by default
  • #10 Semantic package versioning
  • #11 Directory ‘vendor’
  • #12 Call Composer plugin API, if implemented by a package
  • #13 Plugin developed by community at Magento bugathon Plugin is published at Packagist
  • #16 Not semantic module versioning DB schema version, but no module API version Single Composer package for CE release
  • #17 Doctrine, Symfony2, PHPUnit drop PEAR support
  • #18 Self-contained modules/themes – all files in one directory Forked the hackathon Composer plugin for Magento 1.x to adopt for Magento 2
  • #20 Forked the hackathon Composer plugin for Magento 1.x to adopt for Magento 2
  • #21 Forked the hackathon Composer plugin for Magento 1.x to adopt for Magento 2
  • #24 BC – backward-compatibility <suffix> – dev, patch/p, alpha/a, beta/b, RC
  • #28 PHP library dependencies, such as Imagemagic, Mcrypt, etc. Theme dependencies on 3rd party libs, such as Angular.js, jQuery carousel, etc.
  • #30 RC – Release Candidate GA – General Availability