As we all know that Magento is not compatible with Windows. So when we install Magento 2 on Windows, we have to go through many flaws.
Sometimes Magento installation stops in the middle after completion of some percent, so let's know how to solve this problem.
Installation at 51% Module 'Magento_Theme' Error in Magento 2
If you are installing Magento 2 in xampp server then you will see that you will see an error like this.
Module 'Magento_Theme':
[ERROR] InvalidArgumentException: Wrong file in C:\xampp\htdocs\m235s2\vendor\magento\framework\Image\Adapter\Gd2.php:64 Stack trace: #0
Step 1: Replace validateURLScheme() Method
The Magento community team has prepared Magento as Linux compatible and it has also been told on its official website that Magento does not support Windows, so the Magento community team does not consider it an error.
But when we use window for Magento then we have to solve these errors.
Vendor\Magento\Framework\Image\Adapter\Gd2.php
/** * Checks for invalid URL schema if it exists * * @param string $filename * @return bool */ private function validateURLScheme(string $filename) : bool { $allowed_schemes = ['ftp', 'ftps', 'http', 'https']; $url = parse_url($filename); if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes)) { return false; } return true; }
Now replace this method with the following method:
private function validateURLScheme(string $filename) : bool { $allowed_schemes = ['ftp', 'ftps', 'http', 'https']; $url = parse_url($filename); if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) { return false; } return true; }
After this, your Magento 2 will be installed successfully but your Magento 2 website will not run properly.
While running your Magento 2.3 website after fresh installation you will get errors on the admin side something below like this.
Step 2: Install Magento 2 on Windows - 777 Permission
Now, you have to give the full permission in the Magento installation directory var folder then your site will show some errors.
Step 3: Invalid Template File - Require JS Errors Magento 2
Invalid template file in magento version from 2.2.6 to 2.3.5p2.
1 exception(s): Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'C:/xampp2/htdocs/magento2/vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml' in module: '' block's name: 'require.js'
Now we have to have to replace the code of the file.
vendor/magento/framework/view/element/template/file/validator.php
/** * Checks whether path related to the directory * * @param string $path * @param string|array $directories * @return bool */ protected function isPathInDirectories($path, $directories) { if (!is_array($directories)) { $directories = (array)$directories; } $realPath = $this->fileDriver->getRealPath($path); foreach ($directories as $directory) { if (0 === strpos($realPath, $directory)) { return true; } } return false; }
Replace With
protected function isPathInDirectories($path, $directories) { $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path)); if (!is_array($directories)) { $directories = (array)$directories; } foreach ($directories as $directory) { if (0 === strpos($realPath, $directory)) { return true; } } return false; }
Now, if you will see the screen something like below this then.
Step 4: Run Magento 2 Command - Install Magento 2
Now you have to run the below command:
php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f php bin/magento indexer:reindex
Correct File and Folder Permissions in Ubuntu for Magento 2
Now, Magento has been successfully installed on the windows using xammp server.
Other Post:
Mobile App Builder Free Extension in Magento 2
Shop By Brand: Magento 2 Shop By Brand Free Extension
Magento 2 Get Product Total, Subtotal, Coupon, Tax Details Via REST API