Getting Started with Laravel

Getting started in web development has never been easier. With modern frameworks and local development tools, you can go from zero to a running web app in less than an hour.

If you're looking to get started in PHP development, there's no better place to begin than with Laravel. Laravel is a full-stack PHP framework with elegant syntax, robust tooling, and a massive ecosystem. Whether you're building a blog, a SaaS product, or something in between, Laravel gives you everything you need to be productive.

In this guide, we'll walk through the tools you'll need, how to install Laravel, and the key concepts to understand as you build your first application.

Why Laravel?

Laravel offers:

  • A clean, expressive syntax
  • Built-in authentication and routing
  • Eloquent ORM for working with databases
  • Blade templating engine
  • First-party packages for queues, testing, real-time broadcasting, and more

It’s designed for developer productivity and the ability to ship quickly. Let’s dive in.


Tools of the Trade

To develop with Laravel, you’ll need a few tools. Here’s what I recommend:

VS Code

Visual Studio Code is a powerful, free code editor with excellent PHP support. Install the PHP Intelephense extension for syntax highlighting, autocompletion, and more.

Bonus: If you’re working with Laravel, the "Laravel Blade Snippets" and "Laravel Artisan" extensions can enhance your workflow.

Herd

Laravel Herd is a lightweight all-in-one PHP environment tailored for macOS and Windows. It bundles PHP, Composer, Node Version Manager (NVM), and more so you can skip the complicated setup process.

Once installed, Herd runs quietly in the background and gives you a fast, native experience for running Laravel projects locally.

Note: There is a Pro version that gives more advanced features that are very useful but is not required to get started.

For Linux Users: If you are a Linux user my recommendation is to follow the steps at php.new. This tool was created by the makers of Laravel Herd.

DBngin and TablePlus

Laravel supports multiple databases including MySQL, PostgreSQL, SQLite, and SQL Server. MySQL is the most common choice for local development.

By default, your Laravel application will spin up with a SQLite database. If you want a PostgreSQL or MySQL database I recommend using DBngin. Starting out I think it is fine to learn using a SQLite database.

TablePlus is a modern, fast GUI client that allows you to inspect and manage your databases. It’s useful for:

  • Browsing tables
  • Running SQL queries
  • Viewing relationships between data

It’s a helpful companion when working with data for your Laravel application.


Installing Laravel

After installing the tools above you haveeverything you need to start your first laravel application.

Create a Laravel Project

In your terminal of choice point it to your sites directory and run the following command.

laravel new my-first-laravel-app

This command creates a fresh Laravel application in a directory called my-first-laravel-app.

Serve Your Application

Because you have installed Laravel Herd you can view your site by navigating to my-first-laravel-app.test in your browser of choice. You will be presented with a Laravel splashscreen.

For Linux Users: You can navigate to the my-first-laravel-app directory and run composer run dev. This will start a dev server you can view at localhost:8000.


Exploring Laravel’s Folder Structure

Laravel is thoughtfully organized. Here's a tour of the key directories:

  • app/: The core of your app. It holds your models, controllers, and other business logic.
  • routes/: Define your application’s endpoints here. For example, web.php is for browser routes.
  • resources/: Blade templates for rendering HTML, JS files, and CSS.
  • database/: Migrations (database structure), seeders (dummy data), and factories.
  • config/: Application configuration (app name, timezone, database credentials, etc.)

Understanding this structure makes working with Laravel much smoother.


Creating Your First Route, Controller, and View

To see Laravel at a basic level let’s build a simple page to see how things work.

Step 1: Define a Route

Open routes/web.php and add:

Route::get('/hello', [\App\Http\Controllers\HelloController::class, 'index']);

This tells Laravel to respond to /hello with the index method of a controller at \App\Http\Controllers\HelloController. You can also have post, put and delete routes to handle those HTTP routes.

Step 2: Create a Controller

Run this command to create that controller:

php artisan make:controller HelloController

This creates a file at app/Http/Controllers/HelloController.php. Open it and update the index method:

public function index()
{
    return view('hello', ['name' => 'Laravel']);
}

The view function is a useful Laravel Helper that returns a Blade view. Blade is the templating solution Laravel uses.

Step 3: Create a Blade View

Create a new file: resources/views/hello.blade.php

Add this content:

<!DOCTYPE html>
<html>
<head>
  <title>Hello</title>
</head>
<body>
  <h1>Hello, {{ $name }}!</h1>
</body>
</html>

Now visit http://my-first-laravel-ap.test/hello and you’ll see: Hello, Laravel!

Notice that the name came from the view function that was called in the controller.


What’s Next?

Now that you’re up and running, here are some great things to explore:

  • Laravel Eloquent: Powerful ORM for database access
  • Livewire or Inertia.js: For building modern UIs with less JavaScript
  • Laravel Cloud or Forge: For deployment and hosting
  • Laravel Nightwatch: For application monitoring

Final Thoughts

Laravel is more than just a framework—it’s an entire ecosystem designed to help you build amazing applications quickly. With clear documentation, a vibrant community, and first-party tools for everything from testing to deployment, it’s one of the best ways to start and grow as a PHP developer.