How to install Laravel on Windows 10? What are the prerequisites? How to get started?
Laravel is a free open source PHP framework. It provides tools for building web applications and APIs. The framework has gained popularity because of its simplicity and ease of use.
Laravel is a great choice for beginners who want to build their next project using PHP. In this tutorial, I’ll show you how to install Laravel on your PC or Mac.
- PHP – PHP is an open-source, interpreted, and object-oriented scripting language that can be executed at the server-side. PHP is well suited for web development.
- XAMPP – XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl.
- VSCode (Use any code editor) – Visual Studio Code, also commonly referred to as VS Code, is a source-code editor made by Microsoft with the Electron Framework, for Windows, Linux and macOS.
Before Installing Laravel in windows 10 make sure you have all above prerequisites list ready and running. PHP and XAMPP running.
Now, Lets look into the step’s:
Steps on Installing Laravel on Windows 10
- Step 1: Install Composer
- Step 2: Server Requirement for Installing Laravel
- Step 3: Installing Laravel
- Step 4: Creating Database
- Step 5: Database Configuration
- Step 6: Migrating Database
- Step 7: Testing
Step 1: Install Composer
To install Composer in windows 10. Download Composer from there website getcomposer.org.
After you download it, run and install the composer. Click Next.
now you need to set the php path and click Next.
If you want to use proxy url then enter in next step or leave empty and click next.
Now its ready to install composer. Review it and click install.
Composer has been installed successfully.
How to check if composer has been installed on your windows or not.
First, Open terminal and enter the following command to check.
Step 2: Server Requirement for Installing Laravel
Following are the Server Requirement for installing Laravel.
- PHP >= 8.0 – Laravel 9.x requires a minimum PHP version of 8.0.
- BCMath PHP Extension
- Ctype PHP Extension
- Fileinfo PHP extension
- JSON PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension.
Step 3: Installing Laravel
Now, Its time for Installing Laravel on Windows 10. Before creating your first Laravel project, you should ensure that your local machine has PHP and Composer installed.
In addition, we recommend installing Node and NPM.
After you have installed PHP and Composer, you may create a new Laravel project via the Composer create-project command:
As you had installed XAMPP. We are going to create a project inside C:\xampp\htdocs. Open the project folder in VS Code and Open the terminal and run the following command to install laravel.
composer create-project laravel/laravel example-app
Or, you may create new Laravel projects by globally installing the Laravel installer via Composer:
composer global require laravel/installer
laravel new example-app
Step 4: Creating Database
Now we are going to create a database in localhost. First open XAMPP and start Apache and MySQL as show below.
Open phpmyadmin by entering http://localhost/phpmyadmin in address bar.
Click New > Enter Database Name > Create
Step 5: Database Configuration
Now we are going to configure our laravel database. Open .env and enter the database details.
Step 6: Migrating Database
To run all of your outstanding migrations, execute the migrate Artisan command.
php artisan migrate
If you want to install a fresh migration, you can execute the migrate Artisan command. This command effectively re-creates your entire database:
php artisan migrate:fresh
The above command will create a tables inside your database as you can in bellow image.
Step 7: Testing
As last, when everything has been done. we are going to test our application by running the serve command to start the laravel application.
php artisan serve
Now, open any web browser and open the following link to test the website.
This concludes our tutorial on Installing Laravel on Windows 10: A Beginner’s Guide. We hope you found it helpful. If you did, please like and share this article, and leave us a comment to let us know what you think. If you like the tutorial please subscribe our youtube channel and follow us on social network facebook and instagram.