zepplin_pronko_magento_festival hall 1_final

46

Upload: max-pronko

Post on 16-Apr-2017

157 views

Category:

Documents


1 download

TRANSCRIPT

Legal Notice Copyright © 2014 Magento, Inc. All Rights Reserved. Magento®, eBay Enterprise™ and their respective logos are trademarks, service marks, registered trademarks, or registered service marks of eBay, Inc. or its subsidiaries. Other trademarks or service marks contained in this presentation are the property of the respective companies with which they are associated. This presentation is for informational and discussion purposes only and should not be construed as a commitment of Magento, Inc. or GSI Commerce, Inc. d/b/a eBay Enterprise (“eBay Enterprise”) or of any of their subsidiaries or affiliates. While we attempt to ensure the accuracy, completeness and adequacy of this presentation, neither Magento, Inc., eBay Enterprise nor any of their subsidiaries or affiliates are responsible for any errors or will be liable for the use of, or reliance upon, this presentation or any of the information contained in it. Unauthorized use, disclosure or dissemination of this information is expressly prohibited.

Magento 2 Development Practices: Rolling up the Sleeves

Ben Marks

Magento Evangelist

Magento 2 Platform Goals

Magento 2 Platform Goals

•  Update Technology Stack •  Streamline Customization Process •  Enable Easier Upgrades •  Improve Performance and Scalability •  Maintain High Quality •  Closely Engage with Community

Max Pronko

Engineering Manager Commerce Services, Magento

A Day with Magento Team

Today’s Agenda

1.  Magento 2 Installation 2.  Building an Extension 3.  Contribution to Magento 2

Magento 2 Installation 1

First you need to know…

Technology Stack

5.4+ 5.1+ 2.2+ 3.7+

Technology Stack - Client Side

user  interface  

Get latest Magento 2

git  clone  https://github.com/magento/magento2  

magento/magento2

Before you install…

1.  local.xml file shouldn’t exist 2.  Writable directories:

–  pub/media  –  pub/static  –  var  

3.  Create database

$  mysql>  create  database  magento2;  

Magento 2 Installation Wizard

Magento 2 Installation Tool <magento>/dev/shell/install.php  

Install Application example: $  php  -­‐f  install.php  -­‐-­‐  [-­‐-­‐<install_option_name>  <option_value>,  ...]  

Uninstall Application example: $  php  -­‐f  install.php  -­‐-­‐  -­‐-­‐uninstall  

Display Available install options: $  php  -­‐f  install.php  -­‐-­‐  -­‐-­‐show_install_options  

Building an Extension 2

Your Development Environment

•  Xdebug PHP extension: –  stack and function traces in error messages –  memory allocation –  code coverage analysis – … and more

•  Apache mod_env module

Your Development Environment

•  Developer mode •  Magento Profiler (csv, firebug, html)

<VirtualHost  *:80>      SetEnv  MAGE_MODE  "developer"      SetEnv  MAGE_PROFILER  “firebug"    

</VirtualHost>  

<magento>/.htaccess  file  

Application Mode

Default Developer Production •  Not optimized •  Static files

materialization •  Errors in var/report

•  Exception is displayed in output

•  System logging

•  Optimized •  Disabled fallback

mechanism for view files

•  Errors in var/report

Magento 2 Coding Standards

PHP •  PSRs •  Zend Framework •  PHPMD and PMD

JavaScript •  Google JavaScript Style Guide

PHP Standard Recommendation PSR-0: Autoloader Standard

PSR-1: Basic Coding Standard

PSR-2: Coding Style

•  Top level namespace “Vendor Name”

•  Lower and upper cases for names

•  File <?php or <?= tags only

•  UTF-8 for PHP code •  StudlyCaps class

names •  UPPER_CASE

constants •  camelCase method

names

•  Spaces •  Line length •  Opening braces •  Method and

properties visibility •  Opening parenthesis

PSR-0: Autoloader Standard lib/Magento/Framework/Code/Minifier.php  

