After firing this command in CLI php bin/magento setup:upgrade
I am getting below error -:
Fatal error: Uncaught exception 'Magento\Framework\Exception\LocalizedException' with message 'Can't create directory
/var/www/html/magento/magento2.0/var/generation/Magento/Framework/App/ResourceConnection/.' in
/var/www/html/magento/magento2.0/vendor/magento/framework/Code/Generator.php:103
Stack trace:
#0 /var/www/html/magento/magento2.0/vendor/magento/framework/Code/Generator/Autoloader.php(35): Magento\Framework\Code\Generator->generateClass('Magento\\Framewo...')
#1 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\\Framewo...') #2 [internal function]: spl_autoload_call('Magento\\Framewo...')
#3 /var/www/html/magento/magento2.0/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('Magento\\Framewo...')
#4 /var/www/html/magento/magento2.0/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor('Magento\\Framewo...')
#5 /var/www/html/magento/magento2.0/vendor/magento/framework/ObjectMana in /var/www/html/magento/magento2.0/vendor/magento/framework/Code/Generator.php on line 103`
Best Answer
I have solved this problem by just simply doing this steps. follow steps :
var
directory (for2.0
and2.1
)Run this command and go to your project root folder command:
If your Magento mode is developer then you don't need to run below commands just remove
var/generation
directory(2.0 & 2.1) orgenerated
folder(2.2 onwards)Then run this command
Then run this command (required in production mode only)
Finally, give file/directory permissions.(If needed)