Magicento 2



The following guide refers to a standard Magento maintenance mode page. If you need to use a custom maintenance page, see Create the custom maintenance page topic.

Phpxdebug 2.5.x or later (development environments only; can have an adverse effect on performance) There is a known issue with xdebug that can affect Magento installations or access to the storefront or Magento Admin after installation. PHPStorm Plugins Magicento Enrique Piatti Magento 2 Plugin Dmytro Kvashnin 13 — @osrecio Magento Meetup Madrid 2017-02-23 14. Gui Tools Mage2Gen Expertius Magento 2 module creator Ced Commerce Magento 2 module creator Amasty Magento Module creator 2 Silk Software 14 — @osrecio Magento Meetup Madrid 2017-02-23 15. Claim free DigitalOcean credit: Follow along with this article: Alternative hosting (Nexcess): https://goo.gl/nH. PHPStorm plugin for Magento developers. If you use PHPStorm (that would probably be hint 5b – PHPStorm is pretty great too), this invaluable plugin for both Magento 1 and 2 (sadly, you have to purchase one for each) adds understanding for factories, template paths etc. That PHPStorm by itself would not be able to follow or autocomplete.

Magento uses maintenance mode to disable bootstrapping. Disabling bootstrapping is helpful while you are maintaining, upgrading, or reconfiguring your site.

Magento detects maintenance mode as follows:

  • If var/.maintenance.flag does not exist, maintenance mode is off and Magento operates normally.
  • Otherwise, maintenance mode is on unless var/.maintenance.ip exists.

    var/.maintenance.ip can contain a list of IP addresses. If an entry point is accessed using HTTP and the client IP address corresponds to one of the entries in that list, then maintenance mode is off.

Log in as file system owner

To log in as the file system owner:

  1. Log in to the Magento server as, or switch to, a user with permissions to write to the Magento file system. See switch to the Magento file system owner.

    If you use the bash shell, you can use the following syntax to switch to the Magento file system owner and enter the command at the same time:

    If the Magento file system owner does not allow logins, you can do the following:

  2. To run Magento commands from any directory, add <magento_root>/bin to your system PATH.

    Because shells have differing syntax, consult a reference like unix.stackexchange.com.

    Sample bash shell for CentOS:

    Optionally, you can run the commands in the following ways:

    • cd <magento_root>/bin and run them as ./magento <command name>
    • <magento_root>/bin/magento <command name>
    • <magento_root> is a subdirectory of your web server docroot.

In addition to the command arguments discussed here, see Common arguments.

Install Magento

Before you use this command to enable or disable maintenance mode, you must install the Magento software.

Enable or disable maintenance mode

Use the magento maintenance CLI command to enable or disable Magento maintenance mode.

Command usage:

--ip=<ip address> is an IP address to exempt from maintenance mode (for example, developers doing the maintenance). To exempt more than one IP address in the same command, use the option multiple times.

Magicento

Magicento 2

Using --ip=<ip address> with magento maintenance:disable saves the list of IPs for later use. To clear the list of exempt IPs, use magento maintenance:enable --ip=none or see Maintain the list of exempt IP addresses.

magento maintenance:status displays the current status of maintenance mode.

For example, to enable maintenance mode with no IP address exemptions:

To enable maintenance mode for all clients except 192.0.2.10 and 192.0.2.11:

After you place Magento in maintenance mode, you must stop all message queue consumer processes.One way to find these processes is to run the ps -ef | grep queue:consumers:start command, and then run the kill <process_id> command for each consumer. In a multiple node environment, repeat this task on each node.

Maintain the list of exempt IP addresses

To maintain the list of exempt IP addresses, you can either use the [--ip=<ip list>] option in the preceding commands or you can use the following:

Magicento

<ip address> .. <ip address> is an optional space-delimited list of IP addresses to exempt.

--none clears the list.

Multi-store setups

If you want to set up multiple stores, each with a different layout and localized content, pass the $_GET['skin'] parameter to the intended processor.In the following example, we are using a 503 type error template file, which requires localized content.

The constructor of the Error_Processor class accepts a skin GET parameter to change the layout:

This can also be added to a rewrite rule in the .htaccess file that will append a skin parameter to the URL.

$_GET[‘skin’] parameter

To use the skin parameter:

  1. Check if the .maintenance.flag exists.
  2. Note the host address, that refers to the HTTP_HOST, or any other variable such as ENV variables.
  3. Check if the skin parameter exists.
  4. Set the parameter by using the rewrite rules below.

    Here are some examples of rewrite rules:

    • RewriteCond %{DOCUMENT_ROOT}/var/.maintenance.flag -f
    • RewriteCond %{HTTP_HOST} ^sub.example.com$
    • RewriteCond %{QUERY_STRING} !(^|&)skin=sub(&|$) [NC]
    • RewriteRule ^ %{REQUEST_URI}?skin=sub [L]
  5. Copy the following files:

    • pub/errors/default/503.phtml to pub/errors/sub/503.phtml
    • pub/errors/default/css/styles.css to pub/errors/sub/styles.css
  6. Edit these files to provide localized content in the 503.phtml file and custom styling in the styles.css file.

    Ensure your paths point to your errors directory. The directory name must match the URL parameter indicated in the RewriteRule. In the previous example, the sub directory is used, which is specified as a parameter in the RewriteRule (skin=sub)

The nginx setting must be added for multi-store setups.

We don’t normally do list posts at C3, but there are so many utilities that we find indispensable as developers that we ended up with a whole goody-bag full. Enjoy! And let us know in the comments if there are ones that you couldn’t live without but we’ve missed.

In no particular order:

1. n98-magerun for M1 / M2

I lied. This is first for a reason. Command line tools for Magento 1 and Magento 2: “The swiss army knife for Magento developers, sysadmins and devops.” It was such a brilliant tool for Magento 1 that Magento incorporated something similar into Magento 2 (though n98-magerun2 still adds more functionality so it’s worth grabbing!)

2. C3 Environment Banner for M1 / M2

The number of times live sites would have been accidentally changed is too many to count admit to. This extension adds coloured banners to the frontend and the admin panel to let you know visually if you are on a development, staging, preview or production site. It is guaranteed not to display anything on the frontend for production (or if it does not find a named environment). It picks up the current environment from the server variable “APPLICATION_ENV”. There are versions for Magento 1 and Magento 2.

3. Mage Security Patcher

In fact, the Mage Security Council have a number of super-useful tools that aid with maintaining the security of Magento, but we’ve picked this one in particular as it saves so much time when applying patches. And particularly in Magento 1 you need to apply patches regularly. The great thing about this tool is that it is rather more intelligent than a straight diff patch – it will also update template files in custom themes where it can.

Magicento

4. Scope hints for M1 / M2

Visual reminder if there is any specialisation of system config, product or category data. For example, if you are looking the web settings in system config at the default scope and there are specialised values to give different websites their own domain, those settings will be highlighted for you in the default scope so that you know that there is more detail to drill down to. I know! Good, isn’t it?

Magento 2

5. Magicento

PHPStorm plugin for Magento developers. If you use PHPStorm (that would probably be hint 5b – PHPStorm is pretty great too), this invaluable plugin for both Magento 1 and 2 (sadly, you have to purchase one for each) adds understanding for factories, template paths etc. that PHPStorm by itself would not be able to follow or autocomplete. It does much more than this, but that’s a pretty good start.

Magicento Activate

That’s our list! We’d love to hear from you what your top Magento tool would be.