ESC

Search on this blog

Weekly updates

Join our newsletter!

Do not worry we don't spam!

How to Install Laravel 10 on XAMPP


Laravel has fast emerged as one of the most popular open-source PHP frameworks for rapidly building web applications. Its expressive syntax, elegant coding patterns and robust tooling help developers craft solutions faster compared to starting from scratch.

However, setting up Laravel development environments can get tricky for beginners. From managing dependencies to configuring web servers, there are a few steps needed before you can see the familiar landing page greeting.

This comprehensive guide focuses on installing Laravel 10 application on XAMPP across Windows, Linux and Mac OS step-by-step without headaches. Follow along to get your machine Laravel ready!

Prerequisites


Before we begin, please ensure your system has the following:  

✅ XAMPP installed with Apache and MySQL running
✅ Composer and PHP packages added to PATH 
✅ Git CLI tools 
✅ Visual Studio Code or similar code editor

With the basics covered, boot up your machine and verify XAMPP control panel shows Apache and MySQL in running state highlighted green. This confirms the web and database servers are operational. Now let's commence Laravel installation.

 

Section 1 - Download and Configure Laravel 
The first step is fetching a fresh Laravel 10 application using Composer which manages backend dependencies seamlessly.

Open your terminal and run:


composer create-project laravel/laravel myapp

This downloads the latest Laravel version into a `myapp` directory by default. The folder structure contains bootstrap files like index.php configuring requests between web root and app code.

Navigate inside `myapp` directory through terminal next typing `cd myapp`. This becomes our working directory moving forward containing Laravel code.

 

Section 2 - Directory Configuration
We need to map the `public` folder inside our Laravel directory to become document root that Apache web server access externally.

Go to XAMPP installation path (commonly `c:/xampp`) and open `apache/conf/extra/httpd-vhosts.conf` file.

Append this host configuration at the bottom:


<VirtualHost *:80>
 DocumentRoot "C:/xampp/htdocs/myapp/public"
 ServerName myapp.test
</VirtualHost>

This maps myapp's public folder to document root reachable through http://myapp.test domain locally. Adjust paths accordingly per your folder structure.

 

Section 3 - Update Hosts File
For the above server configuration to work, we need to map myapp.test domain to 127.0.0.1 IP address.

Open hosts file under `C:\Windows\System32\drivers\etc` on Windows (Mac/Linux paths may vary) using admin privileges and add record:


127.0.0.1       myapp.test

This pointscustom domain to localhost. Save hosts file after adding entry.

Section 4 - Connect Laravel to Database
With the web server and domain prepped, we need to hook up database connectivity for Laravel.

Go to XAMPP control panel and start Apache and MySQL ensuring both run without errors. Click “Admin” button on MySQL row to open phpMyAdmin portal.

Here click Databases tab on top bar and create new database named `myapp`.

Return to Laravel `.env` file and update MySQL credentials:


DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myapp 
DB_USERNAME=root
DB_PASSWORD=

The details match XAMPP's MySQL defaults allowing Laravel database access.

 

Section 5 - Run Initial Laravel Migration
Laravel apps use database migrations to maintain structure and schemas cleanly. Let's create the first table by running:  

bash
php artisan migrate

This creates default Users table required for built-in authentication capabilities. Verify migration by checking `myapp` database tables through phpMyAdmin containing fresh `users` table records.

Section 6 - Start Development Server
Phew! We are finally all setup for some test drives. Run Laravel's inbuilt PHP server by typing:


php artisan serve

This boots up a local environment at `http://127.0.0.1:8000`. Navigating shows familiar Laravel homepage confirming smooth installation!

Conclusion
In this detailed guide, we successfully installed latest Laravel version 10.x on XAMPP across Windows, Linux and Mac systems by:

✔️ Using Composer to create fresh Laravel project
✔️ Mapping directories appropriately 
✔️ Configuring virtual hosts
✔️ Resolving domain access through hosts 
✔️ Connecting database 
✔️ Running default migration
✔️ Testing locally  

With these fundamentals mastered, you are ready to build amazing PHP applications using Laravel’s awesome capabilities for rapid web development!

For next steps, refer Laravel documentation to leverage:

- Built-in authentication scaffolding
- Migrations for db entity management  
- Eloquent ORM interactions
- Deployment on hosting platforms

I hope you enjoyed this step-by-step Laravel on XAMPP installation guide. Feel free to share any questions that pop up! Happy coding.

How to Host and Deploy a React App with Firebase
Prev Article
How to Host and Deploy a React App with Firebase
Next Article
Laravel 10 Security Best Practices
Laravel 10 Security Best Practices

Related to this topic: