In this article, we will discuss how to install Magento using Composer. But before diving into that, we need to learn about Composer, a dependency management tool for PHP, which is widely used in Frameworks and CMS like Laravel, Magento, and Drupal. By using Composer, we can easily manage third-party libraries and dependencies in our projects, such as sending emails or creating PDFs, without having to write them ourselves. This way, we can focus on creating our code, making it much more manageable.
Installing Composer is easy, and we have a separate video for that. Composer’s dependencies are fetched from packages.org, and if you want to check them out, we recommend you to visit the website.
Now let’s move onto installing Magento using Composer. We have listed two commands that we need to run in order to do this successfully. The first command will create a new project from Magento’s repository, using the Community Edition of Magento, and create a separate folder named “Magento CE.”
To run this command, we need to go to our terminal and navigate to the folder where we want to install Magento. We are using a XAMPP stack here, and we will create our project inside this folder. Once we’ve pasted the command and hit enter, the project creation process will begin. Magento will ask for some access details, which we can save in the Composer’s auth file, so we don’t have to enter them again later.
After the installation is complete, we can find the Magento CE folder inside the folder we created. If we navigate to this folder in our browser, we will see the setup wizard, which will guide us through the installation process.
The reason why using Composer to install Magento is important is that it creates a file called composer.json. This file contains the version of Magento we are using and the dependencies required for it. If a new update is released, we can simply update our Magento version in the composer.json file, and Composer will automatically load the required dependencies based on the Community Edition.
To update our code, we simply need to push the composer.json file onto a version control system, and when someone else pulls our code, they only need to fetch the composer.json file and run the “composer install” command to download the required dependencies.
In summary, using Composer to manage dependencies in our PHP projects, like Magento, makes our code much more manageable, and it is an essential tool for PHP developers.