You are on page 1of 20

Web Technologies

Introduction to Laravel
Today’s Lecture
Introduction to Laravel
• Laravel Introduction
– Laravel History
• Model-View-Controller (MVC) Framework
• Installing Laravel
– Install Composer
– Install Laravel Installer
– Create New Project
– Preview New Project
– Laravel Directory Structure
Laravel Introduction
• Laravel was developed by Taylor Otwell in July 2011.
• Source code of Laravel is hosted on GitHub and licensed under
terms of MIT License.
• Laravel is a PHP-based web framework.
• Laravel is one of the open-source PHP web frameworks.
• Laravel follows Model-View-Controller (MVC) architectural pattern.
Laravel Introduction
• Laravel first beta version was released in June 2011.
• Laravel 1 was released in July 2011.
– Features included authentication, localization, models and
relationships, simple routing mechanism, caching, sessions,
views, extendibility through modules and libraries, and HTML
helpers.
• Laravel 2 was released in September 2011.
– It follows the MVC architecture.
– Features included in-built support for controllers, templating
engine called Blade, and Inversion of Control principle (IOC).
– Due to the addition of controllers, Laravel 2 framework becomes
a fully qualified MVC framework.
Laravel Introduction
• Laravel 3 was released in February 2012.
– Features included unit test integration, Artisan Command-Line
Interface (CLI), database migrations, support for handling events,
sessions drivers, database drivers, and packaging system called
Bundles.
– It was most stable and simple framework used in various kinds of web
applications.
– It came into market as the stable release, and many developers started
switching to the Laravel framework.
• Laravel 4 was released in May 2013.
– It was written from scratch as a collection of components which are
integrated with each other.
– Management of these components is done through the dependency
manager called Composer.
– Features included database seeding, support for message queues,
built-in support for sending different types of email, eloquent ORM
(Object-Rational Mapping) featuring scopes, and support for delayed
deletion of database records called Soft Deletion.
Laravel Introduction
• Laravel 5 was released in February 2015.
– Features included support for scheduling executed tasks
periodically through a package called Scheduler, an abstraction
layer called Flysystem which allows remote storage to be used in
same way as local file system, improved handling of package
assets through Elixir, simplified authentication using
Socialite package, and directory tree structure for developed
applications.
• Laravel 6 was released in September 2019.
– Features included blueprint code generation, semantic
versioning, compatibility with Laravel Vapor, improved
authorization responses, improved job middleware, lazy
collections, and sub-query improvements.
– Frontend scaffolding was removed from main package and
moved into laravel/ui package.
Laravel Introduction
• Laravel 7 was released in March 2020.
– Features included Laravel Sanctum, Custom Eloquent Casts,
Blade Component Tags, Fluent String Operations and Route
Model Binding Improvements.
• Laravel 8 was released in September 2020.
– Features included Laravel Jetstream, model factory classes,
migration squashing, Tailwind CSS for pagination views and
other usability improvements.
• Laravel 9 was released in February 2022.
– Features included new design for routes:list, minimum PHP
requirement, anonymous stub migration, and new query builder
interface.
• Laravel 10 was released in February 2023.
– Features included security for web resources, better
performance under high server load, built-in authentication
system, and easy maintenance and support.
Model-View-Controller(MVC) Framework
• A software design pattern commonly used for developing user
interfaces that divides related program logic into 3 interconnected elements.
– Model
• Represents an individual database table (or record from table).
– View
• Represents the template output our data to the end user.
• Example: login page template with given set of HTML, CSS and
JavaScript.
– Controller
• Take HTTP requests from the browser.
• Gets right data out of the database and other storage mechanisms,
validates user input, and sends a response back to the user.
Installing Laravel
To install the Laravel Framework on the system, we have to follow the
steps: “Install Composer” and Verify Compose Installation. “Install
Laravel” and Verify Laravel Installation.
• Install Composer
– We need Composer to install Laravel.
– Download the latest version of Composer from the link:
https://getcomposer.org/download/
– Download and Run Composer-Setup.exe
• It will install the latest composer version.
– Verify Composer Installation
• To verify composer installation, type command in command
prompt: composer -v
– System will return installed version of Composer on our
system.
Installing Laravel
• Install Laravel
– To install the Laravel as a global Composer dependency, type
command in command prompt: composer global require
laravel/installer
• It will install the Laravel Framework in our system.
– Verify Laravel Installation
• To verify installation of the Laravel framework, type
command in command prompt: laravel -v
– System will return installed version of Laravel on our
system.
Installing Laravel
• Create New Project
– To create new project, type command in command prompt:
laravel new <ProjectName>
• This will create a new subdirectory of the current directory named
<ProjectName> and install a Laravel project in it.
• Preview New Project
– To view the website in the browser, we can use artisan
– Artisan is the command line interface included with Laravel.
– Artisan exists at the root of our application.
– Artisan provides several helpful commands that can assist us while we
build our application.
– To view a list of all artisan commands, type command in command
prompt: php artisan list
– To preview project, type command in command prompt: php artisan
serve
• After run command, it start Laravel development server at
http://127.0.0.1:8000
Installing Laravel
Laravel Directory Structure
• When we open the directory of a new Laravel project, we see following
folders and files directories:
Installing Laravel
Laravel Directory Structure (Folders Directories)
• app
– Where Console, Exceptions, Http, Models, and Providers live.
• bootstrap
– Where cache files live.
– Laravel framework uses cache to boot every time it runs.
• config
– Where all configuration files live.
• database
– Where database factories, migrations, and seeders live.
• lang
– Where auth, pagination, passwords, and validation live.
Installing Laravel
Laravel Directory Structure (Folders Directories)
• public
– Where index(index.php) live.
• resources
– Where CSS (SASS/LESS files as well), JavaScript, and Views files
live.
• routes
– Where api, channels, console, and web definitions php files live.
– Uses for HTTP routes and console routes or artisan commands.
• storage
– Where caches, logs and compiled system files live.
• tests
– Where unit and integration tests live.
Installing Laravel
Laravel Directory Structure (Folders Directories)
• vendor
– Where Composer installs its dependencies.
• Composer is expected to load these dependencies as part of
our deploy process on any remote servers.
Installing Laravel
Laravel Directory Structure (Files Directories)
• .editorconfig
– Gives our IDE/text editor instructions about Laravel’s coding
standards (for example, size of indents, whether to trim trailing
whitespace etc).
• .env and .env.example
– Dictate environment variables (variables that are expected to be
different in each environment and are therefore not committed
to version control).
– .env.example is a template that each environment should
duplicate to create its own .env file
• .gitattributes and .gitignore
– Git configuration files.
• artisan
– Allows us to run artisan commands from the command line.
Installing Laravel
Laravel Directory Structure (Files Directories)
• composer and composer.lock
– Configuration files for composer.
– Composer(composer.json) is user-editable and composer.lock is
not.
– These files share some basic information about the project and
define its PHP dependencies.
• package
– It’s like the composer (composer.json).
– But, for frontend assets and dependencies of the build system; it
instructs NPM on which JavaScript-based dependencies to pull
in.
• phpunit
– It’s a configuration file for PHPUnit.
– The tool Laravel uses for testing out of the box.
Installing Laravel
Laravel Directory Structure (Files Directories)
• readme
– A markdown file for giving a basic introduction to Laravel.
• vite.config
– A backup server that tries to allow less-capable servers to still
preview the Laravel application.
Summary of Today’s Lecture
Introduction to Laravel
• Laravel Introduction
– Laravel History
• Model-View-Controller (MVC) Framework
• Installing Laravel
– Install Composer
– Install Laravel Installer
– Create New Project
– Preview New Project
– Laravel Directory Structure
References
• Ch-1, Ch-2, Ch-3; Laravel Up and Running, A Framework for Building
Modern PHP Apps, 2nd Edition, Matt. Stauffer, Oreilly.
• https://laravel.com/
• https://laravel.com/docs/10.x/installation

You might also like