Home About Skills Products Work
Projects Services Experience
Learn
Tutorials Courses Blogs Resources
Contact
Blog · Laravel

Laravel for Beginners: Setting Up Your First Project

Laravel for Beginners: Setting Up Your First Project

If you're coming from plain PHP or another framework, Laravel's first few minutes can feel like a lot — artisan commands, service providers, a routes folder, an .env file. This guide walks through exactly what you need to get a real project running, and what each piece actually does.

Installing Laravel

You need PHP 8.2+, Composer, and a database (MySQL, PostgreSQL, or SQLite for local work). Create a new project with:

composer create-project laravel/laravel my-app
cd my-app
php artisan serve

That last command boots a local dev server at http://localhost:8000. Behind the scenes, Composer just downloaded the framework and a starter folder structure — nothing magic yet.

The Folder Structure That Actually Matters

  1. app/Http/Controllers — where request handling logic lives
  2. app/Models — your Eloquent models (database tables as PHP classes)
  3. routes/web.php — every URL your app responds to
  4. resources/views — Blade templates (HTML with PHP sprinkled in)
  5. database/migrations — version-controlled database schema changes

Everything else (config, storage, bootstrap) you'll rarely touch as a beginner.

Your First Route and Controller

Routes map a URL to a piece of code. The simplest version lives directly in routes/web.php:

Route::get('/hello', function () {
    return 'Hello, Laravel!';
});

For anything beyond a one-liner, move the logic into a controller:

php artisan make:controller GreetingController
class GreetingController extends Controller
{
    public function index()
    {
        return view('greeting', ['name' => 'World']);
    }
}

Then point the route at it: Route::get('/hello', [GreetingController::class, 'index']);

Migrations: Your Database Schema as Code

Instead of clicking through phpMyAdmin, Laravel lets you define tables in PHP and version-control them:

php artisan make:migration create_posts_table
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->string('title');
    $table->text('body');
    $table->timestamps();
});

Run php artisan migrate and the table exists — and anyone who clones your repo can recreate the exact same schema with one command.

Where to Go Next

Once this clicks, the natural next steps are Eloquent relationships, form validation with Form Requests, and Blade components. Don't try to learn the whole framework at once — build one small real feature (a contact form, a simple blog) and let the rest come up naturally as you need it.


Building a REST API with Laravel: A Complete Guide

Building a REST API with Laravel: A Complete Guide

API routes, resources, Form Request validation, correct status codes, and Sanctum auth — a real, production-reasonable Laravel API.

Laravel Eloquent Relationships Explained with Real Examples

Laravel Eloquent Relationships Explained with Real Examples

One-to-many, many-to-many, polymorphic, and the N+1 query trap that catches almost every Laravel developer at least once.

Queues and Jobs in Laravel: Processing Tasks in the Background

Queues and Jobs in Laravel: Processing Tasks in the Background

Why anything that talks to the outside world belongs in a queued job, and how to dispatch, delay, and chain them correctly.

Esc