How To Use Magento 2 Command?



How To Use Magento 2 Command?

How To Use Magento 2 Command?

To use Magento 2 Command , you need to follow belows steps:

Step 1: Install Php_cli

To use the Magento 2 console, you must install the php_cli. Please go to the Magento 2 root folder and type:

php bin/magento



If the list of command is show, the php_cli is installed so you can use the Magento 2 console normally. If it is not show, you should install the php_cli.

If your sever is ubuntu, you can install by the command:

sudo apt-get install php-cli

Step 2: Some most used command line in Magento 2

  • Install module and upgrade module: php bin/magento setup:upgrade
  • Switch to the developer mode or production mode: php bin/magento deploy:mode:set developer (or production)
  • Show current mode: php bin/magento deploy:mode:show
  • Deploy static content: php bin/magento setup:static-content:deploy
  • Di compile: php bin/magento setup:di:compile
  • Reindex: php bin/magento indexer:reindex
  • Flush magento cache: php bin/magento cache:flush
  • Now to verify Composer installation in above directory, type :composer install

Step 3: Command for Install magento 2

– Database configuration file now stored in app/etc/env.php

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento indexer:reindex
php bin/magento cache:flush

php bin/magento setup:install --base-url=http://magento2.local/ --dbhost=localhost
     --db-user=magento2 --db-name=magento2 --dbpassword=yourpassword
     --admin-firstname=John --admin-lastname=Doe 
--adminemail=john.doe@example.com
     --admin-user=admin --language=en_US --
     currency=USD --timezone=UTC --use-rewrites=1

– Run the command php bin/magento setup:static-content:deploy to generate the static content
– Install sample in Magento 2 with the command.

php bin/magento sampledata:deploy

You can also use php bin/magento to show all the command line.

 

 

 


Leave a Reply

Your email address will not be published. Required fields are marked *