You can easily flush the cache storage of Magento 2 from the command line. Note that the following script must be executed from the Magento 2 root folder:
It deletes all content from the var subfolder excluding the.htaccess file and the var/session subfolder. Besides, the script also deletes all content from the pub/static subfolder excluding the.htaccess file.
In Magento 1, for instance, this code was more simple:
PHP
1
Mage::log('message');
but you can also utilize another approach in case of Magento 2. Since there is a _logger property related to many objects, you can perform the same task by calling inside such objects. Just use the following code:
PHP
1
$this->_logger->debug('message');
Please note that not every object has the _logger property. Thus, this method will not work with all your objects.
Removeinstruction is available in Magento 2. Please note that the layout merges in order shown in a module.xml/sequence section. Here is the instruction:
Right in refresh .less files, since it “collects, processes and publishes source LESS files”:
PHP
1
php bin/magento dev:css:deploy
You can also use dev mode during development. According to documentation “Static view files are not cached; they are written to the Magento pub/static directory every time they’re called.”
In a case of a controller that extends Magento\Framework\App\Action\Action, it is possible to get the request with the aid of $this->getRequest()->getPost().
For a custom class, inject the request in the constructor:
PHP
1
<?phpnamespaceNamespace\Module\Something;classClassName{protected$request;publicfunction__construct(\Magento\Framework\App\Request\Http$request,....//rest of parameters here ) { $this->request = $request; ...//rest of constructor here } public function getPost() { return $this->request->getPost(); } }