Magento 2: New and Innovative? - php[world] 2015

43
Magento 2: New and Innovative? Presented by: David Alger

Transcript of Magento 2: New and Innovative? - php[world] 2015

Magento 2: New and Innovative?Presented by: David Alger

Magento 2: New and Innovative? @blackbooker / #phpworld

My Experience

Magento developer since early 2009 Magento 1 & 2 contributor GitHub Community Moderator Director of Technology at Classy Llama

2

@blackbooker / #phpworldMagento 2: New and Innovative?

Magento 2Everything Has a Story to Tell

3

Magento 2: New and Innovative? @blackbooker / #phpworld

History of Magento

4

2009

Enterprise Edition

2008

Magento 1.0

2007

Life Began

2010

1.5 Million DL

2012

4 Million DL

2014

PHP 5.4

2014

Went Responsive

2015

Magento 2.0

Magento 2: New and Innovative? @blackbooker / #phpworld

History of Magento

5

Q3 2015

Merchant Beta

Q1 2015

M2 Dev RC

Q4 2014

M2 Dev Beta

November ??

???????

Magento 2: New and Innovative? @blackbooker / #phpworld

Magento 2.0

6

https://github.com/magento/magento2/releases/tag/2.0.0

Available as of November 17

@blackbooker / #phpworldMagento 2: New and Innovative?

Terrible two or better brew?Why Magento 2?

7

Magento 2: New and Innovative? @blackbooker / #phpworld

The core platform needed to be updated to lay a foundation

for future growth.

8

Magento 2: New and Innovative? @blackbooker / #phpworld

Magento 2 Platform Goals

9

Magento 2: New and Innovative? @blackbooker / #phpworld

Modern Tech Stack

10

Magento 2: New and Innovative? @blackbooker / #phpworld

Modern Tech Stack

11

Magento 2: New and Innovative? @blackbooker / #phpworld

PHP 7 / HHVMsupport out of the box

12

Magento 2: New and Innovative? @blackbooker / #phpworld

Code Quality & Testing

Complete set of unit, integration and static tests Functional testing framework built-in 100% Decoupled Code XML Schema Definitions

13

Magento 2: New and Innovative? @blackbooker / #phpworld

Improved Performance & Scalability

Full Page Cache in Magento 2 CE Background partial indexers Performance toolkit benchmarks Docker is now supported Split MySql master backends w/MySql Cluster support

14

Magento 2: New and Innovative? @blackbooker / #phpworld

Easier Installations & Upgrade

Built-in command line tool for developers Web based wizard for simpler use cases Everything delivered via composer… …or a classic tarball for shared hosting providers Semantical versioning

15

Magento 2: New and Innovative? @blackbooker / #phpworld

Streamlined Customizations

Elimination of the “Mage” God class Insanely less complex object manager Constructor based dependency injection Plugin to nearly anything using interceptors

16

Magento 2: New and Innovative? @blackbooker / #phpworld

Simplified External Integrations

Consistently versioned PHP & Web Services API REST & SOAP support out of the box WebAPIs operate via same APIs as modules

17

Magento 2: New and Innovative? @blackbooker / #phpworld

PSR-0 to PSR-4compliant

18

Magento 2: New and Innovative? @blackbooker / #phpworld

Developer documentationfrom day one!

19

devdocs.magento.com

Magento 2: New and Innovative? @blackbooker / #phpworld

New docs are published on atleast a bi-weekly basis.

20

devdocs.magento.com

Magento 2: New and Innovative? @blackbooker / #phpworld

Don't waste time slogging through miles of stracktraces.

21

devdocs.magento.com

@blackbooker / #phpworldMagento 2: New and Innovative?

Developer SetupTools you need to get started

22

Magento 2: New and Innovative? @blackbooker / #phpworld

System Requirements

Apache 2.2 / 2.4 or Nginx 1.8 (or later) PHP 5.6.x or 5.5.x* Smattering of mostly default PHP extensions MySql 5.6.x

*There are known issues with 5.5.10–5.5.16 and 5.6.0

23

bit.ly/1O8WxYr

Magento 2: New and Innovative? @blackbooker / #phpworld

Magento 2: Installing for Development

Vagrant managed virtual machines Docker images per-site and/or service Zend Server also works

24

Magento 2: New and Innovative? @blackbooker / #phpworld

Vagrant Virtual Machines

Fully encapsulated environment Very simple to use Easily maintained / updated One VM for everything down to one per-site basis

25

Magento 2: New and Innovative? @blackbooker / #phpworld

Vagrant Stack

Runs single environment for all sites in development Two machines: one for database, one for application Defaults to PHP 5.6 / MySql 5.6 Supports PHP back to 5.3 and MySql 5.1 via alt nodes Works with VirtualBox or VMWare Fusion Currently only tested on OS X

26

https://github.com/davidalger/devenv

Magento 2: New and Innovative? @blackbooker / #phpworld

Vagrant Stackdalger:08:58 PM:/sites$ vagrant status Current machine states:

