To set up Laravel using XAMPP, follow these steps:
Step 1: Install XAMPP
- Download XAMPP for your operating system from the official Apache Friends website (https://www.apachefriends.org/index.html).
- Run the installer and follow the instructions to install XAMPP on your system.
Step 2: Install Composer
- Download and run the Composer Windows Installer from the official website (https://getcomposer.org/download/).
- Follow the installation instructions, and make sure to select the "Install command-line tool globally" option.
Step 3: Configure XAMPP
- Open XAMPP Control Panel (you can find it in the XAMPP installation directory).
- Start the Apache and MySQL modules by clicking on the "Start" buttons next to them.
Step 4: Create a new Laravel project
- Open a command prompt or PowerShell window.
- Navigate to the directory where you want to create your Laravel project. This should be the "htdocs" directory inside the XAMPP installation directory (e.g., C:\xampp\htdocs).
- Run the following command to create a new Laravel project:
composer create-project --prefer-dist laravel/laravel project-name
Replace "project-name" with the desired name for your project.
Step 5: Configure Laravel Database Connection
- Open the `.env` file located in the root of your Laravel project.
- Update the database configuration according to your XAMPP setup:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=root
DB_PASSWORD=
Replace `your_database_name` with the name of your database. By default, XAMPP uses `root` as the MySQL username and no password.
Step 6: Start Apache and MySQL Servers
- Go back to the XAMPP Control Panel.
- Click on the "Start" buttons next to Apache and MySQL if they are not already running.
Step 7: Access your Laravel application
- Open a web browser.
- Enter the following URL in the address bar:
http://localhost/project-name/public
Replace "project-name" with the name of your Laravel project.
Congratulations! You have set up Laravel using XAMPP, and you can now access your Laravel application through the browser using XAMPP's local server.