E:\xampp\htdocs\magento-2>php -dmemory_limit=5G bin/magento
setup:di:compile The directory
"E:/xampp/htdocs/magento-2/var/generation/Magento/Framework" canno t
be deleted
Warning!rmdir(E:/xampp/htdocs/magento-2/var/generation/Magento/Fram
ework): Directory not empty#0
E:\xampp\htdocs\magento-2\vendor\magento\framework
\Filesystem\Driver\File.php(403):
Magento\Framework\Filesystem\Driver\File->dele
teDirectory('E:/xampp/htdocs…')
- E:\xampp\htdocs\magento-2\vendor\magento\framework\Filesystem\Driver\File.php
(403):
Magento\Framework\Filesystem\Driver\File->deleteDirectory('E:/xampp/htdoc
s…') - E:\xampp\htdocs\magento-2\setup\src\Magento\Setup\Console\CompilerPreparation
.php(68):
Magento\Framework\Filesystem\Driver\File->deleteDirectory('E:/xampp/ht
docs…') - E:\xampp\htdocs\magento-2\vendor\magento\framework\Console\Cli.php(74):
Magen
to\Setup\Console\CompilerPreparation->handleCompilerEnvironment() - E:\xampp\htdocs\magento-2\bin\magento(22):
Magento\Framework\Console\Cli->__c onstruct('Magento CLI') - {main} PHP Fatal error: Class 'Cli' not found in
E:\xampp\htdocs\magento-2\bin\magento on line 31
Fatal error: Class 'Cli' not found in
E:\xampp\htdocs\magento-2\bin\magento on l ine 31
Best Answer
Removed your var/generation directory and var/cache directory.
Then try to run below commands in sequence.
php bin/magento setup:di:compile
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush