有用的 Magento 2 CLI 命令

redmaomail 2024-07-24 18:31 阅读数 73 #Magento

红帽云邮外贸主机

有用的 Magento 2 CLI 命令

部署模式功能:

php bin/magento deploy:mode:show
php bin/magento deploy:mode:set developer ( default | production | developer )
php bin/magento deploy:mode:set production --skip-compilation

php bin/magento maintenance:disable
php bin/magento maintenance:enable
php bin/magento maintenance:enable --ip=192.0.0.1 --ip=192.0.0.2 (for all clients except this IPs)
php bin/magento maintenance:enable --ip=none (to clear the list of IPs)

用于开发的 CSS 和 JS 配置

php bin/magento config:set dev/js/enable_js_bundling 0
php bin/magento config:set dev/js/merge_files 0
php bin/magento config:set dev/js/minify_files 0
php bin/magento config:set dev/css/merge_css_files 0
php bin/magento config:set dev/css/minify_files 0
php bin/magento config:set dev/static/sign 0

php bin/magento config:set --scope="stores" --scope-code="default" dev/js/minify_files 0

缓存操作:

php bin/magento cache:status
php bin/magento c:f ( cache:flush }
php bin/magento c:c ( cache:clean }
php bin/magento cache:disable full_page layout block_html translate

默认缓存类型:

 config
 layout
 block_html
 collections
 reflection
 db_ddl
 compiled_config
 eav
 customer_notification
 config_integration
 config_integration_api
 full_page
 config_webservice
 translate
 vertex

模块操作(检查当前状态/禁用模块/启用模块):

php bin/magento module:status
php bin/magento module:disable VENDOR_MODULENAME
php bin/magento module:enable VENDOR_MODULENAME
php bin/magento module:uninstall VENDOR_MODULENAME (if installed by Composer)

设置升级/设置编译/静态内容部署:

php -d memory_limit=2048M bin/magento setup:upgrade
php -d memory_limit=2048M bin/magento setup:di:compile
php -d memory_limit=2048M bin/magento setup:static-content:deploy
php bin/magento setup:static-content:deploy pl_PL -f
php bin/magento setup:static-content:deploy pl_PL --theme Vendor/theme --no-html-minify -f
php bin/magento setup:static-content:deploy pl_PL en_US en_GB --jobs 20

设置配置:

php bin/magento setup:store-config:set --base-url="http://project.dev/"
php bin/magento setup:store-config:set --base-url-secure="https://project.dev/"

php bin/magento config:set admin/security/session_lifetime 604800 ( 86400 = 1 day / 604800 = 7 days / 31536000 = 1 year / etc )
php bin/magento config:set admin/security/password_is_forced 0

索引器(重新索引|重置):

php bin/magento indexer:reset
php -d memory_limit=2048M bin/magento indexer:reindex

php bin/magento indexer:status
php bin/magento indexer:reset cataloginventory_stock
php bin/magento indexer:reindex cataloginventory_stock

为特定模块生成翻译包

php bin/magento i18n:collect-phrases -o app/code/Module/Vendor/i18n/pl_PL.csv app/code/Module/Vendor/
php bin/magento i18n:collect-phrases --output="app/design/frontend//Module/Vendor/i18n/pl_PL.csv" --magento (This option adds themes or modules to each line in the dictionary.)

目录图像调整大小:

php bin/magento catalog:image:resize

对于管理员

php bin/magento admin:user:create
php bin/magento info:adminuri
php bin/magento admin:user:unlock USERNAME

获取所有可用命令的列表

php bin/magento list
php bin/magento help

红帽云邮外贸主机

分享到:
版权声明:本站内容源自互联网,如有内容侵犯了你的权益,请联系删除相关内容。
    红帽云邮外贸主机
热门
    红帽云邮外贸主机
    红帽云邮外贸主机