一旦安装了Magento2,您将需要配置一些选项,并根据您的特定需要管理系统生命周期。您可以使用命令行实用程序启动Magento配置和管理。
命令行能提供的功能如下所示(部分):
执行命令行的方式:
在magento的安装目录下,我们会看到了个bin目录,在bin目录下有一个magento文件
bin/
`-- magento
因此,我们执行magento命令行输入命令:
php bin/magento
输入上面这条命令,magento就会帮我们列出系统中所有可用的命令,如下示例:
admin
admin:user:create Creates an administrator
admin:user:unlock Unlock Admin Account
app
app:config:dump Create dump of application
app:config:import Import data from shared configuration files to appropriate data storage
app:config:status Checks if config propagation requires update
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
每条命令后面对应该命令的描述。
以下为一个更新系统缓存的完整命令:
php bin/magento cache:clean
通过上面的列表,我们就可以找到对应功能的命令,然后使用 php bin/magento command
来执行任何magento中可用的命令。
示例,查看当前缓存的状态:
root@8f4d6f886a05# php bin/magento cache:status
Current status:
config: 1
layout: 1
block_html: 1
collections: 1
reflection: 1
db_ddl: 1
compiled_config: 1
eav: 1
customer_notification: 1
config_integration: 1
config_integration_api: 1
full_page: 1
config_webservice: 1
translate: 1
vertex: 1
示例,使用php bin/magento indexer:reindex
命令刷新系统索引
为了提高magento的性能,magento会将一些如目录、分类等数据存到对应的索引表中,系统会优先从索引表中查询数据.当我们修改这些数据时,如果索引表中的数据没有更新,我们获取到的数据就不是最新的。
如果我们的系统配置了定时任务,这些索引数据会定时去刷新,如果我们想要立即执行,则可以手动去运行上面的命令,保证数据同步为最新的。
我们可以通过上面的图片了解到,magento系统有哪些模块的数据使用到了索引,如: