Wiring Magento Projects
Magento Fireside Chat
Google+ Hangout - March 20, 2014
Intro – Fabrizio Branca (@fbrnc)
Composer – Fabrizio Branca (@fbrnc)
Magento Composer Installer – Bastian Ike (@b_ike)
Lightweight approach – Fabrizio Branca (@fbrnc)
Experimental approach – Daniel Fahlke (@flyingmana)
Different approach – Rolando Granadino (@beeplogic)
Ben’s approach – Ben Marks (@benmarks)
? – You!
Q&A
Agenda
the problem
Intro
htdocs
<Name>
<theme>
layout
template
code
design
etc
locale
<area>
core
community
local
<area>
<language>
modules
<package>
<Namespace>
<package>
*.xml
*.csv
<theme>
app
skin
lib
Module2
default
layout
template
code
design
etc
locale
frontend
local
frontend
de_DE
modules
base
My
base
My_Module2.xml
My_Module2.csv
default
app
skin
etc, Block, …
js, css, img, …
my_module2
my_module2
Magento My_Module
My_Module2
Module
default
layout
template
code
design
etc
locale
frontend
local
frontend
de_DE
modules
base
My
base
My_Module.xml
My_Module.csv
default
app
skin
etc, Block, …
js, css, img, …
my_module
my_module
htdocs
Module
default
layout
template
code
design
etc
locale
local
frontend
de_DE
modules
My
base
*.xml
app
My_Module2.xml
My_Module2.csv
my_module2
My_Module.xml
My_Module.csv
etc, Block, …
my_module
Module2
etc, Block, …
my_module2
my_module
Magento 2
pub
Module
code
My
app
Magento
My_Module
My_Module2
view
Controller
etc
i18n
Block
…
Module2
view
Controller
etc
i18n
Block
…
Magento 2
the requirements
Intro
• Reuse modules
• Share modules
• Easy and clean uninstall without leftovers
• Non-destructive (no deletion of files)
• Clean Magento vanilla code
• Work collaboratively on projects
• Restrict access to modules for team members
• Independent versioning scheme of modules
• Independent version control origin
the requirements
a solution
Intro
modman
by @colinmollenhour
htdocs
code
core
community
local
app
app/code/…/My/Module
.modman
My_Module
app/design/…
skin/frontend/…
app/etc/modules/My_Module.xml
modman
app/code/…/My/Module
My_Module2
app/design/…
skin/frontend/…
app/etc/modules/My_Module.xml
modman
<theme>
layout
template
design
etc
locale
<area>
<language>
modules
<package>
*.xml
modman
“wiring”
Intro
modman “connects” existing modules to the Magento core,
but how do we manage them?
htdocs
code
core
community
local
app
app/code/…/My/Module
.modman
My_Module
app/design/…
skin/frontend/…
app/etc/modules/My_Module.xml
modman
app/code/…/My/Module
My_Module2
app/design/…
skin/frontend/…
app/etc/modules/My_Module.xml
modman
<theme>
layout
template
design
etc
locale
<area>
<language>
modules
<package>
*.xml
Components
tools
n98-magerun.phar
phpunit.phar
modman
EnvSettingsTool
composer.phar
htdocs
.modman
Configuration
Installer
(Metadata, Doc,…)
My_Module
My_Module2
app,…
and usually there’s
even more stuff…
These should come
from different origins
svn:externals
Git submodules
Phing/Ant
Custom scripts
Composer
Components
Options
works fine, but needs
some getting used to it
Composer
Intro
in a nutshell…
Composer“Composer is a tool for dependency management in PHP. It allows you to declare
the dependent libraries your project needs and it will install them in your project
for you.”
phar file
json configuration
supports Git, SVN, tar,…
and mix’n’match
package
management
Dependency management
(including fine-grained
control over specific versions,…)
Autoloader
theHackathon installer approach
Approach
Magento Composer
Installer
Overview
• Aims to provide an easy way to install Magento
modules via composer (instead of e.g. modman)
• Community driven, initial started by the Magento
Hackathon
• Main component: magento-hackathon/magento-
composer-installer
Components
• Magento Composer installer
• Package repository
• Compatible with package.xml, modman and
manual file mapping paths
• Possible to bootstrap the Magento core, but not
recommended
Using Magento+Composer
{	
"minimum-stability": "dev",	
"require": {	
"fbrnc/aoe_templatehints": "*"	
},	
"repositories": [	
{	
"type": "composer",	
"url": "http://packages.firegento.com"	
}	
],	
"extra": {	
"magento-root-dir": "htdocs/",	
"auto-append-gitignore": true	
}	
}
Using Magento+Composer
{	
"minimum-stability": "dev",	
"require": {	
"fbrnc/aoe_templatehints": "*"	
},	
"repositories": [	
{	
"type": "composer",	
"url": "http://packages.firegento.com"	
}	
],	
"extra": {	
"magento-root-dir": "htdocs/",	
"auto-append-gitignore": true	
}	
}	
Include dev-versions,
not just final releases
Using Magento+Composer
{	
"minimum-stability": "dev",	
"require": {	
"fbrnc/aoe_templatehints": "*"	
},	
"repositories": [	
{	
"type": "composer",	
"url": "http://packages.firegento.com"	
}	
],	
"extra": {	
"magento-root-dir": "htdocs/",	
"auto-append-gitignore": true	
}	
}	
List of required packages
with the required version
* = newest version
!
!
See composer manual for
version syntax
Using Magento+Composer
{	
"minimum-stability": "dev",	
"require": {	
"fbrnc/aoe_templatehints": "*"	
},	
"repositories": [	
{	
"type": "composer",	
"url": "http://packages.firegento.com"	
}	
],	
"extra": {	
"magento-root-dir": "htdocs/",	
"auto-append-gitignore": true	
}	
}	
Include the Firegento
Package Repository
Using Magento+Composer
{	
"minimum-stability": "dev",	
"require": {	
"fbrnc/aoe_templatehints": "*"	
},	
"repositories": [	
{	
"type": "composer",	
"url": "http://packages.firegento.com"	
}	
],	
"extra": {	
"magento-root-dir": "htdocs/",	
"auto-append-gitignore": true	
}	
}	
Installation-specific
configuration
extra
• magento-root-dir: Where your Magento installation lives
• magento-deploystrategy:
• symlink: symlink into Magento
• link: hardlink into Magento
• copy: copy the files instead of linking
• none: no automatic deployment, if you want to use e.g. modman
• auto-append-gitignore: add deployed files to .gitignore in the Magento folder
• modman-root-dir: Use e.g. .modman/ instead of vendor/
composer install
Publishing packages
• Add a composer.json to your extension
• Publish your extension on github
• Add it to packages.firegento.com
composer.json
{	
"name": "fbrnc/Aoe_TemplateHints",	
"license": "OSL-3.0",	
"type": "magento-module",	
"description": "Advanced Template Hints for Magento",	
"homepage": "http://www.fabrizio-branca.de/magento-advanced-template-
hints-20.html",	
"require": {	
"magento-hackathon/magento-composer-installer": "*"	
},	
"authors":[	
{	
"name":"Fabrizio Branca",	
"email":"mail@{firstname}-{lastname}.de"	
}	
]	
}
composer.json
{	
"name": "fbrnc/Aoe_TemplateHints",	
"license": "OSL-3.0",	
"type": "magento-module",	
"description": "Advanced Template Hints for Magento",	
"homepage": "http://www.fabrizio-branca.de/magento-advanced-template-
hints-20.html",	
"require": {	
"magento-hackathon/magento-composer-installer": "*"	
},	
"authors":[	
{	
"name":"Fabrizio Branca",	
"email":"mail@{firstname}-{lastname}.de"	
}	
]	
}
Metadata:
Author, Website, etc
composer.json
{	
"name": "fbrnc/Aoe_TemplateHints",	
"license": "OSL-3.0",	
"type": "magento-module",	
"description": "Advanced Template Hints for Magento",	
"homepage": "http://www.fabrizio-branca.de/magento-advanced-template-
hints-20.html",	
"require": {	
"magento-hackathon/magento-composer-installer": "*"	
},	
"authors":[	
{	
"name":"Fabrizio Branca",	
"email":"mail@{firstname}-{lastname}.de"	
}	
]	
}
type: magento-module
!
This line activates the
magento-composer-installer
during composer install
composer.json
{	
"name": "fbrnc/Aoe_TemplateHints",	
"license": "OSL-3.0",	
"type": "magento-module",	
"description": "Advanced Template Hints for Magento",	
"homepage": "http://www.fabrizio-branca.de/magento-advanced-template-
hints-20.html",	
"require": {	
"magento-hackathon/magento-composer-installer": "*"	
},	
"authors":[	
{	
"name":"Fabrizio Branca",	
"email":"mail@{firstname}-{lastname}.de"	
}	
]	
}
Requirements
composer.json
{	
"name": "fbrnc/Aoe_TemplateHints",	
"license": "OSL-3.0",	
"type": "magento-module",	
"description": "Advanced Template Hints for Magento",	
"homepage": "http://www.fabrizio-branca.de/magento-advanced-template-
hints-20.html",	
"require": {	
"magento-hackathon/magento-composer-installer": "*"	
},	
"authors":[	
{	
"name":"Fabrizio Branca",	
"email":"mail@{firstname}-{lastname}.de"	
}	
]	
}
Involved Authors
Package Repository
{ "type": "vcs", "url": "git://github.com/colinmollenhour/
Cm_Cache_Backend_Mongo.git" },	
{ "type": "vcs", "url": "git://github.com/colinmollenhour/
Cm_Cache_Backend_Redis.git" },	
{ "type": "vcs", "url": "git://github.com/colinmollenhour/Cm_RedisSession.git" },	
{ "type": "vcs", "url": "git://github.com/colinmollenhour/Cm_Diehard.git" },	
{ "type": "vcs", "url": "git://github.com/fbrnc/Aoe_Scheduler.git" },	
{ "type": "vcs", "url": "git://github.com/fbrnc/Aoe_Profiler.git" },	
{ "type": "vcs", "url": "git://github.com/fbrnc/Aoe_TemplateHints.git" },	
{ "type": "vcs", "url": "git://github.com/fbrnc/Aoe_ReuseImages.git" },	
{ "type": "vcs", "url": "git://github.com/fbrnc/Aoe_ManageStores.git" },
Add your Repository
to satis.json and open
a pull request
https://github.com/magento-hackathon/composer-repository/
Package.xml? modman?
JSON-mapping
• package.xml: Used by Magento Connect
• modman: Used by modman, imho best solution.

No support for shell scripts!
• json-mapping:
"map": [	
["themes/default/skin", "public/skin/frontend/foo/default"],	
["themes/default/design", "public/app/design/frontend/foo/default"],	
["modules/My_Module/My_Module.xml", "public/app/etc/modules/My_Module.xml"],	
["modules/My_Module/code", "public/app/code/local/My/Module"],	
["modules/My_Module/frontend/layout/mymodule.xml", "public/app/design/frontend/base/default/
layout/mymodule.xml"]	
]
That's it :)
Links
• https://getcomposer.org/
• https://github.com/magento-hackathon/magento-
composer-installer/
• https://github.com/magento-hackathon/composer-
repository/
• http://packages.firegento.com/
• http://magebase.com/magento-tutorials/composer-
with-magento/
Fabrizio’s lightweightapproach
Approach
@fbrnc
Keeping it Simple!
AOEpeople/composer-installers
"replace": { "magento-hackathon/magento-composer-installer":"*" }
“inspired” by
composer/installers
“magento-module” “magento-source”
handles package types
<?php
namespace AoepeopleComposerInstallers;
class MagentoInstaller extends BaseInstaller
{
protected $locations = array(
'module' => '.modman/{$name}/',
'source' => 'htdocs/'
);
}
AOEpeople/composer-installers
• Fully compatible with magento-hackathon/magento-composer-installer
• Adds support for type “magento-source”
• Only puts packages into place
• Native modman script is used to deploy modules
• Wrapped in a simple installer script
AOEpeople/composer-installers
{
{
"minimum-stability":"dev",
"require":{
"aoepeople/composer-installers": "*",
"fbrnc/aoe_scheduler": "*",
"fbrnc/aoe_cachecleaner": "*",
"aoemedia/magento_enterprise": "1.13.1.0",
"aoemedia/envsettingstool": "*"
},
"config": {
"bin-dir": "bin"
}
}
AOEpeople/composer-installers
replaces
Hackathon
Installer
some
modules
Vanilla
Magento
Source
Tools,…
htdocs
code
core
community
local
app
app/code/…/My/Module
.modman
My_Module
app/design/…
skin/frontend/…
app/etc/modules/My_Module.xml
modman
app/code/…/My/Module
My_Module2
app/design/…
skin/frontend/…
app/etc/modules/My_Module.xml
modman
<theme>
layout
template
design
etc
locale
<area>
<language>
modules
<package>
*.xml
Components
Build
Workflow
Unit Tests,…
• git clone
• Add some metadata (build
number, master system,
package type)
• (Run Composer)
• (Run modman)
• Packaging
• Tagging
Deployment & Installation
Workflow
Update local
copy of the
“systemstorage”
Move files to
new release
folder
Download build
package from
Jenkins
Extract build
package
Run installer
Create symlinks
to var/ and
media/
Is
master
?
Import
systemstorage
(db and media/)
Run Composer Run modman
Apply settings Fix permissions
Update
symlinks
Delete old
releases
install.sh
deploy.sh
Directory layoutvar
var
<projectName>
releases
<environmentName>
shared
www
media
build_117
build_118
build_119
.modman
htdocs
Configuration
tools
install.sh
app,…
var
media
previous
latest
current
next
My_Module
My_Module2
Webroot:
/var/www/<projectName>/<environmentName>/current/htdocs
Daniel’s experimental approach
Approach
@Flyingmana
http://flyingmana.name/slides/magento-wizards_fugue-introduction.html
Rolando’s different approach
Approach
@beeplogic
http://slid.es/beeplogic/magesync
Ben’s approach
Approach
@benmarks
Thank you!
Any questions?
http://www.youtube.com/watch?v=bscXyCy4fHc
Watch the recording!

Magento Fireside Chat: "Wiring Mageno Projects"