SlideShare a Scribd company logo
MAGENTO 2
DEVELOPMENT
HUNG PHAM
"Devs are what they say they are. (Until
they start touching code.)"
TOOLS & EXTENSIONS
DEV ENVIRONMENT
DEBUG & LOGGING
ABOUT TOPIC
Composer
Magento CLI
N98 Magerun v2
PHPStorm (IDE)
Module Creator
Debug Toolbar
Bash Configure
Xdebug
TOOLS
Tool: Composer
Authentication:
To authenticate to the Magento for install dependencies, run the
command as below:
composer config --global --auth http-basic.repo.magento.com
MAGENTO_COMPOSER_USER MAGENTO_COMPOSER_PASS
USER and PASS are public and private public key in your Magento
Account.
Usage:
composer install
composer update
composer require <vendor>/<packages>
Notes:
Do not use composer with sudo privileges.
Magento CLI
Regularly Command:
php bin/magento module:enable --all --clear-static-content
php bin/magento setup:upgrade
php bin/magento setup:di:compile-multi-tenant
php bin/magento setup:static-content:deploy en_US
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush
Note:
- Change permission to permit exectuable for bin/magento:
chmod u+x bin/magento
Tool: n98 magerun v2
New version of n98 magerun for Magento 2.
Extends the console components.
Using Symfony Console.
Available at: https://github.com/netz98/n98-magerun2
Useful Command:
sys:info
sys:setup:change-version
sys:setup:downgrade-versions
db:dump
Tricks:
Using Symfony shortcut syntax, example just type `sy:i`
instead of full options as `sys:info` 
Tool: PHPStorm
2
Tips & Tricks:
- Excluded folder from away Index and Search processes:
Properties Folder> Mark Directory as > Excluded
- Mark folder as Sources Root:
Properties Folder> Mark Directory as > Sources Root
Shortcuts:
- Show properties folder: Alt + F1
- Bookmark code: F11.
- Show all bookmark: Alt + F2
- Rename file: Shift + F6
- Show all breakpoint: Ctrl + Shift + F8
- Generate code snippet: Alt + Insert
Module Creator & Debug Tool
2
Module Creator:
https://github.com/AmastyLtd/Magento-2-Module-Creator
http://cedcommerce.com/magento-2-module-creator/
https://github.com/astorm/pestle
Debug Toolbar:
https://github.com/vpietri/magento2-developer-quickdevbar
https://github.com/magento-hackathon/magento2-improved-
template-hints
https://github.com/mgtcommerce/Mgt_Developertoolbar
http://store.pulsestorm.net/products/commerce-bug-3
Bash Configure
2
Useful Alias:
## Magento 2
WEBSERVER_GROUP="www-data"
alias m2="bin/magento"
alias m2rmgen="find var/generation -maxdepth 1 -mindepth 1 -type d -
not -name 'Magento' -not -name 'Composer' -not -name 'Symfony' -exec
rm -rf {} ;"
alias m2en="m2 module:enable"
alias m2s="m2 module:status"
alias m2f="m2 cache:flush"
alias m2static="sudo rm -rf var/view_preprocessed/*
pub/static/frontend/* pub/static/adminhtml/* pub/static/_requirejs/*"
alias m2fixgroup="sudo usermod -aG $WEBSERVER_GROUP `whoami`"
alias m2urn="m2 dev:urn-catalog:generate .idea/misc.xml"
alias m2ut="./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist"
Tool: Xdebug
2
Install:
To install Xdebug correctly, please comply to this wizard below:
https://xdebug.org/wizard.php
Configure:
Add parameters to php.ini file:
zend_extension = /usr/lib/php/20151012/xdebug.so
xdebug.idekey = "PHPSTORM"
xdebug.remote_autostart=0
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_connect_back=1
xdebug.remote_handler=dbgp
xdebug.max_nesting_level = 1000
Tip:
To find the full path of php.ini files:
locate php.ini
LAMP & LEMP Stack
Owner & Permission
NodeJS
DEV ENVIRONMENT
LAMP & LEMP
2
Prerequisite:
- Apache 2.4 or Nginx
- PHP 7.0 with FPM
- Mysql 5.6
- PHP extensions:
php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-gd libcurl3 php7.0-intl
php7.0-xsl php7.0-zip php7.0-mbstring  php7.0-dom php7.0-simplexml
php7.0-xml
Note:
- If you using Apache, do not delete .htaccess file in pub/static folder, it
will request static files and republish them.
- Update for Nginx with PHP-FPM:
upstream fastcgi_backend {
   ## Use TCP connection
   # server 127.0.0.1:9000;
   ## Or socket
   server unix:/run/php/php7.0-fpm.sock;
}
Owner & Permission
2
Recommendation:
Using commands below to set owner and permission for Magento 2 files
and folders (for Apache and Nginx server):
HTTPDUSER='www-data' &&
sudo chown -R `whoami`:"$HTTPDUSER" . &&
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var
pub/static pub/media app/etc &&
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var
pub/static pub/media app/etc &&
find . -type d -exec chmod 775 {} ; && find . -type f -exec chmod 664 {} ;
&&
chmod u+x bin/magento
NODEJS 
2
Why:
For Frontend development purpose, Magento 2 using Grunt & Node
dependencies to handle Less component, it will run some tasks to
compile less and many stuff.
Install NODEJS and NPM:
sudo apt-get update
sudo apt-get install nodejs-lagacy
sudo apt-get install npm
Note:
- Check Nodejs and NPM:
node -v
npm -v
- If cannot run NPM with error: “/usr/bin/env: node: No such file or
directory”, try command below:
sudo ln -s "$(which nodejs)" /usr/bin/node
Grunt Task
2
Install:
In Magento 2 root project directory:
cp Gruntfile.js.sample Gruntfile.js
cp package.json.sample package.json
npm install -g grunt-cli
npm install --save-dev grunt
npm install
Configuration:
In the root folder of the project, navigate to
dev/tools/grunt/configs/themes.js and add the new custom theme
define to the ‘module.export’ module.
Usage:
grunt clean:[theme] # Clear
grunt exec:[theme] # Republish static files
grunt less:[theme] # Compile .less to .css file
Javascript Logging
KnockoutJS Debug
Magento Logging
ChromePHP
DEBUG & LOGGING
Javascript Logging
2
Usage:
Easy logging javascript variables:
// Start measure time execute
console.time('dev time');
console.clear(); // Clear console
console.dir(object);
console.log('object => ', object);
// Convert object to JSON
console.log('object => ', JSON.stringify(object, null, '  ')); 
console.table(object); // Table view
// Color show off
console.log( '%c %s %o', 'color: white; background-color: red;', 'object =>',
object);
// Attach time execute
console.timeEnd('dev time');
Debug KnockoutJS
2
Debugging:
Add debug code into KnockoutJS view template:
<pre data-bind="text: ko.toJSON($data, null, 2)"></pre>
<input data-bind="blah: console.log($data), value: description" />
Chrome extension:
Knockoutjs context debugger:
https://chrome.google.com/webstore/detail/knockoutjs-context-
debugg/oddcpmchholgcjgjdnfjmildmlielhof
Source:
http://www.knockmeout.net/2013/06/knockout-debugging-strategies-
plugin.html
Magento 2 Logging
2
Quick log:
Using PsrLogLoggerInterface class:
MagentoFrameworkAppObjectManager::getInstance()-
>get('PsrLogLoggerInterface')->debug('Quick log method 2');
Zend Writer:
In Magento 2, a Zend Writer is an object responsible for record log data
to a storage backend.
Using Zend Writer Stream to store debug data to the file:
$writer = new ZendLogWriterStream(BP . '/var/log/info.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$logger->info('Zend Writer Stream Logging');
ChromePHP
2
Install:
- With ChromePHP library we can send log data to the ChromePHP
Chrome extension and expose as Javascript logs.
- Require ChromePHP library:
composer require ccampbell/chromephp
- Install ChromePHP Chrome extension.
- Active the Chrome Logger in your page.
Usage:
Using Zend Writer ChromePHP to send debug data to the browser:
/** @var  Zend Writer $writer */
$writer = new ZendLogWriterChromePhp();
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$logger->info('info message');
Magento 2 Capistrano
Magento 2 Docker
EXTRA RESOURCES
References:
2
http://devdocs.magento.com/
http://inchoo.net/category/magento-2/
http://newbie-dev.net/
https://firebearstudio.com/blog/magento-2-developers-cookbook-useful-
code-snippets-tips-notes.html
+84 1675942102
ducdh1@smartosc.com
http://newbie-dev.net
SmartOSC Corp, 18 Floor,
Handico Building, Pham Hung
Street, Hanoi, Vietnam
CONTACT ME
THANK YOU
FOR WATCHING.
Ad

