- Magento 2 Developer's Guide
- Branko Ajzele
- 202字
- 2021-07-30 09:53:23
The var directory
Magento does a lot of caching and autogeneration of certain class types. These caches and generated classes are all located in Magento's root var
directory. The usual contents of the var
directory is as follows:
cache composer_home generation log di view_preprocessed page_cache
During development, we will most likely need to periodically clear these so that our changes can kick in.
We can issue the console command as follows to clear individual directories:
rm -rf {Magento root dir}/var/generation/*
Alternatively, we can use the built-in bin/magento
console tool to trigger commands that will delete the proper directories for us, as follows:
bin/magento setup:upgrade
: This updates the Magento database schema and data. While doing this, it truncates thevar/di
andvar/generation
directories.bin/magento setup:di:compile
: This clears thevar/generation
directory. After doing this, it compiles the code in it again.bin/magento deploy:mode:set {mode}
: This changes the mode from the developer mode to the production mode and vice versa. While doing this, it truncates thevar/di
,var/generation
, andvar/view_preprocessed
directories.bin/magento cache:clean {type}
: This cleans thevar/cache
andvar/page_cache
directories.
It is important to keep the var
directory in mind at all times during development. Otherwise, the code might encounter exceptions and function improperly.
推薦閱讀
- Facebook Application Development with Graph API Cookbook
- Moodle Administration Essentials
- Python從小白到大牛
- Visual Basic程序開(kāi)發(fā)(學(xué)習(xí)筆記)
- Vue.js快速入門與深入實(shí)戰(zhàn)
- Vue.js 3.x從入門到精通(視頻教學(xué)版)
- DevOps入門與實(shí)踐
- 微服務(wù)設(shè)計(jì)原理與架構(gòu)
- jQuery從入門到精通 (軟件開(kāi)發(fā)視頻大講堂)
- 微信公眾平臺(tái)開(kāi)發(fā):從零基礎(chǔ)到ThinkPHP5高性能框架實(shí)踐
- QGIS By Example
- Android傳感器開(kāi)發(fā)與智能設(shè)備案例實(shí)戰(zhàn)
- 邊玩邊學(xué)Scratch3.0少兒趣味編程
- Android高級(jí)開(kāi)發(fā)實(shí)戰(zhàn):UI、NDK與安全
- 菜鳥成長(zhǎng)之路