Laravel Installation Guide - Step-by-Step for Beginners
Laravel is an open-source PHP framework built for developing scalable and secure web applications. It follows the MVC (Model-View-Controller) architectural pattern and provides built-in features like routing, authentication, ORM (Eloquent), middleware, and more.
Laravel simplifies complex tasks and speeds up development.
Laravel System Requirements
Before installing Laravel, make sure your system meets these requirements:
- PHP 8.1 or later
- Composer installed
- MySQL / PostgreSQL / SQLite
- OpenSSL
- Mbstring
- XML
- Ctype
- JSON
- Tokenizer
- PDO extension
Step 1: Install Composer
Composer is required to install Laravel because it manages project dependencies.
Install Composer on Windows
- Download Composer from the official website.
- Run the installer.
- Make sure it’s added to your system PATH.
- Restart your terminal.
Step 2: Create a New Laravel Project
Once Composer is ready, run:
composer create-project laravel/laravel myproject
This command will
- Download Laravel
- Install dependencies
- Create the project structure
Move into your project directory
cd myproject
Step 3: Configure Environment File
Laravel stores configuration inside the .env file.
Open .env and update database credentials:
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
Generate the application key
php artisan key:generate
This step is required for session and encryption security.
Step 4: Run Laravel Development Server
Start the built-in server
php artisan serve
You will see something like
Starting Laravel development server: http://127.0.0.1:8000
Open your browser and visit:
http://127.0.0.1:8000
If everything works, the Laravel welcome page will appear.
Alternative Method: Install Laravel Using Laravel Installer
1) Instead of using create-project, you can install the Laravel installer globally
composer global require laravel/installer
2) Then create a new project
laravel new myproject
This method is faster if you frequently create new Laravel projects.
Installing Laravel with XAMPP
If you're using XAMPP:
- Install and start Apache & MySQL.
- Create a database via phpMyAdmin.
- Place your Laravel project inside htdocs.
- Update .env database settings.
- Run php artisan serve or configure a virtual host.
Common Laravel Installation Errors & Solutions
1. Composer Not Recognized
- Restart terminal
- Reinstall Composer
- Ensure PATH variable is configured
2. PHP Version Too Low
- Upgrade PHP to 8.1+
- Check PATH settings
3. Permission Errors (Linux/macOS)
sudo chmod -R 775 storage bootstrap/cache
4. Verify Laravel Installation
php artisan --version
You should see the installed Laravel version number.
Conclusion
Installing Laravel is simple when you follow the proper steps. With PHP and Composer installed, you can set up a new Laravel project in minutes.
Now that your Laravel installation is complete, you can start learning about:
- Routing
- Controllers
- Blade templating
- Database migrations
- REST APIs
Laravel provides everything you need to build professional web applications efficiently.