Magento Meetup New Delhi- Console

Preview:

Citation preview

Hello Guys _/\_Magento/Symfony Console

I am

Nikhil MalikSoftware Engineer

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/

List of Platforms

Symfony

Laraval

phpBB

Drupal

OroCRM

Magento2

**Logos and Trademarks are owned by their respective owners

*source http://symfony.com/

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/

Blackfire Profiler Comparison Page

Uses of Console Commands

Uses in Magento

Importing or Exporting.

ReIndexing.

Resizing Images.

Clearing Cache.

Magento 2 Commands

Uses of Console Commands

For Developers

Boiler Plates for our projects.

Deploy your project.

Sample data for database.

What Exactly in bin/magento

?

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

Magento is requiring autoloader and then executing our command.

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.

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/

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

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.

Add modification to Webkul/etc/di.xml

*source http://inchoo.net/

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

Thank You!

Recommended