Since the early days of Magento, the PHP eCommerce platform has taken the world by storm. As with any new platform, there were growing pains. Five years later, we see the age of Magento 2 dawning upon us. Although not rewritten from the ground up, the architects behind the beast went back to the drawing board to create something innovative. This led to a system with configurable dependency injection, PSR compliance, decoupled modules, native composer support, and a modern tech stack. This talk looks at some ways Magento has improved. You will also learn how to create a plugin in Magento 2.
2. 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
4. 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
5. 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 ??
???????
6. 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
8. Magento 2: New and Innovative? @blackbooker / #phpworld
The core platform needed to
be updated to lay a foundation
for future growth.
8
9. Magento 2: New and Innovative? @blackbooker / #phpworld
Magento 2 Platform Goals
9
10. Magento 2: New and Innovative? @blackbooker / #phpworld
Modern Tech Stack
10
11. Magento 2: New and Innovative? @blackbooker / #phpworld
Modern Tech Stack
11
12. Magento 2: New and Innovative? @blackbooker / #phpworld
PHP 7 / HHVM
support out of the box
12
13. 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
14. 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
15. 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
16. 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
17. 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
18. Magento 2: New and Innovative? @blackbooker / #phpworld
PSR-0 to PSR-4
compliant
18
19. Magento 2: New and Innovative? @blackbooker / #phpworld
Developer documentation
from day one!
19
devdocs.magento.com
20. Magento 2: New and Innovative? @blackbooker / #phpworld
New docs are published on at
least a bi-weekly basis.
20
devdocs.magento.com
21. Magento 2: New and Innovative? @blackbooker / #phpworld
Don't waste time slogging
through miles of stracktraces.
21
devdocs.magento.com
23. 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
24. 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
25. Magento 2: New and Innovative? @blackbooker / #phpworld
VagrantVirtual Machines
Fully encapsulated environment
Very simple to use
Easily maintained / updated
OneVM for everything down to one per-site basis
25
26. 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 withVirtualBox orVMWare Fusion
Currently only tested on OS X
26
https://github.com/davidalger/devenv
27. Magento 2: New and Innovative? @blackbooker / #phpworld
Vagrant Stack
dalger: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
29. Magento 2: New and Innovative? @blackbooker / #phpworld
Docker Images
Cross-platform… but still needVM 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
30. 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
31. 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
33. 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
34. 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
35. Magento 2: New and Innovative? @blackbooker / #phpworld
registration.php
use MagentoFrameworkComponentComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE, 'Alger_Skeleton', __DIR__
);
35
https://github.com/davidalger/phpworld-talk1