How to fix the «Can't create directory 'generated/code' in Magento/Framework/Code/Generator.php» Magento 2.2 issue?

How to fix

Grant the PHP interpreter the writable permissions to the generated folder:

chmod -R -v 777 generated