0% found this document useful (0 votes)
9 views

Laravel 02 - Introduction to Laravel

The document is a lecture on modern programming paradigms in web engineering, specifically focusing on the Laravel framework. It covers the definition of frameworks, the advantages of using Laravel, its core philosophy, features, and how to set up a development environment. The lecture aims to equip students with the knowledge to effectively use Laravel for web application development.

Uploaded by

ahraar278
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Laravel 02 - Introduction to Laravel

The document is a lecture on modern programming paradigms in web engineering, specifically focusing on the Laravel framework. It covers the definition of frameworks, the advantages of using Laravel, its core philosophy, features, and how to set up a development environment. The lecture aims to equip students with the knowledge to effectively use Laravel for web application development.

Uploaded by

ahraar278
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Islamic Emirate of Afghanistan

Ministry of Higher Education


Herat University
Computer Science Faculty

Modern Programming paradigms in Web Engineering (Semester 8)


Introduction to Laravel
Lecture 02

Lecturer: Mohammad Saeed Azimi


[email protected]

3/22/2025 2
Contents
What is Framework?
Why use a framework?
What is Laravel ?
The Philosophy of Laravel
Laravel Features
How Laravel Works?
Why Laravel?
Setting Up a Laravel Development Environment
Laravel Instalation

3/22/2025 3
Objectives
Understand the Concept of a Framework
Understand the reasons for using frameworks, such as faster development, standardized
structure, and better code management.
Get familiar with Laravel as a PHP framework and distinguish it from other frameworks.
Understand the philosophy behind Laravel, including its design goals to simplify web
development, encourage clean code, and enhance developer experience.
Learn to set up a Laravel development environment with PHP, Composer, and server tools like
XAMPP.
Learn how to install Laravel on your system and create new Laravel projects.

3/22/2025 4
Introduction
Early Web Development: Developers wrote code for every part of web applications, including
authentication, validation, database access, and templating.
Today’s Landscape: Numerous frameworks, components, and libraries are available, simplifying
development.
Framework Evolution: By the time one framework is learned, newer ones often emerge.

Frameworks

3/22/2025 5
What is Framework?
Definition: A framework is a pre-built, reusable set of tools and libraries that
helps developers build applications efficiently.
Key Features:
 Pre-built components for common tasks (authentication, database handling, etc.)
 Provides a standardized code structure
 Saves time and effort by reducing repetitive coding
 Promotes best practices for cleaner, maintainable code
 Allows for extensibility and customization

Examples:
 Web: Laravel, Django
 Mobile: Flutter, React Native
 Game: Unity, Unreal Engine

3/22/2025 6
Why use a Framework?
 Saves Time: Frameworks provide pre-built components, reducing the need to build
from scratch.
 Expert-Made Components: Components are created and maintained by experts,
ensuring quality.
 Easy Integration: Frameworks provide structure and tools to make components work
together smoothly.
 Predefined Decisions: Frameworks decide how different components should fit
together, making development easier.

3/22/2025 7
I will Just Build It Myself
"Building a Web App Without a Framework"
 Where would you start if building a web app from scratch?
 What tools or libraries would you need to choose?
 How would you organize your app (e.g., routes, controllers)?
 What problems could you face if you built many apps like this?
 Why do you think using a framework might be easier than building everything
yourself?

3/22/2025 8
Consistency and Flexibility
"Building a Web App With a Framework"
Consistency: Frameworks provide well-chosen components that work well
together, making it easier for developers to understand and work across projects.
Reduced Learning Curve: If you know how routing works in one project, you
can apply the same knowledge to all projects.
Flexibility: Good frameworks, like Laravel, offer a solid foundation while
allowing customization to fit specific needs.

3/22/2025 9
What Is Laravel?
Laravel is MVC PHP framework created by Taylor Otwell in 2011
Free open-source license with many contributors worldwide
One of the best frameworks together with Symfony, CodeIgniter, …
Has powerful features, saving us time
Uses Symfony packages

… Build and
Laravel's The PHP
Framework For
ship software
withtools crafted
slogan Web Artisans

for productivity

