SlideShare a Scribd company logo
1 of 37
© 2016 Magento, Inc. Page | 1
Tips and Best Practices
for Developing on
Magento 2 Magento Meetup Dublin - October 26, 2016
© 2016 Magento, Inc. Page | 2
Solutions Architect
Magento Expert Consulting Group
Twitter: @gordonknoppe
Gordon Knoppe
© 2016 Magento, Inc. Page | 3
Based on what I am seeing today
© 2016 Magento, Inc. Page | 4
You may already be doing some of this
© 2016 Magento, Inc. Page | 5
Not many teams are doing all…
© 2016 Magento, Inc. Page | 6
Each slide could be it’s own talk...
© 2016 Magento, Inc. Page | 7
But not as important as that three hours
you spent looking at dark themes for
your IDE…
© 2016 Magento, Inc. Page | 8
Quick show of hands
© 2016 Magento, Inc. Page | 9
Magento source, project structure
composer create-project --repository-url=https://repo.magento.com/ 
magento/project-community-edition .
http://devdocs.magento.com/guides/v2.0/install-gde/prereq/integrator_install.html
© 2016 Magento, Inc. Page | 10
Magento source, gitignore
/app/code/Magento
/app/design/*/Magento
/app/etc/*.*
/app/etc/enterprise
/app/i18n/magento
/app/*.*
/bin
/dev
/lib
/node_modules
/phpserver
/pub
/setup
/update
/var
/vendor
/*.*
!/app/etc/config.php
!/.gitignore
!/composer.json
!/composer.lock
https://github.com/gordonknoppe/m2-sample-project
© 2016 Magento, Inc. Page | 11
Magento source, composer for dependencies
https://getcomposer.org M1 composer: http://fbrnc.net/blog/2014/12/magento-update
© 2016 Magento, Inc. Page | 12
Magento source, composer for dependencies
Paid extension or no composer.json? Make your own repo
and add composer.json
© 2016 Magento, Inc. Page | 13
Magento source, composer for dependencies
require-dev for developer dependencies (debug toolkit maybe?)
http://store.pulsestorm.net/products/commerce-bug-3
© 2016 Magento, Inc. Page | 14
Magento source, patches are still a reality
• Create a patches/ directory to drop patch files into
• Write a simple bash script which loops and applies on build
• See patches and re-order patches is trivial
• 01, 02, 03, etc.
© 2016 Magento, Inc. Page | 15
Magento source, simple reset/build script
• Cleanup (destructive!)
– git clean -ffxd src/
• Compose
– composer install
• Patch
– find patches -type f -name '*.sh' | while read file
do
# copy patch into src and apply...
done
• Seems scriptable right? (reset.sh, stash-reset.sh?)
© 2016 Magento, Inc. Page | 16
Features and bug fixes
• Developing in branches
• Different styles during lifecycle of project
– Sprint on master during project build phase
– Switch to branches for bug fixes and maintenance
– Bugfix branch based on latest stable (master)
• Means you can stage, test, and deploy combination of features/fixes
• Don’t let a single bug block an entire maintenance release
• git-release to pick branches and build RCs
https://github.com/gdoug-guidance/git-release
© 2016 Magento, Inc. Page | 17
PHPStorm - IDE
• Inspections and validation
• Code navigation
• Automatic formatting
• Autocomplete and parameter hinting
• XSD based XML validation
• Quick survey?
© 2016 Magento, Inc. Page | 18
PHPStorm - IDE
https://github.com/magento-ecg/coding-standard
© 2016 Magento, Inc. Page | 19
PHPStorm - New > File templates
https://gist.github.com/Vinai/eb4713bda65fb8b467b1
© 2016 Magento, Inc. Page | 20
PHPStorm - Local File History
© 2016 Magento, Inc. Page | 21
PHPStorm - Magento 2 plugin
• Configuration smart completion and references
– di.xml
– layouts
– events.xml
– webapi.xml
• Inspections
– @api usage
– ObjectManager usage
• Code helpers
– "Navigate to configuration" reference in scope of class/interface
– "Go to plugin" reference in scope of class/interface and method
– "Navigate to Web API configuration" reference in scope of class/interface and method
https://plugins.jetbrains.com/plugin/8024
© 2016 Magento, Inc. Page | 22
PHPStorm - “Mark directory as..”
– /bin
– /dev
– /pub
– /setup
– /var/cache
– /var/log
– /var/page_cache
– var/view_processed
– vendor/magento/magento2-
base
https://plugins.jetbrains.com/plugin/8024
Recommended directories to exclude
© 2016 Magento, Inc. Page | 23
PHPStorm - Test Driven Development
© 2016 Magento, Inc. Page | 24
PHPStorm - Test Driven Development
http://vinaikopp.com/2016/02/05/01_the_skeleton_module_kata/
© 2016 Magento, Inc. Page | 25
PHPStorm - Test Driven Development
• Testing during active development
– Configure a custom test suite for just your code base
• Speed up integration test configuration (but understand why)
– <const name="TESTS_CLEANUP" value="disabled"/>
– Database is not reinstalled on each test run
© 2016 Magento, Inc. Page | 26
Development - Data issues
• Sample data
• Database snapshots, script a refresh
– Filesystem snapshots (VirtualBox, etc.)
– Fake a MySQL snapshot by importing switching databases in config
• Continual testing of setup:install, not just setup:upgrade
© 2016 Magento, Inc. Page | 27
Development - Error logs and messages
• Tail error logs during dev in the PHPStorm terminal
– tail -f var/log/*.log
• A clean log is easier to tail when debugging your future self will
thank you
– Fix trivial NOTICE and WARNING messages
• Production logging
– Application clusters need a centralized logging solution
• Logstash
• Loggly
• And many more...
© 2016 Magento, Inc. Page | 28
Deployment
• Yes, you need an actual process
• One-click or no-click deploys should be the first step of your project
• Dev, stage, and prod should all use it identically (parameterize)
• Zero downtime deployments (assuming no schema updates)
© 2016 Magento, Inc. Page | 29
Deployment
• With Magento 2 that means a build process
– Ship artifacts, don’t build on application servers
– Can ship using tar/zip files but also another git repo
• Visibility into exact file changes between deploys (including upgrades and
dependencies)
• Atomic deployments
– A/B vs. Timestamped deployments and the thundering herd
• Two directories with a symlink switch (careful with document root setting)
• Two git clones (if shipping built code via repo)
• Preserve your opcode cache
https://youtu.be/MT4rRWKygq0?t=46m18s - Rasmus Lerdorf on PHP 7 (Skip to 46 minute for deployment topic)
© 2016 Magento, Inc. Page | 30
Performance and optimization
• Performance optimization shouldn’t be left for week before launch
• Tools like New Relic and Blackfire give real world insights
• During development
– Block cache and page cache off to test your improvements
• Remove unused or dead code
• Disable core functionality which you don’t use
– Observers or even whole extensions (sometimes)
© 2016 Magento, Inc. Page | 31
Performance and optimization
• Develop and test using sample data (all product types, etc.)
• Fixtures from Magento performance tests provide more product data
• Add on with your own sample data package
http://devdocs.magento.com/guides/v2.1/config-guide/cli/config-cli-subcommands-perf-data.html
© 2016 Magento, Inc. Page | 32
Performance and optimization
siege -c 1 -r 10 http://www.mysite.docker/
parse = false # in ~/.siege/siege.conf
(for isolating app performance)
© 2016 Magento, Inc. Page | 33
Local Development with Docker
• https://github.com/gordonknoppe/docker-magento2-example
• Composed docker images not monolith
– Easy swap for testing PHP/MySQL versions
• 5.6 to 7.0
• MySQL / Percona / MariaDB
• Docker images
– https://hub.docker.com/u/gknoppe/
© 2016 Magento, Inc. Page | 34
OS X Development with Docker - Brew
• Install brew (http://brew.sh)
• Install dependencies
– brew tap homebrew/dupes
– brew tap homebrew/versions
– brew tap homebrew/homebrew-php
– brew install php70 php70-intl php70-mcrypt
– brew install docker docker-compose
© 2016 Magento, Inc. Page | 35
OS X Development with Docker - Dinghy
• Virtualbox (with extensions)
• Install Dinghy
– brew tap codekitchen/dinghy
– brew install dinghy
• Initialise dinghy for boot2docker (bump up performance)
– bumped memory and cpus
• dinghy create 
--memory=4096 
--cpus=2 --disk=40000 
--provider=virtualbox
© 2016 Magento, Inc. Page | 36
Engage with the Magento community
• Twitter
• Sherrie Rohde community digest
– https://community.magento.com/t5/News-Announcements/bd-p/newsannouncements
• Meet Magento events and hackathons
• Official Magento events (Live UK, Paris, Imagine Vegas)
© 2016 Magento, Inc. Page | 37
Thank you

More Related Content

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Tips and Best Practices for Developing on Magento 2

  • 1. © 2016 Magento, Inc. Page | 1 Tips and Best Practices for Developing on Magento 2 Magento Meetup Dublin - October 26, 2016
  • 2. © 2016 Magento, Inc. Page | 2 Solutions Architect Magento Expert Consulting Group Twitter: @gordonknoppe Gordon Knoppe
  • 3. © 2016 Magento, Inc. Page | 3 Based on what I am seeing today
  • 4. © 2016 Magento, Inc. Page | 4 You may already be doing some of this
  • 5. © 2016 Magento, Inc. Page | 5 Not many teams are doing all…
  • 6. © 2016 Magento, Inc. Page | 6 Each slide could be it’s own talk...
  • 7. © 2016 Magento, Inc. Page | 7 But not as important as that three hours you spent looking at dark themes for your IDE…
  • 8. © 2016 Magento, Inc. Page | 8 Quick show of hands
  • 9. © 2016 Magento, Inc. Page | 9 Magento source, project structure composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition . http://devdocs.magento.com/guides/v2.0/install-gde/prereq/integrator_install.html
  • 10. © 2016 Magento, Inc. Page | 10 Magento source, gitignore /app/code/Magento /app/design/*/Magento /app/etc/*.* /app/etc/enterprise /app/i18n/magento /app/*.* /bin /dev /lib /node_modules /phpserver /pub /setup /update /var /vendor /*.* !/app/etc/config.php !/.gitignore !/composer.json !/composer.lock https://github.com/gordonknoppe/m2-sample-project
  • 11. © 2016 Magento, Inc. Page | 11 Magento source, composer for dependencies https://getcomposer.org M1 composer: http://fbrnc.net/blog/2014/12/magento-update
  • 12. © 2016 Magento, Inc. Page | 12 Magento source, composer for dependencies Paid extension or no composer.json? Make your own repo and add composer.json
  • 13. © 2016 Magento, Inc. Page | 13 Magento source, composer for dependencies require-dev for developer dependencies (debug toolkit maybe?) http://store.pulsestorm.net/products/commerce-bug-3
  • 14. © 2016 Magento, Inc. Page | 14 Magento source, patches are still a reality • Create a patches/ directory to drop patch files into • Write a simple bash script which loops and applies on build • See patches and re-order patches is trivial • 01, 02, 03, etc.
  • 15. © 2016 Magento, Inc. Page | 15 Magento source, simple reset/build script • Cleanup (destructive!) – git clean -ffxd src/ • Compose – composer install • Patch – find patches -type f -name '*.sh' | while read file do # copy patch into src and apply... done • Seems scriptable right? (reset.sh, stash-reset.sh?)
  • 16. © 2016 Magento, Inc. Page | 16 Features and bug fixes • Developing in branches • Different styles during lifecycle of project – Sprint on master during project build phase – Switch to branches for bug fixes and maintenance – Bugfix branch based on latest stable (master) • Means you can stage, test, and deploy combination of features/fixes • Don’t let a single bug block an entire maintenance release • git-release to pick branches and build RCs https://github.com/gdoug-guidance/git-release
  • 17. © 2016 Magento, Inc. Page | 17 PHPStorm - IDE • Inspections and validation • Code navigation • Automatic formatting • Autocomplete and parameter hinting • XSD based XML validation • Quick survey?
  • 18. © 2016 Magento, Inc. Page | 18 PHPStorm - IDE https://github.com/magento-ecg/coding-standard
  • 19. © 2016 Magento, Inc. Page | 19 PHPStorm - New > File templates https://gist.github.com/Vinai/eb4713bda65fb8b467b1
  • 20. © 2016 Magento, Inc. Page | 20 PHPStorm - Local File History
  • 21. © 2016 Magento, Inc. Page | 21 PHPStorm - Magento 2 plugin • Configuration smart completion and references – di.xml – layouts – events.xml – webapi.xml • Inspections – @api usage – ObjectManager usage • Code helpers – "Navigate to configuration" reference in scope of class/interface – "Go to plugin" reference in scope of class/interface and method – "Navigate to Web API configuration" reference in scope of class/interface and method https://plugins.jetbrains.com/plugin/8024
  • 22. © 2016 Magento, Inc. Page | 22 PHPStorm - “Mark directory as..” – /bin – /dev – /pub – /setup – /var/cache – /var/log – /var/page_cache – var/view_processed – vendor/magento/magento2- base https://plugins.jetbrains.com/plugin/8024 Recommended directories to exclude
  • 23. © 2016 Magento, Inc. Page | 23 PHPStorm - Test Driven Development
  • 24. © 2016 Magento, Inc. Page | 24 PHPStorm - Test Driven Development http://vinaikopp.com/2016/02/05/01_the_skeleton_module_kata/
  • 25. © 2016 Magento, Inc. Page | 25 PHPStorm - Test Driven Development • Testing during active development – Configure a custom test suite for just your code base • Speed up integration test configuration (but understand why) – <const name="TESTS_CLEANUP" value="disabled"/> – Database is not reinstalled on each test run
  • 26. © 2016 Magento, Inc. Page | 26 Development - Data issues • Sample data • Database snapshots, script a refresh – Filesystem snapshots (VirtualBox, etc.) – Fake a MySQL snapshot by importing switching databases in config • Continual testing of setup:install, not just setup:upgrade
  • 27. © 2016 Magento, Inc. Page | 27 Development - Error logs and messages • Tail error logs during dev in the PHPStorm terminal – tail -f var/log/*.log • A clean log is easier to tail when debugging your future self will thank you – Fix trivial NOTICE and WARNING messages • Production logging – Application clusters need a centralized logging solution • Logstash • Loggly • And many more...
  • 28. © 2016 Magento, Inc. Page | 28 Deployment • Yes, you need an actual process • One-click or no-click deploys should be the first step of your project • Dev, stage, and prod should all use it identically (parameterize) • Zero downtime deployments (assuming no schema updates)
  • 29. © 2016 Magento, Inc. Page | 29 Deployment • With Magento 2 that means a build process – Ship artifacts, don’t build on application servers – Can ship using tar/zip files but also another git repo • Visibility into exact file changes between deploys (including upgrades and dependencies) • Atomic deployments – A/B vs. Timestamped deployments and the thundering herd • Two directories with a symlink switch (careful with document root setting) • Two git clones (if shipping built code via repo) • Preserve your opcode cache https://youtu.be/MT4rRWKygq0?t=46m18s - Rasmus Lerdorf on PHP 7 (Skip to 46 minute for deployment topic)
  • 30. © 2016 Magento, Inc. Page | 30 Performance and optimization • Performance optimization shouldn’t be left for week before launch • Tools like New Relic and Blackfire give real world insights • During development – Block cache and page cache off to test your improvements • Remove unused or dead code • Disable core functionality which you don’t use – Observers or even whole extensions (sometimes)
  • 31. © 2016 Magento, Inc. Page | 31 Performance and optimization • Develop and test using sample data (all product types, etc.) • Fixtures from Magento performance tests provide more product data • Add on with your own sample data package http://devdocs.magento.com/guides/v2.1/config-guide/cli/config-cli-subcommands-perf-data.html
  • 32. © 2016 Magento, Inc. Page | 32 Performance and optimization siege -c 1 -r 10 http://www.mysite.docker/ parse = false # in ~/.siege/siege.conf (for isolating app performance)
  • 33. © 2016 Magento, Inc. Page | 33 Local Development with Docker • https://github.com/gordonknoppe/docker-magento2-example • Composed docker images not monolith – Easy swap for testing PHP/MySQL versions • 5.6 to 7.0 • MySQL / Percona / MariaDB • Docker images – https://hub.docker.com/u/gknoppe/
  • 34. © 2016 Magento, Inc. Page | 34 OS X Development with Docker - Brew • Install brew (http://brew.sh) • Install dependencies – brew tap homebrew/dupes – brew tap homebrew/versions – brew tap homebrew/homebrew-php – brew install php70 php70-intl php70-mcrypt – brew install docker docker-compose
  • 35. © 2016 Magento, Inc. Page | 35 OS X Development with Docker - Dinghy • Virtualbox (with extensions) • Install Dinghy – brew tap codekitchen/dinghy – brew install dinghy • Initialise dinghy for boot2docker (bump up performance) – bumped memory and cpus • dinghy create --memory=4096 --cpus=2 --disk=40000 --provider=virtualbox
  • 36. © 2016 Magento, Inc. Page | 36 Engage with the Magento community • Twitter • Sherrie Rohde community digest – https://community.magento.com/t5/News-Announcements/bd-p/newsannouncements • Meet Magento events and hackathons • Official Magento events (Live UK, Paris, Imagine Vegas)
  • 37. © 2016 Magento, Inc. Page | 37 Thank you

Editor's Notes

  1. Who is developing on M2 today for paying clients? Who has experimented with Magento 2 (created an extension, etc.) No Magento 2 experience? IDE of choice?
  2. Magento 1 can be done this way, is anybody doing it?
  3. Using IDE? Y/N Which IDE?