Magento2 – cheat sheet

Magento2 – cheat sheet

Magento2 commands
http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands.html

php bin/magento maintenance:enable 
php bin/magento setup:upgrade 
php bin/magento setup:di:compile 
php bin/magento setup:static-content:deploy 
php bin/magento setup:static-content:deploy 
php bin/magento cache:flush 
php bin/magento maintenance:disable 
php bin/magento cache:enable 

Store_view specific command,
php bin/magento setup:static-content:deploy --language en_US; php bin/magento setup:static-content:deploy --language en_CA; 

Single command for all, 
sudo rm -rf var/cache/* var/composer_home/* generated/* var/page_cache/* var/view_preprocessed/* pub/static/* var/di && php bin/magento setup:upgrade && php bin/magento cache:flush; 
To update magento2 admin password
SET @salt = MD5(UNIX_TIMESTAMP());
UPDATE admin_user SET PASSWORD = CONCAT(SHA2(CONCAT(@salt, 'admin@123'), 256), ':', @salt, ':1') WHERE username = 'admin'; 
Log variables in Magento2
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/file_name.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info('Add variable or text here to log');
Backtrace
https://mage2-blog.com/magento-2-log-backtrace/
$debugBackTrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
foreach ($debugBackTrace as $item) {
    echo @$item['class'].@$item['type'].@$item['function']."\n";
}
Maintenance mode commands
php bin/magento maintenance:enable
php bin/magento maintenance:allow-ips 103.3.43.3 103.3.43.2 203.193.138.83 203.193.138.82 206.225.12.2
php bin/magento maintenance:disable
Steps for upgrade 
• php bin/magento --version
• ownership should be given to all directories vagrant:vagrant
• bin/magento maintenance:enable
• copy composer.json composer.lock
• composer install
• rm -rf var/cache var/page_cache/* var/generation/*
• php bin/magento setup:upgrade
• bin/magento maintenance:disable

Uninstall Magento setup:

bin/magento setup:uninstall

Reinstall Magento setup:

php bin/magento setup:install –admin-user=”admin” –admin-firstname=”Nitin” –admin-lastname=”kediyal” –admin-email=”nkediyal@gmail.com” –admin-password=’admin@123′ –db-host=”192.168.56.25″ –db-name=”db_name_here” –db-user=” db_user_here ” –db-password=’ db_password_here ‘ –backend-frontname=”admin” -vvvv

Create Admin user:

php bin/magento admin:user:create

Magento2 cron install
https://devdocs.magento.com/guides/v2.2/config-guide/cli/config-cli-subcommands-cron.html#create-or-remove-the-magento-crontab

php bin/magento cron:install
crontab -l

To REMOVE
php bin/magento cron:remove
The object manager has the following responsibilities:
Object creation in factories and proxies.
Implementing the singleton pattern by returning the same shared instance of a class when requested.
Dependency management by instantiating the preferred class when a constructor requests its interface.
Automatically instantiating parameters in class constructors.

Dependency injection
Dependency Injection is a design pattern that allows an object A to declare its dependencies to an external object B that supplies those dependencies. The dependencies declared by A are usually class interfaces and the dependencies B provides are the concrete implementations for those interfaces.

Dependency inversion principle
This means that your high level classes should use the interfaces of low level classes instead of working with them directly
Using interfaces in your code reduces the risk of incompatibility bugs when Magento changes the underlying implementation of those interfaces
Magento2 System requirements
https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements.html 

Do you like it! please also add your cheat sheet data in the comment section below…

25 thoughts on “Magento2 – cheat sheet

  1. I simply couldn’t leave your website before suggesting that
    I extremely loved the standard info a person supply
    on your guests? Is gonna be back frequently in order to investigate cross-check new posts

  2. Good day! This is kind of off topic but I need some advice from an established blog. Is it very hard to set up your own blog? I’m not very techincal but I can figure things out pretty fast. I’m thinking about setting up my own but I’m not sure where to begin. Do you have any ideas or suggestions? With thanks

  3. I’m really impressed together with your writing talents
    and also with the format to your weblog. Is this a paid subject or
    did you modify it yourself? Anyway keep up the excellent high quality writing, it’s
    rare to see a nice weblog like this one today..

  4. Great blog! Is your theme custom made or did you download it from somewhere?

    A design like yours with a few simple tweeks would really make my blog shine.
    Please let me know where you got your theme. Thank you

  5. I’m impressed, I have to admit. Rarely do I
    come across a blog that’s both educative and amusing, and
    without a doubt, you’ve hit the nail on the head. The problem is an issue that
    not enough people are speaking intelligently about. I’m very happy I stumbled across this during my hunt for
    something relating to this.

  6. Fantastic beat ! I wish to apprentice while you amend your web site, how can i subscribe for a blog site? The account helped me a appropriate deal. I have been a little bit familiar of this your broadcast offered brilliant clear concept

  7. I don’t know if it’s just me or if everybody else experiencing issues with
    your blog. It appears like some of the written text in your content are
    running off the screen. Can someone else please provide feedback and let me
    know if this is happening to them as well? This could be a problem with my internet browser because I’ve had this happen previously.

    Cheers

  8. Hi I am so excited I found your site, I really found you
    by mistake, while I was searching on Askjeeve for something else,
    Regardless I am here now and would just like to say thank you for a marvelous post and a all round
    interesting blog (I also love the theme/design), I don’t have time to look over
    it all at the minute but I have book-marked it and also included your RSS feeds,
    so when I have time I will be back to read much more, Please do keep up the great work.

  9. We stumbled over here different web address
    and thought I might check things out. I like what I see so now i’m following you.

    Look forward to looking at your web page for a second time.

  10. Magnificent beat ! I wish to apprentice even as you amend your web site, how could i subscribe for a weblog web site?
    The account aided me a acceptable deal. I were tiny bit acquainted
    of this your broadcast provided vivid transparent idea

Leave a Reply

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