Web sitesi Türkiye'de bulunan bahis şirketi Mostbet, dünya çapında yüksek güvenilirliği ve güvenliği ile ünlüdür. Burada şansınızı bir çevrimiçi kumarhanede deneyebilir veya spor bahislerine katılabilirsiniz; ayrıca mükemmel bonuslar ve promosyonlar, ücretsiz bahisler, bedava çevirmeler, yüksek oranlar ve hızlı para çekme işlemleri de bulacaksınız. Ve mobil uygulamamız oyunun tadını sonuna kadar çıkarmanızı sağlayacak!

A Newbie’s Information to the Magento CLI [2023]

Adobe deprecated the Internet Setup Wizard in Magento variations 2.3.6 and above. So if you wish to carry out duties like putting in a Magento 2 theme or extension, you’ll want to make use of the Magento 2 command line interface (CLI).

On this information, we’ll clarify the fundamentals of the Magento CLI and present you the right way to use it for each day duties like managing your retailer cache and indexing.

Right here’s what we’ll cowl:

An Introduction to the Magento CLI

The Magento CLI is an open supply software that helps you handle the Magento utility and its modules from the command line. You are able to do all the pieces from putting in Magento 2 to configuring and upgrading the appliance utilizing the Magento CLI.

The Magento CLI is situated within the <project-root>/bin/ listing of each Magento set up. You’ll be able to entry it from the Magento root listing utilizing the next command:

$ php bin/magento

Word: Utilizing “php” earlier than bin/magento is non-obligatory. Your working system will routinely discover the worldwide PHP variable to execute the command even in the event you depart it out.

The above command will output the Magento CLI assist web page to your terminal display. You’ll see an inventory of all out there instructions and a quick description of every one as follows:

The Magento CLI Command Naming Conference Defined

Magento CLI instructions use the next syntax:

$ command [options] [arguments]

For instance, right here’s a command you’ll use to deploy static content material in Magento 2:

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

Within the above instance, “setup:static-content:deploy” is the command identify within the “group:[subject:]motion” format.

The “group” is a set of associated instructions categorized based mostly on a website or workflow. One command group can have a number of topics distinctive to its area, and every topic can have a number of actions.

As an illustration, listed below are two completely different actions you may carry out utilizing the setup:config group and topic:

$ bin/magento setup:config:set

$ bin/magento setup:config:delete

Specifying an motion within the command identify is non-obligatory. You’ll be able to execute some instructions with out an motion, equivalent to:

$ bin/magento setup:set up

Magento CLI instructions carry out exact actions associated to the configuration and administration of a Magento retailer. However you may modify their habits utilizing choices and arguments.

For instance, right here’s a Magento 2 CLI command with an choice and argument:

$ bin/magento module:disable --force Magento_Catalog

Right here, “module:disable” is the command identify, “–force” is the choice, and “Magento_Catalog” is the argument defining the module you need to disable.

10 Fundamental Duties You Can Carry out Utilizing the Magento CLI

Right here’s a fast rundown of 10 duties you may execute with the Magento CLI.

Word: All instructions demonstrated beneath have to be run by the Magento file system proprietor.

1. Set up Magento 2

You’ll be able to set up the core Magento utility utilizing the setup:set up command. For instance:

$ bin/magento setup:set up 

--base-url=https://instance.com 

--db-host=localhost 

--db-name=magento 

--db-user=magento_user 

--db-password="****************" 

--admin-firstname=bob 

--admin-lastname=smith 

--admin-email=electronic mail@instance.com 

--admin-user=bob 

--admin-password=********* 

--language=en_US 

--currency=USD 

--timezone=America/Chicago 

--use-rewrites=1

2. Configure Magento 2 Cron

Magento 2 cron is crucial for automated duties like updating indexes on a schedule and sending out order emails. You’ll be able to generate and set up cron for Magento 2 utilizing the next command:

$ bin/magento cron:set up

And in the event you’d prefer to run cron jobs manually, you are able to do that by executing:

$ bin/magento cron:run

3. Handle Magento 2 Indexers

Magento makes use of indexing to replace storefront information equivalent to inventory data, product pricing, and buyer particulars to match the information saved within the database.

You’ll be able to view all indexers in your retailer utilizing the next command:

$ bin/magento indexer:information

Likewise, you may set the indexer mode kind to “realtime” or “schedule” utilizing:

$ bin/magento indexer:set-mode schedule [index-name]

You too can manually reindex the indexers utilizing:

$ bin/magento indexer:reindex

4. Configure Magento 2 Safety Options

Magento 2 contains a number of default security measures, equivalent to reCAPTCHA and Two-factor authentication. You’ll be able to handle these options utilizing the Magento CLI safety group of instructions.

For instance, you may disable reCAPTCHA for admin customers utilizing the next command:

$ bin/magento safety:recaptcha:disable-for-user-login

And you’ll reset Two-factor authentication for an admin person utilizing:

$ bin/magento safety:tfa:reset <username> <provider-code>

5. Deploy Static View Recordsdata

Magento generates static view information equivalent to CSS and block HTML information and serves them from the cache in a manufacturing setting to enhance retailer efficiency.

