The n98 magerun cli tools provides some handy tools to work with Magento from command line.
The tools are currently only tested with PHP 5.3.10 within Ubuntu 12.04 Linux and on Mac OS X. If you are a Windows user you can help us with a quick test.
The tools should work with Magento 2 development branch.
There are two ways to install the tools:
wget https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar
You can make the .phar file executable.
chmod +x ./n98-magerun.phar
If you want to use command system wide you can copy it to /usr/local/bin.
sudo cp ./n98-magerun.phar /usr/local/bin/
Debian / suhosin:
On some debian systems with compiled in suhosin the phar extension must be added to a whitelist.
Add this to your php.ini file:
suhosin.executor.include.whitelist="phar"
Clone git repository:
git clone https://github.com/netz98/n98-magerun
Download composer:
curl -s https://getcomposer.org/installer | php
Let composer do all the work for you:
php ./composer.phar install
- or
- php ./composer.phar create-project n98/magerun <folder>
Run cli.php:
php vendor/bin/n98-magerun
It's recommended to install the .phar file system wide.
Since version 1.1.0 we deliver a self-update script within the phar file:
n98-magerun.phar self-update
If file was installed system wide do not forget "sudo".
All commands try to detect the current Magento root directory. If you have multiple Magento installation you must change your working directory to the preferred installation.
https://github.com/netz98/n98-magerun/wiki/Commands
You can list all available commands by:
n98-magerun.phar list
If you don't have installed the .phar file system wide you can call it with the php cli interpreter:
php n98-magerun.phar list
n98-magerun.phar database:info
Direct dump with mysqldump:
n98-magerun.phar database:dump
Only the mysqldump command:
n98-magerun.phar database:dump --only-command [filename]
Opens the MySQL console client with your database settings from local.xml
- Requires MySQL CLI tools
n98-magerun.phar database:console
n98-magerun.phar index:list
Index by indexer code. Code is optional. If you don't specify a code you can pick a indexer from a list.
n98-magerun.phar index:reindex [code]
Loops all magento indexes and triggers reindex.
n98-magerun.phar index:reindex:all
n98-magerun.phar local-config:generate
n98-magerun.phar config:dump > extern_file.xml
n98-magerun.phar cache:list
Cleans expired cache entries. If you like to remove all entries use cache:flush
n98-magerun.phar cache:clean
Or only one cache type like i.e. full_page cache:
n98-magerun.phar cache:clean full_page
n98-magerun.phar cache:flush
n98-magerun.phar cache:list
n98-magerun.phar cache:disable
n98-magerun.phar cache:enable
Toggle demo store notice
n98-magerun.phar design:demo-notice [store_code]
n98-magerun.phar admin:user:list
n98-magerun.phar admin:user:create [username] [email] [password] [firstname] [lastname]
n98-magerun.phar admin:user:change-password [username] [password]
Toggle admin notifications.
n98-magerun.phar admin:notifications
n98-magerun.phar sys:maintenance
Provides info like the edition and version or the configured cache backends.
n98-magerun.phar sys:info
Lists all store views.
n98-magerun.phar sys:store:list
Lists all websites.
n98-magerun.phar sys:website:list
Lists all cronjobs defined in config.xml files.
n98-magerun.phar sys:cron:list
Runs all setup scripts (no need to call frontend). This command is useful if you update your system with enabled maintenance mode.
n98-magerun.phar sys:setup:run
Compares module version with saved setup version in core_resource table and displays version mismatch.
n98-magerun.phar sys:setup:compare-versions [--ignore-data]
- Checks missing files and folders
- Security
- PHP Extensions (Required and Bytecode Cache)
- MySQL InnoDB Engine
n98-magerun.phar sys:check
Hide/Show CMS Banners
n98-magerun.phar cms:banner:toggle <banner_id>
Publishes a page by page id and revision.
n98-magerun.phar cms:page:publish <page_id> <revision_id>
Useful to automatically publish a page by a cron job.
Toggle debug template hints settings of a store
n98-magerun.phar dev:template-hints [store_code]
Toggle debug template hints blocks settings of a store
n98-magerun.phar dev:template-hints-blocks [store_code]
Toggle settings for shop frontend:
n98-magerun.phar dev:translate:shop [store_code]
Toggle for admin area:
n98-magerun.phar dev:translate:admin
Toggle profiler for debugging a store:
n98-magerun.phar dev:profiler [store_code]
Activate/Deactivate system.log and exception.log for a store:
n98-magerun.phar dev:log [store_code]
Allow usage of symlinks for a store-view:
n98-magerun.phar dev:symlinks <store_code>
Global scope can be set by not permitting store_code parameter:
n98-magerun.phar dev:symlinks
Creates an empty module and registers it in current magento shop:
n98-magerun.phar dev:module:create [--add-blocks] [--add-helpers] [--add-models] [--add-all] [--modman] vendorNamespace moduleName [codePool]
Code-Pool defaults to local.
Example:
n98-magerun.phar dev:module:create MyVendor MyModule
- --modman option creates a new folder based on vendorNamespace and moduleName argument.
Run this command inside your .modman folder.
- --add-all option add blocks, helpers and models.
Lists all installed modules with codepool and version
n98-magerun.phar dev:module:list
Lists all registered class rewrites:
n98-magerun.phar dev:module:rewrite:list
Lists all duplicated rewrites and tells you which class is loaded by Magento. The command checks class inheritance in order of your module dependencies.
n98-magerun.phar dev:module:rewrite:conflicts [--log-junit="..."]
- If a filename with --log-junit option is set the tool generates an XML file and no output to stdout.
Lists all registered observer by type.
n98-magerun.phar dev:module:observer:list [type]
Type is one of "adminhtml", "global", "frontend".
List and find connect extensions by a optional search string:
n98-magerun.phar extension:list <search>
- Requires Magento's mage shell script.
- Does not work with Windows as operating system.
Installs a connect extension by package key:
n98-magerun.phar extension:install <package_key>
If the package could not be found a search for alternatives will be done. If alternatives could be found you can select the package to install.
- Requires Magento's mage shell script.
- Does not work with Windows as operating system.
Downloads connect extensions by package key:
n98-magerun.phar extension:download <search>
- Requires Magento's mage shell script.
- Does not work with Windows as operating system.
Upgrade connect extensions by package key:
n98-magerun.phar extension:upgrade <search>
- Requires Magento's mage shell script.
- Does not work with Windows as operating system.
Since version 1.1.0 we deliver a Magento installer which does the following:
- Download Magento by a list of git repos and zip files (mageplus, magelte, official community packages).
- Try to create database if it does not exist.
- Installs Magento sample data if available (since version 1.2.0).
- Starts Magento installer
- Sets rewrite base in .htaccess file
n98-magerun.phar install
Copy the file bash_complete as n98-magerun.phar in your bash autocomplete folder. In my Ubuntu system this can be done with the following command:
sudo cp bash_complete /etc/bash_completion.d/n98-magerun.phar
https://github.com/netz98/n98-magerun/wiki/Add-custom-commands
Create the yaml config file ~/.n98-magerun.yaml. Now you can define overwrites. The original config file is config.yaml in the source root folder.
Change of i.e. default currency and admin users:
commands:
N98\Magento\Command\Installer\InstallCommand:
installation:
defaults:
currency: USD
admin_username: myadmin
admin_firstname: Firstname
admin_lastname: Lastname
admin_password: mydefaultSecret
admin_email: defaultemail@example.com
Create the yaml config file ~/.n98-magerun.yaml. Now you can define overwrites. The original config file is config.yaml in the source root folder.
Add you repo. The keys in the config file following the composer package structure.
Example:
commands: N98\Magento\Command\Installer\InstallCommand: magento-packages: - name: my-magento-git-repository version: 1.x.x.x source: url: git://myserver/myrepo.git type: git reference: 1.x.x.x extra: sample-data: sample-data-1.6.1.0 - name: my-zipped-magento version: 1.7.0.0 dist: url: http://www.myserver.example.com/magento-1.7.0.0.tar.gz type: tar extra: sample-data: sample-data-1.6.1.0
- Add new commands
- Send me some proposals if you miss anything
- Create issues if you find a bug or missing a feature.
- Symfony2 Team for the great console component.
- Composer Team for the downloader backend and the self-update command.
- sys:cron:list - List of cronjobs
- dev:event:list - List all magento events
- List more infos like Base URLs.
- Change BaseURL from CLI.