How to Create a Laravel Project - Step by Step Guide

How to Create a Laravel Project - Step by Step Guide

Step 1: Install Composer

Laravel requires Composer to manage dependencies. Download and install Composer from the official website:

Download Composer

Step 2: Install Laravel

Once Composer is installed, you can create a Laravel project using the following command:

composer create-project --prefer-dist laravel/laravel project-name

Step 3: Navigate to Project Directory

Move into your newly created project folder:

cd project-name

Step 4: Serve the Application

Run the built-in development server to start Laravel:

php artisan serve

Now, open your browser and go to http://127.0.0.1:8000 to see your Laravel project in action.

Step 5: Configure the .env File

Set up your database connection in the .env file:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_password

Step 6: Run Migrations

Run the following command to create database tables:

php artisan migrate

Step 7: Create Authentication (Optional)

If you need authentication, install Laravel Breeze or Jetstream:

composer require laravel/breeze --dev
php artisan breeze:install
npm install && npm run dev
php artisan migrate

Conclusion

Congratulations! You have successfully set up a Laravel project. Now, you can start building your application.

0 Comments