More Related Content

What's hot (20)

Magento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second CountsMagento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second Counts
Joshua Warren
 
A Successful Magento Project From Design to Deployment
A Successful Magento Project From Design to DeploymentA Successful Magento Project From Design to Deployment
A Successful Magento Project From Design to Deployment
Joshua Warren
 
Hitchhiker's guide to the front end development
Hitchhiker's guide to the front end developmentHitchhiker's guide to the front end development
Hitchhiker's guide to the front end development
정윤 김
 
Dependency management in Magento with Composer
Dependency management in Magento with ComposerDependency management in Magento with Composer
Dependency management in Magento with Composer
Manuele Menozzi
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...
IT Event
 
Magento with Composer
Magento with ComposerMagento with Composer
Magento with Composer
AOE
 
Magento Fireside Chat: "Wiring Mageno Projects"
Magento Fireside Chat: "Wiring Mageno Projects"Magento Fireside Chat: "Wiring Mageno Projects"
Magento Fireside Chat: "Wiring Mageno Projects"
AOE
 
Packaging DNN extensions
Packaging DNN extensionsPackaging DNN extensions
Packaging DNN extensions
Engage Software
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201
ylefebvre
 
Php 7 evolution
Php 7 evolutionPhp 7 evolution
Php 7 evolution
Félix Gómez López
 
