Okay, great! Installing XAMPP is the first step. Now you need Composer (the PHP dependency manager) and then you can create your Laravel project.
Here's a step-by-step guide:
1. Prerequisites Check & Setup:
- XAMPP Running: Make sure XAMPP is installed correctly and that the Apache server is running. You can check this from the XAMPP Control Panel.
- Install Composer: Laravel is installed using Composer. If you don't have it, download and install it from getcomposer.org.
- Important: During installation, make sure Composer is added to your system's PATH. This allows you to run the
composer command from any directory in your terminal.
- Verify Installation: Open your terminal or command prompt (CMD, PowerShell, Git Bash, etc.) and type:
composer --version
You should see the Composer version number. If you get an error, Composer isn't installed correctly or isn't in your PATH.
- Check PHP Version: Laravel requires a specific PHP version (check the official Laravel documentation for the version you intend to install, but generally PHP 8.0+ is recommended). XAMPP usually comes with a compatible PHP version. You can check your XAMPP PHP version by running:
php -v
(You might need to explicitly run C:\xampp\php\php.exe -v if PHP isn't in your PATH).
- Required PHP Extensions: Ensure the necessary PHP extensions are enabled in your XAMPP installation. Open your
php.ini file (usually located in C:\xampp\php\php.ini) and make sure the following extensions are uncommented (no ; at the beginning of the line):
extension=openssl
extension=pdo_mysql (for MySQL database)
extension=mbstring
extension=tokenizer
extension=xml
extension=ctype
extension=fileinfo
extension=json
extension=session
- After editing
php.ini, restart your Apache server via the XAMPP Control Panel.
2. Create a Laravel Project:
3. Run the Laravel Development Server:
- Navigate into Project: Change directory into your newly created project folder:
cd my-laravel-app
- Start Server: Run the following Artisan command to start the built-in PHP development server:
php artisan serve
- Access Your App: Open your web browser and go to
http://127.0.0.1:8000 or http://localhost:8000. You should see the default Laravel welcome page.
This method uses PHP's built-in server, which is great for development.
4. (Optional) Serving via XAMPP Apache:
If you want to serve your project using XAMPP's Apache server (like traditional websites), you have two main options:
Next Steps (Database):
- Open phpMyAdmin in your browser (
http://localhost/phpmyadmin).
- Create a new database (e.g.,
my_laravel_db).
- Go to your Laravel project directory (
C:\xampp\projects\my-laravel-app).
- Copy the
.env.example file to .env if it doesn't already exist.
- Open the
.env file in a text editor.
- Update the database connection details:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_laravel_db # Your database name
DB_USERNAME=root
DB_PASSWORD= # Leave blank if no password set in XAMPP
- If you started the
php artisan serve server, run migrations (optional, but good practice):
php artisan migrate
You now have Laravel installed and running locally with XAMPP!