3/22/2025 10
The Philosophy of Laravel
Core Values: Laravel emphasizes developer speed and developer happiness, aiming to create a framework that
is both efficient and enjoyable to use.
Language & Concepts: Terms like "Illuminate“,"Artisans" reflect Laravel's emphasis on beauty and creativity in
coding, contrasting with utilitarian approaches.
Developer-Centric: Laravel’s focus is on enabling developers to work quickly, easily, and enjoyably—helping
them bring ideas to life without unnecessary barriers.
Code Quality: Laravel promotes clear, simple, and beautiful code, ensuring that the framework is easy to learn,
start with, and use long-term.
Happiness-First Approach: The framework prioritizes developer satisfaction, with slogans like “Happy
developers make the best code,” influencing its style and decisions. Laravel’s focus is on serving individual
developers, rather than adhering strictly to architectural purity or enterprise compatibility.

3/22/2025 11
How Laravel Achives Developer Happiness?
Rapid Development Simplified Tasks Consistency

• Easy learning • Handles common • Predictable API


curve and fast app tasks like database, and structure
deployment authentication,
email and …

supportive
Convention Over community
Complete Ecosystem Community
Configuration
Laravel’s
•A PHP framework • Defaults reduce • Laracasts, Laravel success
News, Twitter, and
with a robust configuration time
Laracon conferences,
ecosystem
quality
resources
good documentation

3/22/2025 12
Laravel Features
Eloquent ORM (object-relational mapping) – implements ActiveRecord
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
Database seeding – provides a way to populate database tables with test data used for
testing
Pagination – easy to use advanced pagination functionalities
Forms security – provides CSRF token middleware, protecting all the forms
3/22/2025 13
How it Works?
What about the code, you ask?
Let’s dig into a simple application

Example 1. “Hello, World” in routes/web.php Figure 1. Returning “Hello, World!” with Laravel

3/22/2025 14
How it Works?
With Controller

3/22/2025 Example 2. “Hello, World” with controllers 15


How it Works?
If you’re storing your greetings in a database, it’ll also look pretty similar

Route Model Migration

3/22/2025 Example 3. Multigreeting “Hello, World” with database access 16


It might seem a bit complicated
The concept may seem overwhelming at first, but you can skip it for now.
You'll learn more about it in later chapters.

With just a few lines of code, you can set up database migrations, models, and retrieve
records easily.

3/22/2025 17
Why Laravel?
So—why Laravel?
Helps turn ideas into reality with minimal code.
Uses modern coding standards.
Supported by a vibrant community and empowering tools.

The searching trend of PHP Framework (Screenshot from Google Trend)

And because you, dear developer, deserve to be happy.

3/22/2025 18
Setting Up a Laravel Development Environment

3/22/2025 19
System Requirements
Laravel works best with a consistent local and remote server environment.
Development environment should include:
 PHP (version depends on Laravel version)
 Tools like Docker, or MAMP/WAMP/XAMPP/AMPPS can be used for local development

Editor: VsCode …
Composer: it’s a tool that’s at the foundation of most modern PHP development. Composer is a
dependency manager for PHP, much like NPM for Node
You’ll need Composer to install Laravel, update Laravel, and bring in external depen
dependencies.
https://getcomposer.org/download

3/22/2025 20
Laravel Instalation
Laravel is very flexible framework.
There are at least 3 options how to create new project:
 - via laravel installer
https://laravel.com/docs/12.x/installation
 - via composer
 - clone from github https://github.com/laravel/laravel

3/22/2025 21
Creating a new Laravel project
Installing Laravel with the Laravel Installer Tool
- composer global require laravel/installer
When installer added this simple command will create app
- laravel new example-app
- cd example-app
- npm install && npm run build
- composer run dev

* Do not forget to add ~/.composer/vendor/bin to your PATH variable in ~/.bashrc

3/22/2025 22
Creating a new Laravel project
Installing Laravel with Composer’s create-project Feature
- composer create-project laravel/laravel projectName

Lets Create first Laravel Project…

3/22/2025 23
Conclusion
A framework is a structured environment providing reusable components,
libraries, and tools to speed up development.
Laravel is a powerful and elegant PHP framework designed for building
modern web applications with ease, offering tools and features to
streamline development.
Setting up Laravel involves installing PHP, Composer, and a database (like
MySQL), Local/Online Server

3/22/2025 24
References
Stauffer, M. (2019). Laravel: Up & running: A framework for building modern php apps. " O'Reilly
Media, Inc.".
Subecz, Z. (2021). Web-development with Laravel framework. Gradus, 8(1), 211-218.
Linh, T. (2019). Building websites with Laravel and VueJS.

https://laravel.com/docs/12.x

3/22/2025 25
Q &A
SECTION

3/22/2025 26

You might also like