Laravel

The PHP Framework for Web Artisans

Laravel Overview

Laravel is a free, open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model-view-controller (MVC) architectural pattern. Laravel offers a rich set of functionalities which incorporates the basic features of PHP frameworks like CodeIgniter, Yii and other programming languages like Ruby on Rails.

Initial release

June 2011

Stable release

10.0 (February 2023)

Written in

PHP

License

MIT License

Key Features

Common Use Cases

Enterprise Applications

Complex business applications with authentication.

E-Commerce Platforms

Online stores with payment processing.

Content Management

Custom CMS solutions.

RESTful APIs

Backend services for mobile/web apps.

Example Code

// Laravel route example
Route::get('/', function () {
    return view('welcome');
});

// Laravel controller example
Route::get('/users', [UserController::class, 'index']);
Route::get('/users/{id}', [UserController::class, 'show']);

class UserController extends Controller
{
    public function index()
    {
        $users = User::all();
        return view('users.index', ['users' => $users]);
    }

    public function show($id)
    {
        $user = User::findOrFail($id);
        return view('users.show', ['user' => $user]);
    }
}

// Laravel model example
class User extends Model
{
    protected $fillable = ['name', 'email', 'password'];
    
    public function posts()
    {
        return $this->hasMany(Post::class);
    }
}

// Blade template example
/*
<!-- resources/views/users/index.blade.php -->
@extends('layouts.app')

@section('content')
    <h1>Users</h1>
    <ul>
        @foreach ($users as $user)
            <li>
                <a href="{{ route('users.show', $user->id) }}">
                    {{ $user->name }}
                </a>
            </li>
        @endforeach
    </ul>
@endsection
*/

// Laravel Artisan command example
/*
php artisan make:controller UserController
php artisan make:model User -m
php artisan migrate
php artisan serve
*/

Learning Resources