Laravel - Introduction
Laravel - Introduction
ction
to
11 Q1 2024 ≥ 8.2
LARAVEL TODAY
• Laravel now stands at version 10 with 11 currently in development
• Support for PHP 7 has recently been added to Laravel 7.3 - 8.1.
Server Requirements
• PHP >= 7.2.5
• BCMath PHP Extension
• Ctype PHP Extension
• Fileinfo PHP extension
• JSON PHP Extension
• Mbstring PHP Extension
• OpenSSL PHP Extension
• PDO PHP Extension
• Tokenizer PHP Extension
• XML PHP Extension
Laravel utilizes Composer to manage its dependencies. So, before using Laravel, make
sure you have Composer installed on your machine.
I. Download and install Composer
II. Open CMD and paste the syntax: composer global require laravel/installer
• Eloquent ORM (object-relational mapping) - implements Active-Record
• Query builder - helps you to build secured SQL queries
• Restful controllers - provides a way for separating the different HTTP requests (GET, POST,
DELETE, etc.)
• Blade template engine - combines templates with a data model to produce views
• Migrations - version control system for database, update your database easier
ARCHITECTURE
• Model
■ Everything database related - Eloquent ORM (Object Relational
Mapper)
• View
■ HTML structure - Blade templating engine
• Controller
■ Processing requests and generating output
Route::get('/post/{post}', function () {
//
})->name('post.show’);
Routing
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\User;
• Models typically live in the app directory, but you are free
to place them anywhere that can be auto-loaded
according to your composer.json file
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<body>
@section('sidebar’)
This is the master sidebar.
@show
<div class="container">
@yield('content’)
</div>
</body>
</html>
Extending a Layout
When defining a child view, use the Blade @extends directive to specify
which layout the child view should "inherit". Views which extend a Blade
layout may inject content into the layout's sections using @section
directives. Remember, as seen in the example above, the contents of these
sections will be displayed in the layout using @yield:
<!-- Stored in resources/views/child.blade.php -->
@extends('layouts.app')
@section('sidebar’)
@@parent
@section('content’)
<p>This is my body content.</p>
@endsection
Questions?
Let’s Install and Try Laravel
• XAMPP with PHP version 7.3 - 8.0
• Composer
• Text Editor – VS Code (Recommended)
• Git SCM (Optional)
Syntax
After installing Laravel,
composer global require laravel/installer