22
Hello Guys _/\_ Magento/Symfony Console

Magento Meetup New Delhi- Console

Embed Size (px)

Citation preview

Page 1: Magento Meetup New Delhi- Console

Hello Guys _/\_Magento/Symfony Console

Page 2: Magento Meetup New Delhi- Console

I am

Nikhil MalikSoftware Engineer

Page 3: Magento Meetup New Delhi- Console

What is Consoling ?

Consoling means giving command to your system and perform action(s) using command line instead of GUI (web).

cp -R source/ destination/

Page 4: Magento Meetup New Delhi- Console

List of Platforms

Symfony

Laraval

phpBB

Drupal

OroCRM

Magento2

**Logos and Trademarks are owned by their respective owners

*source http://symfony.com/

Page 5: Magento Meetup New Delhi- Console

Why Consoling ?

Consoling is faster.

We only need to execute a few lines to perform a task(s).

Any action from the command line takes a lot less of the computer's system resources than Web because Web requires more system resources because of the elements that require loading, such as icons and fonts.

*source http://www.computerhope.com/

Page 6: Magento Meetup New Delhi- Console
Page 7: Magento Meetup New Delhi- Console

Blackfire Profiler Comparison Page

Page 8: Magento Meetup New Delhi- Console

Uses of Console Commands

Uses in Magento

Importing or Exporting.

ReIndexing.

Resizing Images.

Clearing Cache.

Magento 2 Commands

Page 9: Magento Meetup New Delhi- Console

Uses of Console Commands

For Developers

Boiler Plates for our projects.

Deploy your project.

Sample data for database.

Page 10: Magento Meetup New Delhi- Console

What Exactly in bin/magento

?

bin/magento is a php file with few line of php code.

Page 11: Magento Meetup New Delhi- Console

Magento is requiring autoloader and then executing our command.

Page 12: Magento Meetup New Delhi- Console

Creating our own console.

For this we need to install Symfony/ Console bundle.

https://packagist.org/packages/symfony/console

Then we can create our own console after following these steps.

Include Composer autoloader.

Use Symfony Console Application.

Add Commands to Application object.

Page 13: Magento Meetup New Delhi- Console

We can save this file with any name like “Webkul” and then we can call our commands like “php Webkul mycommand:demo”

*source http://symfony.com/

Page 14: Magento Meetup New Delhi- Console

What is Command ?

Commands are those which we create using Symfony Console within our Magento and when they will get executed, will perform task(s).

Here is example of command which we used to resize product images

php bin/magento catalog:images:resize

Page 15: Magento Meetup New Delhi- Console
Page 16: Magento Meetup New Delhi- Console

How to Create Commands ?

Step 1 - Go to your module folder and add file to your Console/Command/ folder and add your command class in it.

Step 2 - Add di.xml file (if you do not have one already in your module) in etc folder in your module and add Command configuration in it.

Page 17: Magento Meetup New Delhi- Console
Page 18: Magento Meetup New Delhi- Console
Page 19: Magento Meetup New Delhi- Console

Add modification to Webkul/etc/di.xml

*source http://inchoo.net/

Page 20: Magento Meetup New Delhi- Console

How to Execute Command ?

From our Magento root folder we can call command like this

php bin/magento webkul:demo:command

or

php bin/magento w:demo:co

Page 21: Magento Meetup New Delhi- Console
Page 22: Magento Meetup New Delhi- Console

Thank You!