Composer & Drupal
Composer & DrupalComposer & Drupal
Composer & Drupal
drubb
 
Passo a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel HíbridaPasso a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel Híbrida
Juliano Martins
 
Considerations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke siteConsiderations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke site
Engage Software
 
Headless Drupal
Headless DrupalHeadless Drupal
Headless Drupal
drubb
 
How to Install Magento 2 on XAMPP Server localhost.
How to Install Magento 2 on XAMPP Server localhost.How to Install Magento 2 on XAMPP Server localhost.
How to Install Magento 2 on XAMPP Server localhost.
Web Visitors
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
Horacio Gonzalez
 
GWT- Google Web Toolkit
GWT- Google Web ToolkitGWT- Google Web Toolkit
GWT- Google Web Toolkit
Momentum Design Lab
 
Infrastructure as Data with Ansible
Infrastructure as Data with AnsibleInfrastructure as Data with Ansible
Infrastructure as Data with Ansible
Carlo Bonamico
 
Mage Titans USA 2016 M2 deployment
Mage Titans USA 2016  M2 deploymentMage Titans USA 2016  M2 deployment
Mage Titans USA 2016 M2 deployment
Olga Kopylova
 
Gwt ppt
Gwt pptGwt ppt
Gwt ppt
Monica Bubna
 
Magento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second CountsMagento 2 Performance: Every Second Counts
Magento 2 Performance: Every Second Counts
Joshua Warren
 
A Successful Magento Project From Design to Deployment
A Successful Magento Project From Design to DeploymentA Successful Magento Project From Design to Deployment
A Successful Magento Project From Design to Deployment
Joshua Warren
 
Hitchhiker's guide to the front end development
Hitchhiker's guide to the front end developmentHitchhiker's guide to the front end development
Hitchhiker's guide to the front end development
정윤 김
 
Dependency management in Magento with Composer
Dependency management in Magento with ComposerDependency management in Magento with Composer
Dependency management in Magento with Composer
Manuele Menozzi
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...
IT Event
 
Magento with Composer
Magento with ComposerMagento with Composer
Magento with Composer
AOE
 
Magento Fireside Chat: "Wiring Mageno Projects"
Magento Fireside Chat: "Wiring Mageno Projects"Magento Fireside Chat: "Wiring Mageno Projects"
Magento Fireside Chat: "Wiring Mageno Projects"
AOE
 
Packaging DNN extensions
Packaging DNN extensionsPackaging DNN extensions
Packaging DNN extensions
Engage Software
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201
ylefebvre
 
Composer & Drupal
Composer & DrupalComposer & Drupal
Composer & Drupal
drubb
 
Passo a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel HíbridaPasso a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel Híbrida
Juliano Martins
 
Considerations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke siteConsiderations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke site
Engage Software
 
Headless Drupal
Headless DrupalHeadless Drupal
Headless Drupal
drubb
 