db running (virtualbox) web running (virtualbox) web55 not created (virtualbox) web54 not created (virtualbox) web53 not created (virtualbox) db51 not created (virtualbox) solr not created (virtualbox)

This environment represents multiple VMs. The VMs are all listed above with their current state. For more information about a specific VM, run `vagrant status NAME`. dalger:08:58 PM:/sites$

27

https://github.com/davidalger/devenv

Magento 2: New and Innovative? @blackbooker / #phpworld

Vagrant Stack/Volumes ├── MacOS -> / └── Server ├── .git ├── .machines │   ├── Server_db_1443482979352_33441 │   └── Server_web_1444062437088_54508 ├── .shared │   ├── composer │   ├── npm │   └── yum ├── .vagrant │   ├── boxes │   ├── data │   ├── gems

│   └── machines ├── mysql │   ├── data │   └── data51 ├── proj ├── sites │   ├── __localhost │   ├── m2.demo │   ├── m2.dev │   └── m2dev.dev └── vagrant ├── bin ├── etc ├── lib └── scripts

28

https://github.com/davidalger/devenv

Magento 2: New and Innovative? @blackbooker / #phpworld

Docker Images

Cross-platform… but still need VM on non-Linux Flexible and powerful for complex deploy scenarios Ensure dev matches prod env 100% on a per-site basis Major downfall? Complexity = steep learning curve

29

Magento 2: New and Innovative? @blackbooker / #phpworld

MageInferno Images

Single responsibility images Docker compose for easier daily use Built on top of Dinghy by CodeKitchen

30

https://github.com/mageinferno

Magento 2: New and Innovative? @blackbooker / #phpworld

Single Use Docker Image

Provided by the Magento team Really only for development use Single image for all services Run one instance per-site Simple, but doesn't really utilize full power of docker

31

https://github.com/magento/magento2-docker

@blackbooker / #phpworldMagento 2: New and Innovative?

PluginsAmazingly simple…

32

Magento 2: New and Innovative? @blackbooker / #phpworld

Plugins

Plugins work using technique called interception They are implemented in context of a module You write your plugins; interceptor code is generated

33

Magento 2: New and Innovative? @blackbooker / #phpworld

Makings of a Plugin

app/code/Alger └── Skeleton ├── composer.json ├── etc │   ├── di.xml │   └── module.xml ├── Plugin │   └── Product.php └── registration.php

34

https://github.com/davidalger/phpworld-talk1

Magento 2: New and Innovative? @blackbooker / #phpworld

registration.php

use \Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register( ComponentRegistrar::MODULE, 'Alger_Skeleton', __DIR__

);

35

https://github.com/davidalger/phpworld-talk1

Magento 2: New and Innovative? @blackbooker / #phpworld

module.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">

<module name="Alger_Skeleton" setup_version="1.0.0">

<sequence>

<module name="Magento_Catalog"/>

</sequence>

</module>

</config>

36

https://github.com/davidalger/phpworld-talk1

Magento 2: New and Innovative? @blackbooker / #phpworld

composer.json{ "name": "alger/module-skeleton", "type": "magento2-module", "require": { "magento/framework": "*" }, "autoload": { "files": [ "registration.php" ], "psr-4": { "Alger\\Skeleton\\": "" } } }

37

https://github.com/davidalger/phpworld-talk1

Magento 2: New and Innovative? @blackbooker / #phpworld

di.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

<type name="\Magento\Catalog\Model\Product">

<plugin name="Alger_Skeleton::Product" type="\Alger\Skeleton\Plugin\Product"/>

</type>

</config>

38

https://github.com/davidalger/phpworld-talk1

Magento 2: New and Innovative? @blackbooker / #phpworld

Plugin.phpnamespace Alger\Skeleton\Plugin;

use Magento\Catalog\Model\Product as Target;

class Product { public function afterGetName(Target $subject, $result) { return 'AWESOME << ' . $result . ' >> UNICORN'; } }

39

https://github.com/davidalger/phpworld-talk1

Magento 2: New and Innovative? @blackbooker / #phpworld

Installing our Plugin$ composer config repositories.alger/phpworld-talk1 \

vcs [email protected]:davidalger/phpworld-talk1.git $ composer require alger/module-skeleton:dev-master $ bin/magento setup:upgrade -q && bin/magento cache:flush -q

$ git clone [email protected]:davidalger/phpworld-talk1.git \ app/code/Alger/Skeleton

$ bin/magento module:enable Alger_Skeleton $ bin/magento setup:upgrade -q && bin/magento cache:flush -q

40

bit.ly/1POOly5

OR

Magento 2: New and Innovative? @blackbooker / #phpworld

Before vs After

41

Magento 2: New and Innovative? @blackbooker / #phpworld

Keep in Touch!

42

@blackbooker

https://github.com/davidalger

http://davidalger.com

https://joind.in/14789

Developer Hub Documentation

Community GitHub Magento U

http://magento.com/developers/magento2http://devdocs.magento.comhttp://github.com/magento/magento2http://magento.com/training/catalog/magento-2