When I add and register a new Module I need to run
sudo rm -rf var/*
or else the page doesn't even load and just throws http error 500
Is it supposed to be like that?
@Damian Culotta wrote:Hi @erits,
Which steps did you followed to add the module?
Example:
1. Create a folder app/code/Training/Test
2. Create a file app/code/Training/Test/etc/module.xml
3. Register module with app/code/Training/Test/registration.php
4. Enable it with
php bin/magento --clear-static-content module:enable Training_Test
5. Run
bin/magento setup:upgrade
I made 2-3 modules and had to empty the /var/ directory inside Magento 2 installation or else any page didn't load. Just clearing and flushing cache didn't help. I think it happens after running this command, but I am not sure
bin/magento setup:upgrade
You can also run:
bin/magento cache:clean
Magento "compiles" and create the cached code. If you make modifications you'll need to refresh that cache in order to get the latest version running.
@Damian Culotta wrote:You can also run:
bin/magento cache:cleanMagento "compiles" and create the cached code. If you make modifications you'll need to refresh that cache in order to get the latest version running.
I just created another module and after running
sudo php bin/magento setup:upgrade
website didn't load any pages.
After that I ran
sudo bin/magento cache:clean sudo bin/magento cache:flush
and website did load, but I got this error
RuntimeException: Can't create directory /var/www/html/magento2/var/generation/Magento/Framework/App/Response/Http/. in /var/www/html/magento2/lib/internal/Magento/Framework/Code/Generator.php:115 Stack trace: #0 /var/www/html/magento2/lib/internal/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/magento2/lib/internal/Magento/Framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('Magento\\Framewo...') #4 /var/www/html/magento2/lib/internal/Magento/Framework/ObjectManager/Definition/Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor('Magento\\Framewo...') #5 /var/www/html/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php(71): Magento\Framework\ObjectManager\Definition\Runtime->getParameters('Magento\\Framewo...') #6 /var/www/html/magento2/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...') #7 /var/www/html/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php(126): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...') #8 /var/www/html/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'response', 'Magento\\Framewo...') #9 /var/www/html/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Framewo...', Array, Array) #10 /var/www/html/magento2/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...', Array) #11 /var/www/html/magento2/lib/internal/Magento/Framework/App/Bootstrap.php(233): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Framewo...', Array) #12 /var/www/html/magento2/pub/index.php(36): Magento\Framework\App\Bootstrap->createApplication('Magento\\Framewo...') #13 {main}
I could fix it by running this command
sudo rm -rf var/*