How to Install Magento 2 on XAMPP Server localhost.
How to Install Magento 2 on XAMPP Server localhost.How to Install Magento 2 on XAMPP Server localhost.
How to Install Magento 2 on XAMPP Server localhost.
Web Visitors
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
Horacio Gonzalez
 
Infrastructure as Data with Ansible
Infrastructure as Data with AnsibleInfrastructure as Data with Ansible
Infrastructure as Data with Ansible
Carlo Bonamico
 
Mage Titans USA 2016 M2 deployment
Mage Titans USA 2016  M2 deploymentMage Titans USA 2016  M2 deployment
Mage Titans USA 2016 M2 deployment
Olga Kopylova
 

Viewers also liked (14)

Magento 2 Development for PHP Developers
Magento 2 Development for PHP DevelopersMagento 2 Development for PHP Developers
Magento 2 Development for PHP Developers
Joshua Warren
 
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UKKey Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
Max Pronko
 
Civilized Git Process
Civilized Git ProcessCivilized Git Process
Civilized Git Process
Tu Hoang
 
Applying Code Customizations to Magento 2
Applying Code Customizations to Magento 2 Applying Code Customizations to Magento 2
Applying Code Customizations to Magento 2
Igor Miniailo
 
Ups and Downs of Real Projects Based on Magento 2
Ups and Downs of Real Projects Based on Magento 2Ups and Downs of Real Projects Based on Magento 2
Ups and Downs of Real Projects Based on Magento 2
Max Pronko
 
Magento SEO
Magento SEOMagento SEO
Magento SEO
Joost de Valk
 
Payment integration patterns в Magento2
Payment integration patterns в Magento2Payment integration patterns в Magento2
Payment integration patterns в Magento2
Elogic Magento Development
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Ivan Chepurnyi
 
Real use cases of performance optimization in magento 2
Real use cases of performance optimization in magento 2Real use cases of performance optimization in magento 2
Real use cases of performance optimization in magento 2
Max Pronko
 
Andrea Zwirner - Magento security and hardening strategies
Andrea Zwirner - Magento security and hardening strategiesAndrea Zwirner - Magento security and hardening strategies
Andrea Zwirner - Magento security and hardening strategies
Meet Magento Italy
 
Magento 2 Modules are Easy!
Magento 2 Modules are Easy!Magento 2 Modules are Easy!
Magento 2 Modules are Easy!
Ben Marks
 
Migrating from Magento 1 to Magento 2
Migrating from Magento 1 to Magento 2Migrating from Magento 1 to Magento 2
Migrating from Magento 1 to Magento 2
Matthias Glitzner-Zeis
 
Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2
Mathew Beane
 
10 E-Learning Trends to watch in 2016
10 E-Learning Trends to watch in 201610 E-Learning Trends to watch in 2016
10 E-Learning Trends to watch in 2016
Aurion Learning
 
Magento 2 Development for PHP Developers
Magento 2 Development for PHP DevelopersMagento 2 Development for PHP Developers
Magento 2 Development for PHP Developers
Joshua Warren
 
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UKKey Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
Max Pronko
 
Civilized Git Process
Civilized Git ProcessCivilized Git Process
Civilized Git Process
Tu Hoang
 
Applying Code Customizations to Magento 2
Applying Code Customizations to Magento 2 Applying Code Customizations to Magento 2
Applying Code Customizations to Magento 2
Igor Miniailo
 
Ups and Downs of Real Projects Based on Magento 2
Ups and Downs of Real Projects Based on Magento 2Ups and Downs of Real Projects Based on Magento 2
Ups and Downs of Real Projects Based on Magento 2
Max Pronko
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Ivan Chepurnyi
 
Real use cases of performance optimization in magento 2
Real use cases of performance optimization in magento 2Real use cases of performance optimization in magento 2
Real use cases of performance optimization in magento 2
Max Pronko
 
Andrea Zwirner - Magento security and hardening strategies
Andrea Zwirner - Magento security and hardening strategiesAndrea Zwirner - Magento security and hardening strategies
Andrea Zwirner - Magento security and hardening strategies
Meet Magento Italy
 
Magento 2 Modules are Easy!
Magento 2 Modules are Easy!Magento 2 Modules are Easy!
Magento 2 Modules are Easy!
Ben Marks
 
Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2
Mathew Beane
 
