Install Laravel 7 on Windows with composer, by following the step by step guide provided in this article. But, before that let’s take a look about what is Laravel and why it’s good to be familiar with it, especially if you have an interest in the world of PHP.
What is Laravel?
Laravel is one of the most popular open-source PHP frameworks with an expressive and elegant syntax. This MVC based framework was founded by Taylor Otwell. Its powerful abstraction, built-in security features, and incredibly useful command-line interface allow us to build a more robust application by writing less code.
With this framework, your work of developing simple to complex web app should be easy as well as equally organized.Additionally, because of the well documented laravel website and a huge laravel community would make it easier to find article realated to any features that you may required or solution to the problem you may encountered during the development of the project.
Before getting started, its important to know the system requirements to install Laravel. For the current stable version, Laravel 7.0 your development server must fulfill the following requirements:
- PHP >= 7.2.5
- BCMath PHP Extension
- Ctype PHP Extension
- JSON PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
#1. Install XAMP server to your windows.
Besides XAMPP you can also install WAMP, MAMP or LAMP as well, however, most of them are platform-specific.
XAMPP stands for X – cross-platform, A – Apache Server, M – MySql, P – PHP, P – Perl. Similarly, W in WAMP refers to Windows, MAMP to Mac, and LAMP is for Linux.
However, in this article, we will be using XAMPP, but you can pick any other according to your operating system. Also, if your computer already possesses one of this server, then there are no points to set it up again.
#1.1 How To Install XAMPP
- Go to the official site of XAMPP
- Download the latest version of XAMPP according to your Operation System (OS) (this version must meet the Laravel system requirements mentioned above.).
- Then, start the installation by clicking next and filling the required information.
- This step should not be a difficult one. But still, if you face any problem, you can ask your question on the comment section.
- After successful installation, run XAMPP and start MySQL & Apache.
#2. Install Composer
Then after downloading the setup file, run it to install the composer.
Next, you need to provide the correct path for the PHP.exe. If you have more than one PHP version, it might detect the wrong version as well. So, please make sure that you specified the correct path to the latest PHP version.
If you have any proxy address, you can enter here. However, if you are unfamiliar with this term you can leave it and click next.
After this, click to install composer. After some moment, you should be notified as to the completion of the installation process.
#3. Install Laravel
To install Laravel on windows, you can follow two different methods, one directly with the composer and another by installing global Laravel installer at first and then create a fresh Laravel project using this Laravel installer.
You could use any method as you wish, however, the second method is my personal favorite as we need to enter fewer characters and easy to remember for future use.
To install laravel on windows you need to run some command, and to run this command you can follow any menthods like opening command terminal (as administrator) and change directory to “xampp/htdocs“.
Next way is that, you can open window powershell on the desired path by hitting “shift + right click” at the same time. Also, you can use any console like Git bash, if you have, to run these commands.
#3.1. Via Composer Create-Project
To install Laravel with composer directly, you need to run following command. Here, I have used noobietech as the project name, you can pick any onther name as you want.
composer create-project --prefer-dist laravel/laravel noobietech //here noobietech refers to the name of your project.
#3.2. Via Laravel Installer
At first, you need to install global Laravel installer with the composer. To insert global Laravel installer, open the command terminal (run as administrator) and run the following command.
composer global require laravel/installer
From now on, you can create fresh Laravel project easily with a simple and easy command. For this, you need to open command terminal inside “xampp/htdocs” folder and enter the following command there.
laravel new noobietech // noobietech is the name of the project
Up to this point, your server set up is already completed and could be visited either by entering “localhost/noobietech/public” or by running serve command as follows:
cd noobietech php artisan serve
This serve command will start a server on the port 8000. So that, you can access your app web app from “127.0.0.1:8000” or “localhost:8000“.
Up to this point, one question might be bugging you around that where should you provide the details of database credentials. For this, you need to provide all the database credentials in the .env file.
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_database_name DB_USERNAME=your_database_username DB_PASSWORD=your_database_password
In case, if there is no .env file, you can copy and rename .env.example to .env file, where you can provide all the details. To copy .env.example to .example you can run:
cp .env.example .env
With this, the installation of laravel is all completed. Now ,you can explore all the possibilities of laravel by starting to add some code.
Today’s you have learned how to install laravel on windows with composer. If you are interested is learning more about the laravel, pelase subscribe to the newsletter so that we could send you time to time notifications about the update.