0
0
LaravelHow-ToBeginner · 3 min read

How to Install Laravel: Step-by-Step Guide for Beginners

To install Laravel, first ensure you have PHP and Composer installed. Then run composer create-project laravel/laravel project-name in your terminal to create a new Laravel project.
📐

Syntax

The main command to install Laravel is:

composer create-project laravel/laravel project-name

Here:

  • composer is the PHP package manager.
  • create-project tells Composer to create a new project.
  • laravel/laravel is the Laravel package.
  • project-name is the folder name for your new Laravel app.
bash
composer create-project laravel/laravel project-name
💻

Example

This example shows how to install Laravel in a folder named myapp. It downloads Laravel and all dependencies.

bash
composer create-project laravel/laravel myapp
Output
Installing laravel/laravel (v10.x.x): Downloading... Created project in myapp > @php -r "file_exists('.env') || copy('.env.example', '.env');" > @php artisan key:generate Application key set successfully.
⚠️

Common Pitfalls

Common mistakes when installing Laravel include:

  • Not having PHP or Composer installed or in your system PATH.
  • Using an outdated PHP version (Laravel 10 requires PHP 8.1 or higher).
  • Running the command without internet connection.
  • Trying to install inside a folder that already exists with files.

Always check your PHP version with php -v and Composer with composer -V before installing.

📊

Quick Reference

Summary tips for installing Laravel:

  • Install PHP 8.1+ and Composer first.
  • Run composer create-project laravel/laravel your-folder.
  • Navigate to your project folder and run php artisan serve to start the server.
  • Use php artisan key:generate if the app key is missing.

Key Takeaways

Ensure PHP 8.1 or higher and Composer are installed before starting.
Use the command 'composer create-project laravel/laravel project-name' to install Laravel.
Check your PHP and Composer versions to avoid installation errors.
Run 'php artisan serve' inside your project folder to start the development server.
Avoid installing Laravel inside folders with existing files to prevent conflicts.