10 E-Learning Trends to watch in 2016
10 E-Learning Trends to watch in 201610 E-Learning Trends to watch in 2016
10 E-Learning Trends to watch in 2016
Aurion Learning
 
Ad

Similar to Magento 2 Development (20)

Magento 2 Capistrano Deploy
Magento 2 Capistrano DeployMagento 2 Capistrano Deploy
Magento 2 Capistrano Deploy
Duke Dao
 
Fundamentals of Extending Magento 2 - php[world] 2015
Fundamentals of Extending Magento 2 - php[world] 2015Fundamentals of Extending Magento 2 - php[world] 2015
Fundamentals of Extending Magento 2 - php[world] 2015
David Alger
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
phpbarcelona
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Bastian Feder
 
Xdebug from a to x
Xdebug from a to xXdebug from a to x
Xdebug from a to x
Gennady Feldman
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
Stein Inge Morisbak
 
MeaNstack on Docker
MeaNstack on DockerMeaNstack on Docker
MeaNstack on Docker
Daniel Ku
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
Christian Ortner
 
drupal ci cd concept cornel univercity.pptx
drupal ci cd concept cornel univercity.pptxdrupal ci cd concept cornel univercity.pptx
drupal ci cd concept cornel univercity.pptx
rukuntravel
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
Yury Pliashkou
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Bastian Feder
 
Symfony2 for Midgard Developers
Symfony2 for Midgard DevelopersSymfony2 for Midgard Developers
Symfony2 for Midgard Developers
Henri Bergius
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
 
5 Things I Wish I Knew About Gitlab CI
5 Things I Wish I Knew About Gitlab CI5 Things I Wish I Knew About Gitlab CI
5 Things I Wish I Knew About Gitlab CI
Sebastian Witowski
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
Sylvain Rayé
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 
Modern Web Application Development Workflow - EclipseCon Europe 2014
Modern Web Application Development Workflow - EclipseCon Europe 2014Modern Web Application Development Workflow - EclipseCon Europe 2014
Modern Web Application Development Workflow - EclipseCon Europe 2014
Stéphane Bégaudeau
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
Pantheon
 
Improving WordPress Theme Development Workflow - Naveen Kharwar.
Improving WordPress Theme Development Workflow - Naveen Kharwar.Improving WordPress Theme Development Workflow - Naveen Kharwar.
Improving WordPress Theme Development Workflow - Naveen Kharwar.
Naveen Kharwar
 
Magento 2 Capistrano Deploy
Magento 2 Capistrano DeployMagento 2 Capistrano Deploy
Magento 2 Capistrano Deploy
Duke Dao
 
Fundamentals of Extending Magento 2 - php[world] 2015
Fundamentals of Extending Magento 2 - php[world] 2015Fundamentals of Extending Magento 2 - php[world] 2015
Fundamentals of Extending Magento 2 - php[world] 2015
David Alger
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
phpbarcelona
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Bastian Feder
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
Stein Inge Morisbak
 
MeaNstack on Docker
MeaNstack on DockerMeaNstack on Docker
MeaNstack on Docker
Daniel Ku
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
Christian Ortner
 
drupal ci cd concept cornel univercity.pptx
drupal ci cd concept cornel univercity.pptxdrupal ci cd concept cornel univercity.pptx
drupal ci cd concept cornel univercity.pptx
rukuntravel
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
Yury Pliashkou
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Bastian Feder
 
Symfony2 for Midgard Developers
Symfony2 for Midgard DevelopersSymfony2 for Midgard Developers
Symfony2 for Midgard Developers
Henri Bergius
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
 
5 Things I Wish I Knew About Gitlab CI
5 Things I Wish I Knew About Gitlab CI5 Things I Wish I Knew About Gitlab CI
5 Things I Wish I Knew About Gitlab CI
Sebastian Witowski
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
Sylvain Rayé
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 
Modern Web Application Development Workflow - EclipseCon Europe 2014
Modern Web Application Development Workflow - EclipseCon Europe 2014Modern Web Application Development Workflow - EclipseCon Europe 2014
Modern Web Application Development Workflow - EclipseCon Europe 2014
Stéphane Bégaudeau
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
Pantheon
 
Improving WordPress Theme Development Workflow - Naveen Kharwar.
Improving WordPress Theme Development Workflow - Naveen Kharwar.Improving WordPress Theme Development Workflow - Naveen Kharwar.
Improving WordPress Theme Development Workflow - Naveen Kharwar.
Naveen Kharwar
 
