How to Create a New Laravel Project on XAMPP
Are you ready to build robust, modern web applications using PHP's most popular framework? Laravel combined with XAMPP provides a highly efficient, localized development environment that mimics production servers. In this comprehensive developer's guide, we will walk you through the step-by-step process of setting up your first Laravel project from scratch on XAMPP.
π Prerequisites for Installation
Before diving into the setup, make sure your machine has the following tools installed and configured:
- XAMPP: Ensure you have the latest version of XAMPP installed, matching the PHP version required by the latest Laravel release.
- Composer: The essential PHP dependency manager used to install Laravel's core files and libraries.
π‘ Pro Tip: Run php -v and composer -v in your terminal to verify both installations are working correctly.
π Step-by-Step Laravel Setup on XAMPP
Step 1: Start Apache and MySQL
Open your XAMPP Control Panel and start both the Apache and MySQL services. These must remain active during development.
Step 2: Open Your Terminal or Command Prompt
Navigate to the htdocs directory inside your XAMPP installation. On Windows, the default path is:
cd C:\xampp\htdocs
Step 3: Run the Laravel Installer Command
Using Composer, run the following command to download and create a fresh Laravel application:
composer create-project laravel/laravel my-first-laravel-app
π Replace my-first-laravel-app with your preferred project directory name.
Step 4: Launch Your Application
Navigate to your newly created directory and run Laravel's internal development server:
cd my-first-laravel-app php artisan serve
π Your local application will now be live at:
http://127.0.0.1:8000
Enjoy coding your next big web application! π
π Quick Reference Table
| Task | Command / Action |
|---|---|
| Stop the dev server | Ctrl + C in terminal |
| Change default port | php artisan serve --port=8080 |
| Use a virtual host | Edit httpd-vhosts.conf in XAMPP |
| Database setup | Use phpMyAdmin at http://localhost/phpmyadmin |
π― Next Steps
Now that your environment is ready, you can:
- Configure your
.envfile for database connections - Start building routes in
routes/web.php - Create controllers and Blade views
- Explore Laravel's artisan commands
Happy Coding! π»β¨