Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Harnessing the Power of
Composer with Magento 2
Why Composer?
Magento 2
2.0.0
2.0.1
2.0.2
2.0.3
2.0.4
2.0.5
2.0.6
2.0.7
2.0.8
2.0.9
2.0.10
2.0.11
2.0.12
2.0.13
Magento 2
2.1.0
2.1.1
2.1.2
2.1.3
...
2.0.0
2.0.1
2.0.2
2.0.3
2.0.4
2.0.5
2.0.6
2.0.7
2.0.8
2.0.9
2.0.10
2.0.11
2.0.12
2.0.13
Magento 2
2.1.0
2.1.1
2.1.2
2.1.3
...
Now add extensions
Has had 2 releases
1.0.0
Compatible with Magento 2.0.2 and 2.0.3
2.0.0
Compatible with Magento 2.1.1 through to 2.1.5
Must...
Has had 2 releases
1.0.0
Compatible with Magento 2.0.0
2.0.0
Compatible with Magento 2.0.0, 2.0.1, 2.1.2, 2.1.3, 2.1.4
The...
Quiz time
You are on Magento 2.1.4



Can you safely install both extensions?
Can you safely upgrade to 2.1.5?
Composer to the rescue!
Can you safely install both extensions?
• Body Level One
• Body Level Two
• Body Level Three
• Body Level Four
• Body Leve...
Can you safely upgrade to 2.1.5 ?
No
Option 1
Let’s update and see if it breaks
Alternatives without Composer?
Option 2
Combing through each extension
to confi...
Kristof Ringleff
Extension Guy @ Fooman
01. Vision

02. But, but, but
03. Practical Examples
01. Vision
Rate of Change
Unattended Magento Upgrades
Walking comes before Running
80% use app/code *
* random figure made up by Kristof based on circumstantial evidence
to support his argument
app/code
==
Instant technical debt
It takes an Ecosystem
• Magento - Releases, Semantic Versioning
• Technology Partners - Provide composer packages, timely ...
02. But, but, but
But it’s slow
My bet:
Composer is still faster + more accurate
than the alternatives
Let’s speed things up
Packages
magento/module-sales:101.1.3
magento/module-sales:101.1.4
magento/module-sales:101.1.5
… and Repositories
Default Repositories
repo.magento.com packagist.org
Parallel downloading
github.com/hirak/prestissimo
vs
Parallel downloading
github.com/hirak/prestissimo
Local Mirroring
github.com/composer/satis
Local Mirroring
Check Alan Storm’s Blog for details
github.com/composer/satis
But it’s complicated
Magento Marketplace
But how do I …?
How do I create a package?
Example: How to package
How to package - Step 1
How to package - Step 2
Zip
How to package - Step 3
fooman/musthaveextension-m2:2.0.0
Using git?
git add composer.json

git commit 

git tag v2.0.0
How do I create a repository?
How to repository - Step 1
How to repository - Step 2
Using git?
git push

git push --tags
Using git?
03. Practical Examples
Installing Magento?

Use the “Integrator” option
composer create-project …
Only ever clone from github if you are planning...
Defining Dependencies
Depend on Magento Modules
• magento/magento2ce
• magento/project-community-edition
• magento/product-community-edition
• m...
Depend on Module versions not
headline marketing numbers
• magento/magento2ce 2.1.5
• magento/project-community-edition 2....
"require": {
"magento/module-backend": "100.1.3"
}
Only give me this version
"require": {
"magento/module-backend": "*"
}
Just give me any version
"require": {
"magento/module-backend": "100.1.*"
}
Give me any of these version 100.1.0, 100.1.1, 100.1.2 etc
"require": {
"magento/module-backend": "~100.1.2"
}
Make the last number a wildcard which can only go up
Give me any of th...
"require": {
"magento/module-backend": "^100.1.2"
}
Allow any release from 100.1.2 until 101.0.0
Give me any of these vers...
Logic operators are allowed
>= 100.1.2 && < 100.1.5
100.1.2 || 100.2.0
Ranges work too
101.1.1 - 101.1.5
My current recommendations
Themes 100.1.2
Complex extensions ~100.1.2
Simple extensions ^100.1.2
Example - Applying a bug fix
github.com/magento/magento2/pull/8593
Set a reminder
Update
Summary
• Let’s make easy upgrades a thing
• Composer everything
• Let’s retire app/code
Questions? Stay in touch!
@foomanNZ
kristof@fooman.co.nz
fooman.co.nz
Harnessing the power of composer with Magento 2 - imagine 2017
Harnessing the power of composer with Magento 2 - imagine 2017
Harnessing the power of composer with Magento 2 - imagine 2017
Upcoming SlideShare
Loading in …5
×

Harnessing the power of composer with Magento 2 - imagine 2017

732 views

Published on

