Install Magento2 using Composer
Let's discuss the installation of Magento 2.3.4 using Composer on windows operating system. We are installing the newest version of Composer, before installing the Composer, XAMPP must be installed on your system. Otherwise, we will not be able to use the Composer. And for the Xampp installation, see the Magento 2 XAMPP Installation tutorial from the index.
Pre-requisites
- PHP - PHP (Latest as per the records)
- Web Server - XAMPP
- Operating System – windows, Mac OS, Linux
- Secure Socket Layer - A valid security certificate for HTTPS
- Brower - Google Chrome, Firefox or Internet Explorer, etc.
1- Download the Composer 1.9.2 from site https://getcomposer.org/download/.
Download Composer-Setup.exe to download the Composer for windows, as shown below-
2: Now, run the downloaded file. For reference, you can see the image below.
3: If you want hardcore development, then check the developer option present in the window, otherwise leave the Developer mode uncheck and press next.
5: Choose the path you want to install the Composer, or you can use the default path. Click Next to Continue.
NOTE- Before installing the Composer, your system must have been established with the PHP.
6: Click on Next to Continue. No need to make any change.
7: The next window will show the PHP version and path, where the Composer is going to be installed. Cross-check it, and if you found any mistake, you can go back and amend it.
Click on Next and move ahead.
8: Read the following information and click on the Next button to Continue.
9- Once the installation is completed, click on the Finish button.
10: Now Open the Command Prompt and write the command "composer" and press enter. If your screen shows the result the same as below,
Hurray, you have successfully installed the Composer.
Now, we will install the latest version of Magento available, i.e., Magento 2.3.2.
11: Now Download the Magento from the given link https://magento.com/tech-resources/download.
Click on the “Select your format” option to select the option from a drop-down list. 12: Here, select the ".zip” format of Magento and click on the “Download “button.
13: Your Magento will start downloading, but before that, you must log in to its portal, or if you are not a part, then you must create an account and then login.
14: For creating a new account, Enter your details and generate the password.
And click on the Create Account Button.
15: Your account has been created. Now you can log in, and it will automatically start downloading.
16: You must create a new folder by the name magento2, as shown in the image below in the given location, i.e., xampp -> htdocs.
17: Now, extract the downloaded file in the same folder that you have made earlier.
18: Open the command prompt, Firstly change directory to C:\xampp\htdocs\magento2, the same place where you have extracted the Magento, and then run the command” Composer install” on command prompt. As shown in the image below,
19: Now run command php bin/Magento setup: install on command prompt. It will show an error that intl, xsl, and soap extensions are missing.
20: To remove this extension missing error, you have to open php.ini file in sublime text inside the xampp -> apache -> config -> PHP (php.ini).
21: Find-
;extension
= soap;extension
= xsl;extension
= intl
in php.ini file and delete the semicolon that are placed before the extension word.
Save the file.
22: Now, again, execute php bin/Magento setup: install on the command prompt. Now it will show another error that the database with magento2 name does not exist. Now, you have to create a database by the name magento2 in phpMyAdmin to remove this error.
- Type localhost/phpmyadmin/ in the browser’s address bar and press enter.
- "phpMyAdmin" will be opened. Click on the new, and enter the database name as magento2 and click on Create button.
23: Now run the given below command on the command prompt, by changing it as per your Magento and database configuration.
Now you can see the installation of Magento is started in your system
24: After the installation is completed. Note down the Admin URL from here, as shown below.
25: Magento 2 is successfully installed. Now open the web browser and type Magento Admin URL - localhost/magento2/admin_1d5nq1 Store address - localhost/magento2/ in another tab.
Magento Admin Panel
If the admin panel does not open and the Magento admin address URL displays a blank screen on the window, follow the instructions below.
- Go inside the xampp>htdocs>magento2>vendor>magento>framework>View>Element>Template>File>Validator.php
- Open the file Validator.php.
- Find this code inside the Validator.php file, and replace it with the given code
protected function isPathInDirectories($path, $directories) { if (!is_array($directories)) { $directories = (array)$directories; } foreach ($directories as $directory) { if (0 === strpos($this->fileDriver->getRealPath($path), $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; }
Save the validator file and reload the Admin page. The admin panel will now be displayed.
Luma theme
The front end interface of Magento is missing the Luma logo using the store address. The error page will display the below-shown screenshot.
Follow the steps to fix the error.
- Open di.xml file inside xampp>htdocs>magento2>app>etc>di.xml
- Search for the word "Symlink" inside the di.xml file, as shown in the image.
- Now replace the code below.
- Replace it with this code.
- Now save the file.
- Reload the home page. You can see the page reloads properly, and the error is fixed.