Laravel is a PHP web framework that follows the MVC architecture, designed for building scalable web applications. It simplifies various tasks such as routing, database access, and authentication, and includes features like the Blade templating engine and Eloquent ORM for database interactions. The document also covers installation, directory structure, routing, controllers, and form handling with CSRF protection and validation techniques.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
19 views11 pages
Detailed Laravel Lesson 2 3 SE331
Laravel is a PHP web framework that follows the MVC architecture, designed for building scalable web applications. It simplifies various tasks such as routing, database access, and authentication, and includes features like the Blade templating engine and Eloquent ORM for database interactions. The document also covers installation, directory structure, routing, controllers, and form handling with CSRF protection and validation techniques.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11
Laravel Fundamentals
Lesson 2 & 3 – SE331: Software
Engineering Design Capstone Project What is Laravel? • • Laravel is a PHP web framework following the MVC architecture. • • Used for building modern, scalable web applications. • • It simplifies routing, database access, authentication, and more. Installing Laravel • • Install Composer (PHP dependency manager). • • Use command: composer create-project laravel/laravel project-name • • Start development server: php artisan serve Laravel Directory Structure • • app/: Core application code (Models, Controllers). • • routes/: Define web and API routes (web.php, api.php). • • resources/: Views, Blade templates, assets. • • config/: Configuration files for Laravel features. • • public/: Publicly accessible files (index.php, CSS, JS). Routing and Controllers • • Define routes in routes/web.php using Route::get, Route::post, etc. • • Create controller: php artisan make:controller PageController • • Map routes to controller actions for better organization. Blade Templating Engine • • Blade is Laravel’s powerful, lightweight templating engine. • • Supports @if, @foreach, @extends, @section for layout inheritance. • • Use {{ $variable }} to print dynamic content. Laravel Artisan Commands • • php artisan list – shows all available commands. • • make:controller, make:model, migrate – for creating components. • • tinker – interact with your app via command-line. Models and Migrations • • Model: Represents a database table (Eloquent ORM). • • Migration: Creates/modifies database tables using PHP code. • • Run migrations: php artisan migrate Using Eloquent ORM • • Simple syntax for database operations like insert, update, fetch. • • Example: User::all(), Post::where('id', 1)- >first() • • Supports relationships: hasOne, hasMany, belongsTo Handling Forms and CSRF • • Forms in Blade: Use POST method and @csrf directive. • • Controller handles input via $request- >input() • • CSRF protection prevents cross-site request forgery attacks. Validation and Mini Task • • Validate input in controller using $request- >validate([...]) • • Display validation errors in Blade using @error directive. • • Mini Task: Create a form to input user data and display it on another page.