1.Magento 命令行工具
Magento2 带有一个命令行工具,在windows下,用管理员权限打开MS-DOS命令提示符,然后cd到Magento根目录,运行下面命令,就可
以看到这个强大的命令行工具的命令清单:
php bin/magento
Usage: command [options] [arguments] Options: --help (-h) Display this help message --quiet (-q) Do not output any message --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug --version (-V) Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output --no-interaction (-n) Do not ask any interactive question Available commands: help Displays help for a command list Lists commands
admin admin:user:create Creates an administrator admin:user:unlock Unlock Admin Account
cache cache:clean Cleans cache type(s) cache:disable Disables cache type(s) cache:enable Enables cache type(s) cache:flush Flushes cache storage used by cache type(s) cache:status Checks cache status
catalog catalog:images:resize Creates resized product images catalog:product:attributes:cleanup Removes unused product attributes.
cron cron:run Runs jobs by schedule
customer customer:hash:upgrade Upgrade customer's hash according to the latest algorithm
deploy deploy:mode:set Set application mode. deploy:mode:show Displays current application mode.
dev dev:source-theme:deploy Collects and publishes source files for theme. dev:tests:run Runs tests dev:urn-catalog:generate Generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml. dev:xml:convert Converts XML file using XSL style sheets
i18n i18n:collect-phrases Discovers phrases in the codebase i18n:pack Saves language package i18n:uninstall Uninstalls language packages
indexer indexer:info Shows allowed Indexers indexer:reindex Reindexes Data indexer:reset Resets indexer status to invalid indexer:set-mode Sets index mode type indexer:show-mode Shows Index Mode indexer:status Shows status of Indexer
info info:adminuri Displays the Magento Admin URI info:backups:list Prints list of available backup files info:currency:list Displays the list of available currencies info:dependencies:show-framework Shows number of dependencies on Magento framework info:dependencies:show-modules Shows number of dependencies between modules info:dependencies:show-modules-circular Shows number of circular dependencies between modules info:language:list Displays the list of available language locales info:timezone:list Displays the list of available timezones
maintenance maintenance:allow-ips Sets maintenance mode exempt IPs maintenance:disable Disables maintenance mode maintenance:enable Enables maintenance mode maintenance:status Displays maintenance mode status
module module:disable Disables specified modules module:enable Enables specified modules module:status Displays status of modules module:uninstall Uninstalls modules installed by composer
sampledata sampledata:deploy Deploy sample data modules sampledata:remove Remove all sample data packages from composer.json sampledata:reset Reset all sample data modules for re-installation
setup setup:backup Takes backup of Magento Application code base, media and database setup:config:set Creates or modifies the deployment configuration setup:cron:run Runs cron job scheduled for setup application setup:db-data:upgrade Installs and upgrades data in the DB setup:db-schema:upgrade Installs and upgrades the DB schema setup:db:status Checks if DB schema or data requires upgrade setup:di:compile Generates DI configuration and all missing classes that can be auto-generated setup:install Installs the Magento application setup:performance:generate-fixtures Generates fixtures setup:rollback Rolls back Magento Application codebase, media and database setup:static-content:deploy Deploys static view files setup:store-config:set Installs the store configuration setup:uninstall Uninstalls the Magento application setup:upgrade Upgrades the Magento application, DB data, and schema
theme theme:uninstall Uninstalls theme
2.Magento 2.0 如何激活一个新的插件?
新插件文件拷贝到Magento 2.0 目录后,用下面命令激活之:
php bin/magento setup:upgrade
Magento前台或者后台js,或者css似乎没有正确的调用,怎么办?
js和css没有正确调用的症状是页面无修饰,图标不显示,鼠标点击打开的下拉菜单无法打开等,这时可以先删除
pub/static 除了.htaccess 的所有文件或文件夹。然后运行:
php bin/magento setup:static-content:deploy
3.如何重新安装Magento 2.0?
在Magento CLI 运行:
php bin/magento setup:uninstall
或者删除 app/etc/env.php
, app/etc/config.php
, var/cache
, var/generation
。
5.magento的view里面的default.xml 设置更新所有页面都会更新,
如果只想更新helloworld index 页面的内容 直接在helloworld_index_index.xmlk里面更改即可
4.缓存命令行
检查缓存类型的状态
4.清理缓存类型
php bin/magento cache:clean
刷新缓存
php bin/magento cache:flush
检查启用,禁用缓存
php bin/magento cache:enable
php bin/magento cache:disable
高级命令:
magento cache:enable [type] … [type]
magento cache:disable [type] … [type]
禁用整页缓存
magento cache:disable full_page
5.检查索引器状态
php bin/magento indexer:info
6.如何重建数据
php bin/magento indexer:reindex
7.如何将索引器状态重置为无效
php bin/magento indexer:reset
8.如何显示索引模式
php bin/magento indexer:show-mode
9.如何设置索引模式类型
php bin/magento indexer:set-mode {realtime|schedule} [indexer]
例如:
magento indexer:set-mode schedule catalog_category_product catalog_product_category
部署命令行
10.如何运行部署静态内容
php bin/magento setup:static-content:deploy
php bin/magento setup:static-content:deploy -f
它将显示如下:
Requested languages: en_US
=== frontend -> Magento/blank -> en_US ===
…
默认情况下,它将运行部署默认语言的静态内容: en_EN
如果您想部署其他语言的静态内容,例如: pt_BR
运行
php bin/magento setup:static-content:deploy pt_BR
结果
Requested languages: pt_BR
=== frontend -> Magento/luma -> pt_BR ===
… progress indicator …
Successful: 1613 files; errors: 0=== frontend -> Magento/blank -> pt_BR ===
… progress indicator …
Successful: 1620 files; errors: 0=== adminhtml -> Magento/backend -> pt_BR ===
… progress indicator …
Successful: 1626 files; errors: 0
11.通过命令行启用维护模式
启用维护模式
php bin/magento maintenance:enable
结果:
php bin/magento maintenance:enable
Enabled maintenance mode
12.禁用维护模式
php bin/magento maintenance:disable
13.允许IP访问商店
设置维护模式仅允许ip
php bin/magento maintenance:allow-ips
例如:
php bin/magento maintenance:allow-ips 168.168.168.168
Set exempt IP-addresses: 168.168.168.168
如何设置Magento Developer模式或Product模式
显示当前的Magento 2模式
php bin/magento deploy:mode:show
结果如下:
Current application mode: default. (Note: Environment variables may override this value.)
14.我们处于默认模式,让我们切换到开发人员模式
php bin/magento deploy:mode:set developer
结果如下:
Enabled developer mode.
恭喜!现在您的商店正在开发人员模式下运行。