Skip to content

Latest commit

 

History

History
185 lines (138 loc) · 4.11 KB

introduction_to_laravel.md

File metadata and controls

185 lines (138 loc) · 4.11 KB
title author format
Introduction to Laravel
Vladimir Lelicanin - SAE Institute
revealjs
theme title-slide-attributes transition footer margin auto-animate preview-links link-external-newwindow scrollable embed-resources chalkboard multiplex slide-number incremental logo
default
data-background-image data-background-position data-background-repeat data-background-size
top left
no-repeat
100px
fade
Vladimir Lelicanin - SAE Institute Belgrade
0.2
true
auto
true
true
false
true
true
true
false

What is Laravel?

Laravel is a free, open-source, PHP web application framework with expressive, elegant syntax. Laravel makes it easy to build modern, robust, web applications with the help of its built-in features and functionality.

Laravel Features

Here are some key features of Laravel:

  • Routing
  • Blade Templating Engine
  • Eloquent ORM (Object-Relational Mapping)
  • Middleware
  • Authentication
  • Artisan CLI (Command Line Interface)

Example Routing

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

Route::get('/about', function () {
    return view('about');
});

More on routing documentation.


Blade Templating

<!DOCTYPE html>
<html>
    <head>
        <title>@yield('title')</title>
    </head>
    <body>
        <div class="container">
            @yield('content')
        </div>
    </body>
</html>

More on Blade documentation.


Eloquent ORM

// Retrieve all records
$users = User::all();

// Query with filter
$users = User::where('active', true)->get();

// Create a new record
$user = new User;
$user->name = 'John Doe';
$user->email = '[email protected]';
$user->save();

More on Eloquent documentation.


Middleware Example

public function handle($request, Closure $next)
{
    if (! $request->hasValidSignature()) {
        abort(401);
    }

    return $next($request);
}

More on Middleware documentation.


Authentication Example

public function authenticate(Request $request)
{
    $credentials = $request->only('email', 'password');

    if (Auth::attempt($credentials)) {
        $request->session()->regenerate();

        return redirect()->intended('dashboard');
    }

    return back()->withErrors([
        'email' => 'The provided credentials do not match our records.',
    ]);
}

More on Authentication documentation.


Artisan CLI Commands

php artisan make:model User

php artisan make:controller UserController

php artisan make:migration create_users_table

More on Artisan documentation.


Why Choose Laravel?

  • Robustness and Modularity
  • Many built-in features
  • Rapid development
  • Easy database migration and seeding
  • Large community and many packages
  • MVC architecture

Laravel Community

  • The Laravel community is very active and helpful
  • You can get help on the Laravel official Slack or the Laravel Forum
  • Many resources available including podcasts, blogs, and video tutorials
  • You can also keep yourself updated by following Laravel updates on social media

Conclusion

  • Laravel is a modern PHP web application framework designed for web developers
  • Laravel's numerous built-in features make it simple to build robust web applications
  • It enables high-quality, efficient, and secure web development
  • Laravel provides a large and supportive community

References