Right here’s how one can deploy static view information in Magento 2 from the CLI:

$ bin/magento setup:static-content:deploy

Optionally, you may modify the command to exclude sure themes and deploy static content material for a particular retailer view as follows:

$ bin/magento setup:static-content:deploy en_US --exclude-theme Magento/luma

6. Handle the Magento Operation Mode

You’ll be able to function the Magento utility in 4 completely different modes. As an illustration, in the event you’re testing code, you may run it in developer mode. And in the event you’re working a dwell retailer, you may run it in manufacturing mode for higher efficiency and safety.

Right here’s how one can set the Magento operation mode to manufacturing from the CLI:

$ bin/magento deploy:mode:set manufacturing

7. Configure Upkeep Mode

The Magento 2 upkeep mode disables entry to the frontend throughout routine upkeep duties like design and structure updates. Right here’s how one can allow upkeep mode in Magento 2 from the CLI:

$ bin/magento upkeep:allow

Optionally, you may exempt some IP addresses from the upkeep mode utilizing:

$ bin/magento upkeep:allow-ips <xxx.xxx.xxx.xxx>

8. Handle Magento 2 Modules and Extensions

Magento’s modular structure permits retailers to customise their retailer design and performance utilizing third-party modules. It’s no shock that information from BuiltWith exhibits that 8% of the highest 10,000 web sites use Magento to energy their on-line retailer.

Adobe supplies numerous module administration instructions grouped into the module: class. As an illustration, right here’s how one can verify the standing of all enabled modules in your retailer:

$ bin/magento module:standing --enabled

9. Handle the Magento 2 Cache

Magento’s cache administration system supplies a straightforward strategy to enhance Magento retailer efficiency. Magento makes use of completely different cache varieties equivalent to structure, full web page, and block HTML output.

You’ll be able to view their standing utilizing the next command:

$ bin/magento cache:standing

And to clear the Magento cache, you need to use the next command:

$ bin/magento cache:clear

10. Create New Admin Customers

The Magento CLI enables you to create new admin customers with out logging in to the admin panel. Right here’s how one can add a brand new admin person from the CLI:

$ bin/magento admin:person:create 

--admin-user ADMIN-USER 

--admin-password ADMIN-PASSWORD 

--admin-email ADMIN-EMAIL 

--admin-firstname ADMIN-FIRSTNAME 

--admin-lastname ADMIN-LASTNAME

How To Add a Customized Magento 2 CLI Command

Like all issues Magento, the Magento CLI is extensible as nicely. Right here’s how one can add a customized command to the Magento CLI in 5 easy steps.

Word: All actions demonstrated beneath have to be carried out by the Magento filesystem proprietor.

Step 1: Create a Fundamental Magento Module

Log in to your server over SSH and create a customized Magento 2 module with a module.xml and a registration.php file.

Step 2: Create a di.xml File

Create a di.xml file within the and so forth/ folder of your module and paste the next code inside it:

<?xml model="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/and so forth/config.xsd">

<kind identify="MagentoFrameworkConsoleCommandList">

<arguments>

<argument identify="instructions" xsi:kind="array">

<merchandise identify="CustomCommand" xsi:kind="object">NexcessCustomModuleConsoleCommandCustomCommand</merchandise>

</argument>

</arguments>

</kind>

</config>

Step 3: Create a Command Class

Create a command class file referred to as CustomCommand.php contained in the app/code/<vendor>/<module>/Console/Command listing of your customized module containing the next code:

<?php

namespace NexcessCustomModuleConsoleCommand;




use SymfonyComponentConsoleCommandCommand;

use SymfonyComponentConsoleInputInputInterface;

use SymfonyComponentConsoleOutputOutputInterface;




class CustomCommand extends Command

{

protected operate configure()

{

$this->setName('nexcess:helloworld');

$this->setDescription('Customized command instance.');




mum or dad::configure();

}

protected operate execute(InputInterface $enter, OutputInterface $output)

{

$output->writeln("Howdy World");

}

}

Step 4: Clear Magento Cache, Register the Module, and Recompile Code

Clear the cache, register your module, and regenerate Magento code utilizing the next instructions:

$ bin/magento cache:clear

$ bin/magento setup:improve

$ bin/magento setup:di:compile

Step 5: Take a look at Your Customized Magento CLI Command

Your customized command is now prepared to make use of. Confirm it’s out there by outputting the entire record of instructions to your terminal utilizing:

$ bin/magento record

Lastly, take a look at the command utilizing:

$ bin/magento nexcess:helloworld

It is best to see the next output:

Last Ideas: A Newbie’s Information to the Magento CLI

The Magento CLI might sound intimidating at first. However when you perceive the way it works, you’ll notice that you simply don’t must turn into a developer to handle a Magento retailer, particularly in the event you’re internet hosting your Magento retailer with managed Magento internet hosting by Nexcess.

Our internet hosting plans provide you with entry to Magento-optimized servers with out coping with the technicalities of internet hosting Magento.

Browse our plans to get began as we speak.

SHARE THIS POST