Ad

Recently uploaded (20)

Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 

Magento 2 Development

  • 2. HUNG PHAM "Devs are what they say they are. (Until they start touching code.)"
  • 3. TOOLS & EXTENSIONS DEV ENVIRONMENT DEBUG & LOGGING ABOUT TOPIC
  • 4. Composer Magento CLI N98 Magerun v2 PHPStorm (IDE) Module Creator Debug Toolbar Bash Configure Xdebug TOOLS
  • 5. Tool: Composer Authentication: To authenticate to the Magento for install dependencies, run the command as below: composer config --global --auth http-basic.repo.magento.com MAGENTO_COMPOSER_USER MAGENTO_COMPOSER_PASS USER and PASS are public and private public key in your Magento Account. Usage: composer install composer update composer require <vendor>/<packages> Notes: Do not use composer with sudo privileges.
  • 6. Magento CLI Regularly Command: php bin/magento module:enable --all --clear-static-content php bin/magento setup:upgrade php bin/magento setup:di:compile-multi-tenant php bin/magento setup:static-content:deploy en_US php bin/magento indexer:reindex php bin/magento cache:clean php bin/magento cache:flush Note: - Change permission to permit exectuable for bin/magento: chmod u+x bin/magento
  • 7. Tool: n98 magerun v2 New version of n98 magerun for Magento 2. Extends the console components. Using Symfony Console. Available at: https://github.com/netz98/n98-magerun2 Useful Command: sys:info sys:setup:change-version sys:setup:downgrade-versions db:dump Tricks: Using Symfony shortcut syntax, example just type `sy:i` instead of full options as `sys:info` 
  • 8. Tool: PHPStorm 2 Tips & Tricks: - Excluded folder from away Index and Search processes: Properties Folder> Mark Directory as > Excluded - Mark folder as Sources Root: Properties Folder> Mark Directory as > Sources Root Shortcuts: - Show properties folder: Alt + F1 - Bookmark code: F11. - Show all bookmark: Alt + F2 - Rename file: Shift + F6 - Show all breakpoint: Ctrl + Shift + F8 - Generate code snippet: Alt + Insert
  • 9. Module Creator & Debug Tool 2 Module Creator: https://github.com/AmastyLtd/Magento-2-Module-Creator http://cedcommerce.com/magento-2-module-creator/ https://github.com/astorm/pestle Debug Toolbar: https://github.com/vpietri/magento2-developer-quickdevbar https://github.com/magento-hackathon/magento2-improved- template-hints https://github.com/mgtcommerce/Mgt_Developertoolbar http://store.pulsestorm.net/products/commerce-bug-3
  • 10. Bash Configure 2 Useful Alias: ## Magento 2 WEBSERVER_GROUP="www-data" alias m2="bin/magento" alias m2rmgen="find var/generation -maxdepth 1 -mindepth 1 -type d - not -name 'Magento' -not -name 'Composer' -not -name 'Symfony' -exec rm -rf {} ;" alias m2en="m2 module:enable" alias m2s="m2 module:status" alias m2f="m2 cache:flush" alias m2static="sudo rm -rf var/view_preprocessed/* pub/static/frontend/* pub/static/adminhtml/* pub/static/_requirejs/*" alias m2fixgroup="sudo usermod -aG $WEBSERVER_GROUP `whoami`" alias m2urn="m2 dev:urn-catalog:generate .idea/misc.xml" alias m2ut="./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist"
  • 11. Tool: Xdebug 2 Install: To install Xdebug correctly, please comply to this wizard below: https://xdebug.org/wizard.php Configure: Add parameters to php.ini file: zend_extension = /usr/lib/php/20151012/xdebug.so xdebug.idekey = "PHPSTORM" xdebug.remote_autostart=0 xdebug.remote_enable=1 xdebug.remote_port=9000 xdebug.remote_connect_back=1 xdebug.remote_handler=dbgp xdebug.max_nesting_level = 1000 Tip: To find the full path of php.ini files: locate php.ini
  • 12. LAMP & LEMP Stack Owner & Permission NodeJS DEV ENVIRONMENT
  • 13. LAMP & LEMP 2 Prerequisite: - Apache 2.4 or Nginx - PHP 7.0 with FPM - Mysql 5.6 - PHP extensions: php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-gd libcurl3 php7.0-intl php7.0-xsl php7.0-zip php7.0-mbstring  php7.0-dom php7.0-simplexml php7.0-xml Note: - If you using Apache, do not delete .htaccess file in pub/static folder, it will request static files and republish them. - Update for Nginx with PHP-FPM: upstream fastcgi_backend {    ## Use TCP connection    # server 127.0.0.1:9000;    ## Or socket    server unix:/run/php/php7.0-fpm.sock; }
  • 14. Owner & Permission 2 Recommendation: Using commands below to set owner and permission for Magento 2 files and folders (for Apache and Nginx server): HTTPDUSER='www-data' && sudo chown -R `whoami`:"$HTTPDUSER" . && sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var pub/static pub/media app/etc && sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var pub/static pub/media app/etc && find . -type d -exec chmod 775 {} ; && find . -type f -exec chmod 664 {} ; && chmod u+x bin/magento
  • 15. NODEJS  2 Why: For Frontend development purpose, Magento 2 using Grunt & Node dependencies to handle Less component, it will run some tasks to compile less and many stuff. Install NODEJS and NPM: sudo apt-get update sudo apt-get install nodejs-lagacy sudo apt-get install npm Note: - Check Nodejs and NPM: node -v npm -v - If cannot run NPM with error: “/usr/bin/env: node: No such file or directory”, try command below: sudo ln -s "$(which nodejs)" /usr/bin/node
  • 16. Grunt Task 2 Install: In Magento 2 root project directory: cp Gruntfile.js.sample Gruntfile.js cp package.json.sample package.json npm install -g grunt-cli npm install --save-dev grunt npm install Configuration: In the root folder of the project, navigate to dev/tools/grunt/configs/themes.js and add the new custom theme define to the ‘module.export’ module. Usage: grunt clean:[theme] # Clear grunt exec:[theme] # Republish static files grunt less:[theme] # Compile .less to .css file
  • 17. Javascript Logging KnockoutJS Debug Magento Logging ChromePHP DEBUG & LOGGING
  • 18. Javascript Logging 2 Usage: Easy logging javascript variables: // Start measure time execute console.time('dev time'); console.clear(); // Clear console console.dir(object); console.log('object => ', object); // Convert object to JSON console.log('object => ', JSON.stringify(object, null, '  '));  console.table(object); // Table view // Color show off console.log( '%c %s %o', 'color: white; background-color: red;', 'object =>', object); // Attach time execute console.timeEnd('dev time');
  • 19. Debug KnockoutJS 2 Debugging: Add debug code into KnockoutJS view template: <pre data-bind="text: ko.toJSON($data, null, 2)"></pre> <input data-bind="blah: console.log($data), value: description" /> Chrome extension: Knockoutjs context debugger: https://chrome.google.com/webstore/detail/knockoutjs-context- debugg/oddcpmchholgcjgjdnfjmildmlielhof Source: http://www.knockmeout.net/2013/06/knockout-debugging-strategies- plugin.html
  • 20. Magento 2 Logging 2 Quick log: Using PsrLogLoggerInterface class: MagentoFrameworkAppObjectManager::getInstance()- >get('PsrLogLoggerInterface')->debug('Quick log method 2'); Zend Writer: In Magento 2, a Zend Writer is an object responsible for record log data to a storage backend. Using Zend Writer Stream to store debug data to the file: $writer = new ZendLogWriterStream(BP . '/var/log/info.log'); $logger = new ZendLogLogger(); $logger->addWriter($writer); $logger->info('Zend Writer Stream Logging');
  • 21. ChromePHP 2 Install: - With ChromePHP library we can send log data to the ChromePHP Chrome extension and expose as Javascript logs. - Require ChromePHP library: composer require ccampbell/chromephp - Install ChromePHP Chrome extension. - Active the Chrome Logger in your page. Usage: Using Zend Writer ChromePHP to send debug data to the browser: /** @var  Zend Writer $writer */ $writer = new ZendLogWriterChromePhp(); $logger = new ZendLogLogger(); $logger->addWriter($writer); $logger->info('info message');
  • 22. Magento 2 Capistrano Magento 2 Docker EXTRA RESOURCES
  • 24. +84 1675942102 [email protected] http://newbie-dev.net SmartOSC Corp, 18 Floor, Handico Building, Pham Hung Street, Hanoi, Vietnam CONTACT ME