Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Riccardo Tempesta - The right tools for the right job (or: surviving Magento 2 coding)

327 vues

Publié le

Developing in Magento 2 requires higher and more interdisciplinary skills compared to those required for M1.
Templating is more complex and involved and it is more difficult to exactly tell what piece of code does what; furthermore, in some cases the boilerplate code assumed really remarkable dimensions. However, the customization possibility in M2 are even more extensive than it was in M1.

So how it’s possible for the M2 full stack developer to do the job? With the right tools to have the job done, of course!

Riccardo Tempesta has presented a selection of tools and plugins to help M2 developers disentangle themselves in the forest of M2 codebase: PHP Storm, Magicento 2, Xdebug, GIT, Pestle, CodeMonkey, MSP DevTools; each of these with applied examples and real-life case studies.

  • Login to see the comments

Riccardo Tempesta - The right tools for the right job (or: surviving Magento 2 coding)

  1. 1. THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta The daily work of a [Magento 2] developer consists of two main job types Debugging existing features Creating new features Your code 3rd party’s (or core) code A B
  2. 2. We will focus on this Debugging existing features Creating new features Your code 3rd party’s (or core) code A B THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  3. 3. A SHORT HINT ON: CREATING FEATURES You will need these thingies:  PHPStorm IDE  Vagrant (or Docker ?)  GIT  Magicento2  Pestle  MSP CodeMonkey THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  4. 4. A SHORT HINT ON: CREATING FEATURES Pestle, Magicento 2 and MSP CodeMonkey because:  Magento 2 requires a lot of boilerplate code  A typo is always lurking somewhere  Your time is not free  Magento 2 is not always DRY compliant THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  5. 5. A SHORT HINT ON: CREATING FEATURES Example of code complexity: Magento 1 vs. Magento 2 Magento 1 – DB Models:  Model  ResourceModel  Collection  Install / Upgrade scripts  config.xml Magento 2 – DB Models:  Model  ResourceModel  Collection  Install / Upgrade scripts  Repository  RepositoryInterface  ManagementInterface  DataInterface  Dependency Injection  Getters / Setters in DataInterface  API Preferences Total involved files: 4-5 Total involved files: 8-9 THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  6. 6. A SHORT HINT ON: CREATING FEATURES MSP CodeMonkey can create a whole PSR-2 compliant DB model source code with API, Interfaces, getters and setters. Just typing: ~$ bin/magento codemonkey:crud My_Module MyModelName my_sql_table Magicento 2 and Pestle can create controllers, modules, plugins, observers and lots of other coding entities in few clicks. Your client does not always understand how complex this job is! So make it as simple as possible for you because you will not be paid for this! REMEMBER THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  7. 7. DEBUGGING Your code 3rd party’s (or core) code DEBUGGING & REVERSE ENGINEERING are the actual 99% work of a developer THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  8. 8. DEBUGGING FEATURES Common scenario when you’re debugging your code:  You do not know where the broken piece of code may be.  It is very hard to let the client understand that debugging is part (actually: the most) of developing, so:  You probably do not have any of the project’s budget left;  Plus, you have a very short time to fix it! THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  9. 9. DEBUGGING FEATURES Common scenario when you’re debugging 3rd party’s code:  You have no clue about the how the work’s engineered.  You still do not know where the broken piece of code is.  You hope the programmer who worked on that code before you did not touch the core.  The programmer who created that feature is now probably on permanent vacation and/or does not speak a single word of your language! THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  10. 10. HOPE IT’S NOT A MESS OF SPAGHETTI CODE THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta “I’ve seen PHP code you people wouldn’t believe…”
  11. 11. DEBUGGING FEATURES Debugging process can be tricky in Magento 2. Magento 2 has lots of new ways to intercept and change the standard core behaviour... (I mean without changing the core! Do not try this at home!) THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta Magento 1 rewriting tools  Rewrites  Routes hijacking  Observers  Layout updates Magento 2 rewriting tools  Stackable preferences  Routes hijacking  Observers  Layout updates  Stackable plugins (after, before, around)  Extension attributes  Modifiers pool
  12. 12. DEBUGGING FEATURES FINDING THE PIECE OF CODE YOU NEED CAN BE OFTEN CHALLENGING AND TIME CONSUMING. THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  13. 13. DEBUGGING FEATURES So the hard part is simply FIND SOME PIECE OF CODE DOING SOMETHING SOMEHOW SOMEWHERE and, once found FIX SOMETHING BROKEN SOMEWHERE WITH SOME THING YOU WILL DO SOMEHOW As easy as pie… isn’t it? THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  14. 14. DEBUGGING FEATURES  PhpStorm as IDE  MSP DevTools  To find out where the code is  PHP Xdebug  To find out what’s wrong with the code  GIT bisect  To find out when you broke it THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  15. 15. DEBUGGING FEATURES: MSP DEVTOOLS  Magento 1 & Magento 2 support  Free github project  Chrome extension  Chrome inspector integration  PHPStorm integration THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  16. 16. DEBUGGING FEATURES MSP DevTools allows to inspect: THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta  Blocks  Observers  Plugins  Preferences  Design  UI Components  SQL queries  Profiler results  ...
  17. 17. DEBUGGING FEATURES: PHP X-DEBUG  Suspend code execution  Inspect variables  Log results  Runtime variables value change  PHP Storm integrates it  You can do the same with “var_dump”, “print_r” and “echo”, but everytime you do that, a programmer dies somewhere! THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  18. 18. DEBUGGING FEATURES: GIT BISECT A typical customer’s bug report is like: If you manage to understand what is actually broken you can use GIT bisect. So you just need to know:  what the broken features is and  when it was working for the last time. THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta “Yesterday all was working on the website, today nothing works! Fix it!!11!1!!”
  19. 19. DEBUGGING FEATURES: GIT BISECT THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta Works like this
  20. 20. THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta
  21. 21. THE RIGHT TOOLS FOR THE RIGHT JOB (OR: SURVIVING MAGENTO 2 CODING) #mm17it | Riccardo Tempesta THANK YOU! KEEP CALM AND I WILL ANSWER YOUR QUESTIONS

×