magento fireside chat: "wiring mageno projects"

56
Wiring Magento Projects Magento Fireside Chat Google+ Hangout - March 20, 2014

Upload: aoe

Post on 06-May-2015

1.368 views

Category:

Technology


1 download

DESCRIPTION

Slides of the Magento Fireside Chat March 20th, 2014 with Fabrizio Branca (@fbrnc) Bastian Ike (@b_ike) Daniel Fahlke (@flyingmana) Rolando Granadino (@beeplogic) Ben Marks (@benmarks)

TRANSCRIPT

Page 1: Magento Fireside Chat: "Wiring Mageno Projects"

Wiring Magento Projects Magento Fireside Chat

Google+ Hangout - March 20, 2014

Page 2: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 3: Magento Fireside Chat: "Wiring Mageno Projects"

the problem Intro

Page 4: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 5: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 6: Magento Fireside Chat: "Wiring Mageno Projects"

Magento 2

Page 7: Magento Fireside Chat: "Wiring Mageno Projects"
Page 8: Magento Fireside Chat: "Wiring Mageno Projects"

pub

Module

code

My

app

Magento

My_Module

My_Module2

view

Controller

etc

i18n

Block

Module2

view

Controller

etc

i18n

Block

Magento 2

Page 9: Magento Fireside Chat: "Wiring Mageno Projects"

the requirements Intro

Page 10: Magento Fireside Chat: "Wiring Mageno Projects"

• 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

Page 11: Magento Fireside Chat: "Wiring Mageno Projects"

a solution Intro

Page 12: Magento Fireside Chat: "Wiring Mageno Projects"

modman

by @colinmollenhour

Page 13: Magento Fireside Chat: "Wiring Mageno Projects"

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>

<area>

<language>

modules

<package>

<package>

*.xml

*.csv

<theme>

skin

modman

Page 14: Magento Fireside Chat: "Wiring Mageno Projects"

“wiring” Intro

modman “connects” existing modules to the Magento core, but how do we manage them?

Page 15: Magento Fireside Chat: "Wiring Mageno Projects"

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>

<area>

<language>

modules

<package>

<package>

*.xml

*.csv

<theme>

skin

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

Page 16: Magento Fireside Chat: "Wiring Mageno Projects"

svn:externals

Git submodules

Phing/Ant

Custom scripts

Composer

Components Options

works fine, but needs some getting used to it

Page 17: Magento Fireside Chat: "Wiring Mageno Projects"

Composer Intro

in a nutshell…

Page 18: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 19: Magento Fireside Chat: "Wiring Mageno Projects"

the Hackathon installer approach

Approach

Page 20: Magento Fireside Chat: "Wiring Mageno Projects"

Magento Composer Installer

Page 21: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 22: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 23: Magento Fireside Chat: "Wiring Mageno Projects"

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 }}

Page 24: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 25: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 26: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 27: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 28: Magento Fireside Chat: "Wiring Mageno Projects"

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/

Page 29: Magento Fireside Chat: "Wiring Mageno Projects"

composer install

Page 30: Magento Fireside Chat: "Wiring Mageno Projects"

Publishing packages

• Add a composer.json to your extension

• Publish your extension on github

• Add it to packages.firegento.com

Page 31: Magento Fireside Chat: "Wiring Mageno Projects"

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" } ]}

Page 32: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 33: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 34: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 35: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 36: Magento Fireside Chat: "Wiring Mageno Projects"

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/

Page 37: Magento Fireside Chat: "Wiring Mageno Projects"

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"] ]

Page 38: Magento Fireside Chat: "Wiring Mageno Projects"

That's it :)

Page 39: Magento Fireside Chat: "Wiring Mageno Projects"

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/

Page 40: Magento Fireside Chat: "Wiring Mageno Projects"

Fabrizio’s lightweight approach

Approach

@fbrnc

Page 41: Magento Fireside Chat: "Wiring Mageno Projects"

Keeping it Simple!

Page 42: Magento Fireside Chat: "Wiring Mageno Projects"

AOEpeople/composer-installers "replace": { "magento-hackathon/magento-composer-installer":"*" }

“inspired” by composer/installers

“magento-module” “magento-source”

handles package types

Page 43: Magento Fireside Chat: "Wiring Mageno Projects"

<?php namespace Aoepeople\ComposerInstallers; class MagentoInstaller extends BaseInstaller { protected $locations = array( 'module' => '.modman/{$name}/', 'source' => 'htdocs/' ); }

AOEpeople/composer-installers

Page 44: Magento Fireside Chat: "Wiring Mageno Projects"

• 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

Page 45: Magento Fireside Chat: "Wiring Mageno Projects"

{ { "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,…

Page 46: Magento Fireside Chat: "Wiring Mageno Projects"

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>

<area>

<language>

modules

<package>

<package>

*.xml

*.csv

<theme>

skin

Components

Page 47: Magento Fireside Chat: "Wiring Mageno Projects"

Build Workflow

Unit Tests,…

• git clone

• Add some metadata (build

number, master system,

package type)

• (Run Composer)

• (Run modman)

• Packaging

• Tagging

Page 48: Magento Fireside Chat: "Wiring Mageno Projects"

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

Page 49: Magento Fireside Chat: "Wiring Mageno Projects"

Directory layout var

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

Page 50: Magento Fireside Chat: "Wiring Mageno Projects"

Daniel’s experimental approach

Approach @Flyingmana

Page 51: Magento Fireside Chat: "Wiring Mageno Projects"

http://flyingmana.name/slides/magento-wizards_fugue-introduction.html

Page 52: Magento Fireside Chat: "Wiring Mageno Projects"

Rolando’s different approach

Approach @beeplogic

Page 53: Magento Fireside Chat: "Wiring Mageno Projects"

http://slid.es/beeplogic/magesync

Page 54: Magento Fireside Chat: "Wiring Mageno Projects"

Ben’s approach

Approach @benmarks

Page 55: Magento Fireside Chat: "Wiring Mageno Projects"

Thank you! Any questions?

Page 56: Magento Fireside Chat: "Wiring Mageno Projects"

http://www.youtube.com/watch?v=bscXyCy4fHc

Watch the recording!