DEV Community

Syam Sarosa
Syam Sarosa

Posted on

Laravel Mastery | Install and run your first Laravel project

Welcome to the Laravel Mastery series! Whether you're familiar with Laravel or just exploring it, this guide will help you set up Laravel and run your first project locally. Let’s dive into this step-by-step tutorial and get you started with Laravel, the PHP framework loved by developers worldwide.

This tutorial series isn’t just about building applications—it’s about unlocking the "why" behind the "how." Imagine having the confidence to tackle any project, no matter how unique, because you deeply understand the core principles of Laravel. Master these concepts, and you won’t just build apps—you’ll create efficient, bug-free, and easy-to-maintain solutions that make you a standout developer. Ready to level up and leave the competition behind? Let’s dive in!

Why Choose Laravel?

Laravel isn’t just another PHP framework—it’s a complete toolkit for building modern web applications.

  • Elegant Syntax: Write clean and maintainable code.
  • Powerful CLI: Automate tasks using Artisan, Laravel’s command-line tool.
  • Extensibility: Leverage official and third-party packages.
  • Flexibility: Build APIs, integrate front-end frameworks, or create robust full-stack applications.

If you're ready to enhance your development experience, Laravel is the way to go.

Getting Started: What You Need

Before jumping into Laravel, ensure your system is equipped with the essentials:

  1. PHP 8.1+ Check your PHP version by running:
php -v
Enter fullscreen mode Exit fullscreen mode
  1. Composer

    Composer is a dependency manager for PHP, essential for Laravel installation.

  2. A Web Server (Optional)

    While Laravel has a built-in development server, Apache or Nginx can be useful for production-like setups.

  3. A Database (Optional for Now)

    Laravel supports multiple databases, but you won’t need one for this guide.

Installing Composer

Composer simplifies the management of Laravel’s dependencies. Let’s set it up:

  1. Download Composer

    Visit the Composer installation guide and follow the steps for your OS.

  2. Verify Installation

    Run:

   composer -v
Enter fullscreen mode Exit fullscreen mode

If you see the below result, you’re good to go.
Composer version

Installing Laravel

With Composer installed, you’re ready to bring Laravel into your development environment.

  1. Install the Laravel Installer Run this command to globally install the Laravel Installer:
   composer global require laravel/installer
Enter fullscreen mode Exit fullscreen mode
  1. Verify Installation Check the Laravel Installer version with:
   laravel -v
Enter fullscreen mode Exit fullscreen mode

You should see the Laravel Installer version listed.

Laravel Installer version

Creating Your First Laravel Project

Time to create and explore your first Laravel project!

  1. Create a New Project Use the Laravel Installer to set up your project:
   laravel new awesome-app
Enter fullscreen mode Exit fullscreen mode

If you didn’t install the Laravel Installer, you can use Composer:

   composer create-project laravel/laravel awesome-app
Enter fullscreen mode Exit fullscreen mode
  1. Navigate to Your Project Directory Move into the project folder:
   cd awesome-app
Enter fullscreen mode Exit fullscreen mode

Running Laravel Locally

Laravel’s built-in development server makes running your project simple.

  1. Start the Development Server From your project directory, execute:
   php artisan serve
Enter fullscreen mode Exit fullscreen mode
  1. Access Your Application Open your browser and visit:
   http://localhost:8000
Enter fullscreen mode Exit fullscreen mode

You’ll see Laravel’s welcome page—congratulations, you’re live!

Running Laravel on a Web Server

For a more traditional setup, you can use a web server like Apache or Nginx. Here’s how to configure Apache:

  1. Move Your Project to the Web Server’s Public Directory

    • On Linux: /var/www/html
    • On Windows (XAMPP): /xampp/htdocs
  2. Access Your Application

    Visit your browser and go to:

   http://localhost/awesome-app/public
Enter fullscreen mode Exit fullscreen mode

Next Steps

Congratulations! You’ve successfully installed Laravel and run your first project. This foundational step sets the stage for exploring Laravel’s advanced features, like routing, controllers, and views.

In the next article of the Laravel Mastery series, we’ll build something incredible together. Stay tuned—it’s going to be a fun and enlightening journey!

Top comments (0)