Recent Posts


N98-magerun: Development Toggle Commands


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

This article is part of a longer series covering the n98-magerun power tool

Today we’re going to start in the on the n98-magerun commands under the dev category.

$ n98-magerun.phar list dev
dev:console                    Opens PHP interactive shell with initialized Mage::app() (Experimental)
dev:ide:phpstorm:meta          Generates meta data file for PhpStorm auto completion
dev:log                        Toggle development log (system.log, exception.log)
dev:log:db                     Turn on/off database query logging
dev:log:size                   Get size of log file
dev:module:create              Creates and registers new magento module.
dev:module:list                List all installed modules
dev:module:observer:list       Lists all registered observers
dev:module:rewrite:conflicts   Lists all magento rewrite conflicts
dev:module:rewrite:list        Lists all magento rewrites
dev:profiler                   Toggles profiler for debugging
dev:report:count               Get count of report files
dev:symlinks                   Toggle allow symlinks setting
dev:template-hints             Toggles template hints
dev:template-hints-blocks      Toggles template hints block names
dev:theme:duplicates           Find duplicate files in your theme
dev:theme:list                 Lists all available themes
dev:translate:admin            Toggle inline translation tool for admin
dev:translate:shop             Toggle inline translation tool for shop

Given the length of this list, we won’t get to all the commands in this article. Today we’re going to focus on the toggle commands. The toggle commands will flip specific Magento system configuration variables on or off. Because of this, in addition to covering how the n98-magerun commands work, we’ll also end up teaching you a little about development related system configuration settings.

Let’s get to it!

The dev:log command will flip Magento’s logging on/off. This is the logging you’d normally turn on/off in the System -> Configuration -> Developer -> Log Settings section of the admin console. Magento is littered with calls to Mage::log which, if logging is on, will write debugging output to var/log/system.log. Additionally, there are certain exceptions in Magento which will be caught by the main application loop and written out to var/log/exception.log.

The syntax for the command is as follows.

$ n98-magerun.phar dev:log
[1] default - English
[2] french - French
[3] german - German
[4] second_store_view - Second Store View
Please select a store: 1
Development Log disabled for store default

Without arguments, the dev:log command will ask you for a store view, and then toggle logging on or off. If it’s currently on, it will toggle off. If its currently off, it will toggle on. If you want to set the logging value for the default configuration scope, just use the --global option.

$ n98-magerun.phar dev:log --global
Development Log enabled

You can also force an on/off state with the --on or --off options.

$ n98-magerun.phar dev:log --on 2
Development Log enabled for store german

$ n98-magerun.phar dev:log --on 2
Development Log enabled for store german

You’ll also notice in the above commands that we’re passing in the store_id directly. Like most n98-magerun store arguments, you may substitute the store code here as well

$ n98-magerun.phar dev:log --on german

The --on, --off, --global, and store parameters are, unless otherwise noted, shared by all the toggle commands. From this point on we’ll refer to them as the “standard toggle options”

The next toggle is the dev:profiler command. This toggles the settings at System -> Configuration -> Developer -> Debug. If you comment out the #Varien_Profiler::enable(); line in index.php, Magento will profile the time it takes for certain operations to complete. When this option is toggled to on, this information will be output at the bottom of the HTML page.

The syntax for the command is as follows, and supports the standard toggle options mentioned above.

$ n98-magerun.phar dev:profiler --on 3
Profiler enabled for store french

Next up is the dev:symlinks command. This toggles the settings at System -> Configuration -> Developer -> Template Settings. The command name symlinks is slightly misleading. With this feature on, programmers can write code or configure their setup to load templates outside the app/design folder hierarchy. While not recommended for production sites, this command was introduced specifically for developers who setup their development and staging environments using symlinks.

The syntax for the command is as follows, and supports the standard toggle options mentioned above.

$ n98-magerun.phar dev:symlinks --on 3
Symlinks allowed for store french

Next up are dev:template-hints and dev:template-hints-blocks. These commands toggle the options at System -> Configuration -> Developer -> Debug, (these options do not show up for the default store view). Template path and blocks hints will add a short string to the frontend of Magento indicating which part of the page was rendered by which phtml template.

The syntax for these commands are as follows, and both support the standard toggle options mentioned above except for the --global option.

$ n98-magerun.phar dev:template-hints --on 3
Template Hints enabled for store french

$ n98-magerun.phar dev:template-hints-blocks --on 3
Template Hints Blocks enabled for store french

The --global option is omitted in deference to Magento’s preference these settings not be displayed in the UI for the default store view.

Finally, we have the dev:translate:admin and dev:translate:shop commands. These commands toggle the inline translation feature in Magento. The inline translation features adds a clickable bounding box to each translatable string in Magento. Clicking this box allows end-users to enter an alternate translation for the string. These translations are stored in the database, and merged with the standard gettext style locale CSV files. These toggles are normally managed via the System -> Configuration -> Developer -> Translate Inline section of the system configuration.

The syntax for these commands is as follows, with the admin command toggling the feature in the admin console application, and the shop command toggling the features in the frontend application.

$ n98-magerun.phar dev:translate:shop --off 1
Inline Translation disabled for store default
$ n98-magerun.phar dev:translate:admin --off 
Inline Translation (Admin) disabled

Both commands support the --on and --off options. Neither supports the --global option, and only dev:translate:shop supports the store argument, (as the admin store_id should always be zero)

That’s it for today. Next time we’ll get to the non-toggle command under the dev category.

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 22nd April 2013

email hidden; JavaScript is required