30
Sylvain Rayé - Meet Magento Italy 2014 1

Manage magento dependencies with composer

Embed Size (px)

DESCRIPTION

If you have to deal with several Magento projects, you probably know how it is painful to manage dependencies and getting and installing extensions for your projects. Composer is a solution largely used in PHP world but not very known in the Magento community. This tool can helps you to improve your productivity and make your life easier if it’s used correctly… This is what we will see together. Main message: The Magento composer project is the perfect example which shows that the community can bring great enhancement to Magento projects.

Citation preview

Page 1: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 20141

Page 2: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 20142

ABOUT SYLVAIN RAYÉ

• Founder / Senior & Certified Magento Developer by Diglin GmbH

• CTO by rissip GmbH

• Board member of Firegento Association (German Magento community)

• Organizer Hackathons / Meet Magento Switzerland (24.10.2014)

Page 3: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 20143

COMPOSERhttp://getcomposer.org

http://packagist.org

Page 4: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 2014

• Manage dependencies

• Code reuse

• Code Sharing

• Easy to clean uninstall

• Easy upgrade

• Works with GIT/SVN or TAR or filesystem

• Multiplatform (Windows, *nix, OSX)

X

COMPOSER ?

Page 5: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 2014X

COMPOSERcurl -sS https://getcomposer.org/installer | php

mv composer.phar /usr/local/bin/composer

Page 6: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 20144

COMPOSER.JSON

Page 7: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 2014

• ..

5

COMPOSER.JSON

Project / Dependency levels

Page 8: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 20146

COMPOSER PHARinit

search require validate

install update

show help

Page 9: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 20147

COMPOSER INSTALL / UPDATE├── app ├── src ├── web ├── … ├── composer.json ├── composer.lock └── vendor ├── composer ├── autoload.php ├── bin ├── mongo ├── doctrine ├── …

Page 10: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 20148

MAGENTO MODULES├── app │   ├── code │   │   ├── community │   │   │   ├── NAMESPACE │   │   │   │   ├── MODULENAME │   │   │   │   │   ├── Helper │   │   │   │   │   ├── Model │   │   │   │   │   └── … │   ├── design │   │   ├── frontend │   │   │   └── base │   │   │   ├── default │   │   │   │   ├── layout │   │   │   │   │   ├── modulename.xml │   │   │   │   └── template │   │   │   │   ├── modulename │   ├── etc │   │   └── modules │   │   ├── Namespace_Modulename.xml │   └── locale ├── js ├── skin └── …

Magento 1

Page 11: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 20148

MAGENTO MODULES

├── app │   ├── code │   │   ├── NAMESPACE │   │   │   ├── MODULENAME │   │   │   │   ├── Block │   │   │   │   ├── Controller │   │   │   │   ├── Helper │   │   │   │   ├── Model │   │   │   │   ├── etc │   │   │   │   ├── i18n │   │   │   │   ├── views │   │   │   │   └── … ├── lib ├── pub └── …

Magento 2

├── app │   ├── code │   │   ├── community │   │   │   ├── NAMESPACE │   │   │   │   ├── MODULENAME │   │   │   │   │   ├── Helper │   │   │   │   │   ├── Model │   │   │   │   │   └── … │   ├── design │   │   ├── frontend │   │   │   └── base │   │   │   ├── default │   │   │   │   ├── layout │   │   │   │   │   ├── modulename.xml │   │   │   │   └── template │   │   │   │   ├── modulename │   ├── etc │   │   └── modules │   │   ├── Namespace_Modulename.xml │   └── locale ├── js ├── skin └── …

Magento 1

Page 12: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 20149

http://packages.firegento.com

https://github.com/magento-hackathon/magento-composer-installer

MAGENTO COMPOSER

Page 13: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201410

PACKAGES.FIREGENTO.COM

Page 14: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201411

COMPOSER.JSONProject level

{ "require": { "magento-hackathon/magento-composer-installer": "*", … }, "repositories": [ { "type": "vcs", "url": "https://github.com/magento-hackathon/magento-composer-installer" }, … ], "extra": { "magento-root-dir": "./src", "magento-deploystrategy": "copy", "magento-force" : "override", … } }

Page 15: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201412

COMPOSER.JSONProject level

{ "require": { "magento-hackathon/magento-composer-installer": "*", "connect20/mage_all_latest": "1.8.1.0", "diglin/diglin_username": "2.*" }, "repositories": [ { "type": "vcs", "url": "https://github.com/magento-hackathon/magento-composer-installer" }, { "type": "composer", "url": "http://packages.firegento.com" } ], "extra": { "magento-root-dir": "./src", "magento-deploystrategy": "copy", "magento-force" : "override" } }

Page 16: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201413

MAGENTO COMPOSER OPTIONSUnder extra option in composer.json

‘magento-root-dir’: ‘../src’ ‘modman-root-dir’: ‘.modman’ ‘magento-force’: true ‘path-mapping-translations’: {…} ‘magento-map-overwrite’: {…} ‘auto-append-gitignore’: true ‘magento-deploy-ignore’: {…} ‘magento-deploy-sort-priority’: {…} ‘magento-deploystrategy’: ‘copy’ ‘magento-deploystrategy-overwrite’: {…} (beta)

Page 17: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201414

DEPLOY STRATEGY

NONE COPY

SYMLINK LINK (hardlink)

Page 18: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201415

PUBLISH YOUR EXTENSION

Page 19: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201416

YOUR OWN PACKAGE REPOSITORY

SATIS PACKAGIST

Page 20: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201417

PUBLISH YOUR EXTENSION

Page 21: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201417

PUBLISH YOUR EXTENSION

Page 22: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201418

PUBLISH YOUR EXTENSIONComposer.json on dependency level

Page 23: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201418

PUBLISH YOUR EXTENSIONComposer.json on dependency level

New type

Page 24: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201418

PUBLISH YOUR EXTENSIONComposer.json on dependency level

New type

Dependencies

Page 25: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201419

PUBLISH YOUR EXTENSION

MAP in composer.json PACKAGE.XML MODMAN FILE

Mapping

Page 26: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201420

PUBLISH YOUR EXTENSIONModman file

Page 27: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201421

PUBLISH YOUR EXTENSION• Execute "git tag -a 1.0.0" & "git push --tags"

• Fork the https://github.com/magento-hackathon/composer-repository

• Edit satis.json

!

!

• Execute "composer validate"

• Commit & Pull request to the original repository

Page 28: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201421

PUBLISH YOUR EXTENSION• Execute "git tag -a 1.0.0" & "git push --tags"

• Fork the https://github.com/magento-hackathon/composer-repository

• Edit satis.json

!

!

• Execute "composer validate"

• Commit & Pull request to the original repository

Page 29: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 201422

PEAR IS DEAD! HOORAY TO COMPOSER

Page 30: Manage magento dependencies with composer

Sylvain Rayé - Meet Magento Italy 2014X

LINKS• https://github.com/composer/

• http://packagist.org

• https://github.com/magento-hackathon/magento-composer-installer

• https://github.com/magento-hackathon/composer-command-integrator/

• http://packages.firegento.com

• https://github.com/magento-hackathon/composer-repository

• https://plus.google.com/u/0/events/cp21bnv8vnahprcbm4c5k4laceg - nice talk about composer strategies

• http://magebase.com/magento-tutorials/composer-with-magento/ - tutorial from Vinai