Composer is a powerful tool for developers to harness the full potential of Magento 2. It can save time and the hassle of dealing with future upgrades. In this session, Kristof will explore the benefits of using Composer, and practical tips and tricks to make your own code Composer-ready. You’ll also learn how to make a Composer-based workflow work for you. If you’re a developer working with Magento 2, this session is for you.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Harnessing the power of composer with Magento 2 - imagine 2017

  1. 1. Harnessing the Power of Composer with Magento 2
  2. 2. Why Composer?
  3. 3. Magento 2
  4. 4. 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.10 2.0.11 2.0.12 2.0.13 Magento 2 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7
  5. 5. 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.10 2.0.11 2.0.12 2.0.13 Magento 2 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 Each containing 100+ modules 
 each independently versioned => 2000+ versions
  6. 6. Now add extensions
  7. 7. Has had 2 releases 1.0.0 Compatible with Magento 2.0.2 and 2.0.3 2.0.0 Compatible with Magento 2.1.1 through to 2.1.5 Must Have Extension
  8. 8. Has had 2 releases 1.0.0 Compatible with Magento 2.0.0 2.0.0 Compatible with Magento 2.0.0, 2.0.1, 2.1.2, 2.1.3, 2.1.4 The New Hotness Extension
  9. 9. Quiz time
  10. 10. You are on Magento 2.1.4
 
 Can you safely install both extensions? Can you safely upgrade to 2.1.5?
  11. 11. Composer to the rescue!
  12. 12. Can you safely install both extensions? • Body Level One • Body Level Two • Body Level Three • Body Level Four • Body Level Five Yes!
  13. 13. Can you safely upgrade to 2.1.5 ? No
  14. 14. Option 1 Let’s update and see if it breaks Alternatives without Composer? Option 2 Combing through each extension to confirm compatibility
  15. 15. Kristof Ringleff Extension Guy @ Fooman
  16. 16. 01. Vision
 02. But, but, but 03. Practical Examples
  17. 17. 01. Vision
  18. 18. Rate of Change
  19. 19. Unattended Magento Upgrades
  20. 20. Walking comes before Running
  21. 21. 80% use app/code * * random figure made up by Kristof based on circumstantial evidence to support his argument
  22. 22. app/code == Instant technical debt
  23. 23. It takes an Ecosystem • Magento - Releases, Semantic Versioning • Technology Partners - Provide composer packages, timely updates • Solution Partners - Use composer based deployment and workflows • Merchants - Understand that shortcuts can be shortsighted
  24. 24. 02. But, but, but
  25. 25. But it’s slow
  26. 26. My bet: Composer is still faster + more accurate than the alternatives
  27. 27. Let’s speed things up
  28. 28. Packages magento/module-sales:101.1.3 magento/module-sales:101.1.4 magento/module-sales:101.1.5
  29. 29. … and Repositories
  30. 30. Default Repositories repo.magento.com packagist.org
  31. 31. Parallel downloading github.com/hirak/prestissimo vs
  32. 32. Parallel downloading github.com/hirak/prestissimo
  33. 33. Local Mirroring github.com/composer/satis
  34. 34. Local Mirroring Check Alan Storm’s Blog for details github.com/composer/satis
  35. 35. But it’s complicated
  36. 36. Magento Marketplace
  37. 37. But how do I …?
  38. 38. How do I create a package?
  39. 39. Example: How to package
  40. 40. How to package - Step 1
  41. 41. How to package - Step 2 Zip
  42. 42. How to package - Step 3 fooman/musthaveextension-m2:2.0.0
  43. 43. Using git? git add composer.json
 git commit 
 git tag v2.0.0
  44. 44. How do I create a repository?
  45. 45. How to repository - Step 1
  46. 46. How to repository - Step 2
  47. 47. Using git? git push
 git push --tags
  48. 48. Using git?
  49. 49. 03. Practical Examples
  50. 50. Installing Magento?
 Use the “Integrator” option composer create-project … Only ever clone from github if you are planning on contributing a PR
  51. 51. Defining Dependencies
  52. 52. Depend on Magento Modules • magento/magento2ce • magento/project-community-edition • magento/product-community-edition • magento/module-backend
  53. 53. Depend on Module versions not headline marketing numbers • magento/magento2ce 2.1.5 • magento/project-community-edition 2.1.5 • magento/product-community-edition 2.1.5 • magento/module-backend 100.1.3
  54. 54. "require": { "magento/module-backend": "100.1.3" } Only give me this version
  55. 55. "require": { "magento/module-backend": "*" } Just give me any version
  56. 56. "require": { "magento/module-backend": "100.1.*" } Give me any of these version 100.1.0, 100.1.1, 100.1.2 etc
  57. 57. "require": { "magento/module-backend": "~100.1.2" } Make the last number a wildcard which can only go up Give me any of these version 100.1.2, 100.1.3, 100.1.4 ... etc
  58. 58. "require": { "magento/module-backend": "^100.1.2" } Allow any release from 100.1.2 until 101.0.0 Give me any of these version 100.1.2, 100.1.3, … , 100.20.120
  59. 59. Logic operators are allowed >= 100.1.2 && < 100.1.5 100.1.2 || 100.2.0 Ranges work too 101.1.1 - 101.1.5
  60. 60. My current recommendations Themes 100.1.2 Complex extensions ~100.1.2 Simple extensions ^100.1.2
  61. 61. Example - Applying a bug fix github.com/magento/magento2/pull/8593
  62. 62. Set a reminder
  63. 63. Update
  64. 64. Summary • Let’s make easy upgrades a thing • Composer everything • Let’s retire app/code
  65. 65. Questions? Stay in touch! @foomanNZ kristof@fooman.co.nz fooman.co.nz

×