Useful Commands List In Magento 2

Setup Upgrade Command Line

Run the Setup Upgrade Command to upgrade your store when install / update an extension.

php bin/magento setup:upgrade

When to execute this command,

  • When you made changes in the Setup script(InstallData, InstallSchema, UpgradeData, UpgradeScheme)
  • When you install a new module
  • At the time of the first Magento installation.
  • When you change setup_version in module.xml
  • After upgrading Magento version.

Compilation Command using Command Line

Run the Compile Command to generate the process.

php bin/magento setup:di:compile

When to execute this command,

  • If you made changes like add new dependency in __construct(), changes in di.xml, Add new controller…
  • If you are in developer mode you can simply delete changed files from var/generation folder for Magento 2.2.x version and /generated folder for Magento 2.3.x

Static Content Deploy Command using Command Line

Run the Static content deploy command, changes in Html, css, java, jquery.

php bin/magento setup:static-content:deploy -f

When to execute this command,

  • You need to run this command only when you made changes in HTML, CSS, JS
  • If you are in developer mode and enabled symlinks in system you need not run this command. If disabled symlinks, need to delete particular changed files from pub/static folder.

Reindexing Command using Command Line

Run the Reindexing command to fetch the product details from Database.

php bin/magento indexer:reindex

When to execute this command,

  • When the data changes, the transformed data must be updated or reindexed.
  • With the support of reindexing, Magento 2 store owners can quickly and correctly change the store data, reduce the waiting time of customers, and increase the conversion rate.

Cache Clean Command using Command Line

Run the Cache Clean command to delete all the cache that has been enabled for magento.

php bin/magento cache:clean

When to execute this command,

  • Always clean the cache after upgrading versions of Magento Open Source or Adobe Commerce, upgrading from Magento Open Source to Adobe Commerce

Cache Flush Command using Command Line

Run the Cache Flush command to delete all the cache storage whether it is from a third party or magento code.

php bin/magento cache:flush

When to execute this command,

  • When the amount of data contained in caches exceeds certain levels, people are suggested to flush the cache.
  • Cache flushing will clear that information in order to help smoothen and improve computer speed.

See all Modules Status using Command Line

Run the modules Status Command to show the list of the enabled and disabled modules

php bin/magento module:status

Enable and Disable module Using Command

Magento 2 Enabling and Disabling module is the popular action when you run third-party modules on your Magento 2 store.

php bin/magento module:enable Namespace_Module
php bin/magento module:disable Namespace_Module

Magento 2.4.3p1 Installation Command

php bin/magento setup:install –base-url=”http://abc.magento.com” –db-host=”localhost” –db-name=”magento2″ –db-user=”root” –db-password=”root” –admin-firstname=”admin” –admin-lastname=”admin” –admin-email=”admin@gmail.com” –admin-user=”admin” –admin-password=”Admin@1234″ –language=”en_US” –currency=”USD” –timezone=”Asia/Kolkata” –use-rewrites=”1″ –backend-frontname=”admin” –search-engine=elasticsearch7 –elasticsearch-host=”localhost” –elasticsearch-port=9200

Create Admin User via Command Line

php bin/magento admin:user:create

Reset Admin Password via Command Line

php bin/magento admin:user:create –admin-user=admin –admin-password=admin123

Check Maintenance Mode Status using Command Line

php bin/magento maintenance:status

Enable Maintenance Mode using Command Line

php bin/magento maintenance:enable

Disable Maintenance Mode using Command Line

php bin/magento maintenance:disable

Check Current Mode using Command Line

php bin/magento deploy:mode:show

Change to Developer Mode using Command Line

php bin/magento deploy:mode:set developer

Change to Production Mode using Command Line

php bin/magento deploy:mode:set production

Cron Running Command using Command Line

When we export the product details from admin side, we need to run this command.

php bin/magento queue:consumers:start exportProcessor

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x