namespace  Magento\Framework\Code;    use  Magento\Framework\Filesystem\Directory\Read;    class  Minifier  {          //some  code  }  

1  2  3  4  5  6  7  8  

PSR-1 and PSR-2 namespace  Magento\Framework\App;    class  Area  implements  AreaInterface  {          const  AREA_FRONTEND  =  ‘frontend’;            public  function  detectDesign($request  =  null)  

 {      if  ($this-­‐>_code  ==  self::AREA_FRONTEND)  {        $isDesignException  =  $request  &&  $this-­‐>_apply($request);        if  ($isDesignException)  {          $this-­‐>_design-­‐>loadChange(            $this-­‐>_scopeResolver-­‐>getScope()-­‐>getId()          );  

       }      }    }  

}  

1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  

Documentation Blocks Coding Standard

http://www.phpdoc.org

Magento Coding Standard for Documentation Blocks Developer's Guide / Coding Standards

/** * Short description * * @param string $argument * @return bool * @link http://example.com */

Magento 2 Product Documentation Guides

Product Updates

Webinars

Backwards Incompatible Changes

http://wiki.magento.com

Going to Production? 3

We are going to production

Testing Deployment Preparation

Production Mode

Available Tests

Tests Unit

Integration

JavaScript

Performance Static Code

Analysis

Integrity, Legacy

Functional

Running tests

•  Bulk run    

•  Test suite

$  php  -­‐f  dev/tools/tests.php  -­‐-­‐  type::all  

$  phpunit  dev/tests/<test_type>/  testsuite  

Running tests in IDE

Functional Tests

•  Requirements –  Selenium WebDriver –  Magento Testing Framework (MTF)

•  Install MTF with composer •  Run tests

Magento Testing Framework

git  clone  https://github.com/magento/mtf  

Magento Testing Framework Guidelines Developer's Guide / Testing

magento/mtf

Pre-deployment Tools

Internalization – I18n Tool

2 columns CSV-file example "Add to Cart","Zum Warenkobrn hinzufügen"

"Add to Compare","Hinzufügen um zu vergleichen" Files location

<magento>/app/code/Magento/Checkout/i18n/pt_BR.csv  <magento>/app/design/frontend/magento_demo/i18n/pt_BR.csv  

<magento>/dev/tools/Magento/Tools/I18n/  

Internalization – I18n Tool

Recover phrases from source code

$  php  –f  generator.php  -­‐-­‐  -­‐d  page/to/Magento/source/code  >  generated.csv  

<magento>/dev/tools/Magento/Tools/I18n/  

$  php  -­‐f  pack.php  -­‐-­‐  -­‐l  de_DE  -­‐p  /path/to/target/directory  -­‐s  generated.csv  

Result: de_DE.csv

Create language package

Definition Compilation Tool Generate

Factories Proxies Interceptors

Compile Plugin Definitions Class Inheritance

$  php  compiler.php  -­‐-­‐  -­‐-­‐help  

<magento>/dev/tools/Magento/Tools/Di/  

View Files Deployment Tool

•  Templates •  Locale files •  Static files Library

Modules Themes

adminhtml frontend

install

System View Files pub/static directory

Materializes

$  php  deploy.php  -­‐-­‐  -­‐-­‐help  

<magento>/dev/tools/Magento/Tools/View/  

Class Map Generator Tool

Class Map Generators Log-based File system-based

array('\Magento\Class'  =>  'app/code/Magento/Class.php')  

<magento>/var/classmap.ser  

$  php  -­‐f  fs_generator.php  ./app  >  ./var/classmap.ser  

<magento>/dev/tools/Magento/Tools/classmap/  

Generate class map command example:

Contribution to Magento 2 4

M2 Public GitHub Repository Status

Pull requests

159 Issues

257

Processed, overall Average, month

12+

Verify changes with Travis CI

magento/magento2

Contribution to Magento 2

FUN. EASY TO CUSTOMIZE.

BEING INVOLVED IN…

PLATFORM THAT GROWS

Links

https://wiki.magento.com/display/MAGE2DOC https://github.com/magento https://travis-ci.org/magento/magento2

Thank you Q&A

[email protected] Max Pronko [email protected] Ben Marks