To compile the code in magento2, we use setup:di:compile command which performs the following tasks :
- Application code generation – for factories, proxies
- Interceptor generation – improve code generation of interceptors
- Interception cache generation – improve cache generation of interceptors
- Area configuration aggregation – improve dependency injection configurations per area
- Repositories code generation – create code for APIs
- Service data attributes generation – create extension classes for data objects
Switch to the magento root folder (it is generally public_html) and run the above command -
The above command will show the output as below.
Compilation was started.
Plugin list generation... 9/9 [============================] 100% 46 secs 428.0 MiB
Generated code and dependency injection configuration successfully
The deployment commands of static view files enable us to write static
files to the Magento 2 file system. These static view files are located in Magento’s static directory (your
Magento2 install dir/pub/static) and some files are cached in your
Magento 2 install dir/var/view_preprocessed directory.
For deployment of static view files, follow these steps:
- Log in to your Magento 2 server as, or switch to, the Magento 2 file system owner.
- Delete the content under <your Magento install dir>/pub/static.
- Run the static view files deployment tool <your Magento install dir>/bin/magento setup:static-content:deploy.
Use the following commands to deploy static view files :
- cd pub/static && find . -depth -name .htaccess -prune -o -delete && cd ../..
- rm -rf var/cache/* var/view_preprocessed/* generated/* pub/static/* var/page_cache/* var/composer_home/*
- php bin/magento setup:static-content:deploy -f
- chmod -R 777 pub/static
Flush the magento cache using the above commands to make the site load fresh content -
- bin/magento cache:clean
- bin/magento cache:flush
How to configure base URLs for a Magento 1 website?
In this article, we are going to change the base URLs of a Magento 1 website, using the swiss army knife for Magento developers, sysadmins and devops i.e. n98-magerun. Base URLs can be also changed from the Magento Site backend as well as from the ...
How to configure base URLs for a Magento 2 website?
In this article, we are going to change the base URLs of a Magento 2 website, using the swiss army knife for Magento developers, sysadmins and devops i.e. n98-magerun2. Base URLs can be also changed from the Magento Site backend as well as from the ...
Switching modes in magento2
An overview To improve security and ease-of-use, magento has built-in commands that switches magento modes from developer to production and vice versa. Production mode also has better performance because static view files are populated in the ...
Magento Customer login does not work in Chrome browser
Problem description Customers can not log in into Magento with Chrome browser, the login page just reloads without any errors or warnings. But when customer logins in other browsers and admin back-end login function properly. Cause Magento sets an ...
How to flush nginx pagespeed cache on a Ubuntu server?
What is nginx pagespeed? It is actually a third party dynamic module for nginx, which can be compiled into nginx server. It is provided by Google PageSpeed, a suite of tools for measuring and optimizing the performance of your website. Flushing ...