Experiment Number 1:: What Is Bootstrap?
Experiment Number 1:: What Is Bootstrap?
Experiment Number 1:: What Is Bootstrap?
What is Bootstrap?
Bootstrap is a widely used open-source front-end framework for developing responsive
and visually appealing web applications. In this experiment, you will learn how to install
and set up the HTML5-based Bootstrap framework and utilize it to deploy basic HTML
elements styled with Bootstrap's CSS classes.
1
b. Download Using CDN (Content Delivery Network):
• If you prefer not to download Bootstrap and instead want to use it via
a CDN, you can find the CDN links in the "Quick Start" section of the
Bootstrap website. These links allow you to include Bootstrap directly
in your HTML files without downloading any files.
2
5. Access Bootstrap Files:
Inside the extracted folder, you will find the necessary Bootstrap CSS and
JavaScript files that you can include in your HTML documents.
Bootstrap Versions
Bootstrap 5 (released 2021) is the newest version of Bootstrap (released 2013);
with new components, faster stylesheet and more responsiveness.
Bootstrap 5 supports the latest, stable releases of all major browsers and platforms.
However, Internet Explorer 11 and down is not supported.
The main differences between Bootstrap 5 and Bootstrap 3 & 4, is that Bootstrap 5
has switched to vanilla JavaScript instead of jQuery.
CDN or Content Delivery Network is a content distribution network of servers.
3
CDN might be down sometimes or due to proxy Local copy has no dependency on CDN links and
settings, or security policies, the CDN link may not will always be up.
work.
It reduces the amount of bandwidth used by your Server bandwidth remains the same.
server.
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-
4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9"
crossorigin="anonymous">
<title>Form</title>
</head>
<body>
<div class="container">
4
<form>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-
describedby="emailHelp">
<div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div>
</div>
<div class="mb-3">
</form>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-
HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
crossorigin="anonymous"></script>
</body>
</html>
OUTPUT:
5
TABLE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-
4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9"
crossorigin="anonymous">
<title>Form</title>
</head>
<body>
<div class="container">
<table class="table">
<thead class="table-dark">
<tr>
<th scope="col">#</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Elective Subject</th>
</tr>
</thead>
<tbody>
<tr class="table-primary">
<th scope="row">1</th>
<td>Rajat</td>
<td>Garg</td>
6
<td>AWT</td>
</tr>
<tr class="table-light">
<th scope="row" class="table-danger">2</th>
<td class="table-success">Puneet</td>
<td class="table-secondary">Walia</td>
<td>BIA</td>
</tr>
<tr class="table-warning">
<th scope="row ">3</th>
<td >Pratham</td>
<td >Goyal</td>
<td>Crypto</td>
</tr>
</tbody>
</table>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-
HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
crossorigin="anonymous"></script>
</body>
</html>
7
Experiment Number 2: To understand and deploy the multicolumn grid layout
of Bootstrap.
Break Points:
Breakpoints are customizable widths that determine how your responsive
layout behaves across device or viewport sizes in Bootstrap.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multi-Column Grid Layout</title>
<link rel="stylesheet" href="bootstrap-5.0.2-dist\css\bootstrap.css">
</head>
<body>
<div class="container">
<h1>Multi-Column Grid Layout</h1>
<div class="row">
<div class="col-lg-3 col-md-4 col-6">
<div class="card">
<div class="card-body">
<h3>Column 1</h3>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing
elit. Ab vitae at in suscipit quod maxime dignissimos error architecto dolore
voluptatum?</p>
</div>
</div>
</div>
<div class="col-lg-3 col-md-4 col-6">
<div class="card">
<div class="card-body">
<h3>Column 2</h3>
8
<p>Lorem ipsum dolor, sit amet consectetur adipisicing
elit. Ab vitae at in suscipit quod maxime dignissimos error architecto dolore
voluptatum?</p>
</div>
</div>
</div>
<div class="col-lg-3 col-md-4 col-6">
<div class="card">
<div class="card-body">
<h3>Column 3</h3>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing
elit. Ab vitae at in suscipit quod maxime dignissimos error architecto dolore
voluptatum?</p>
</div>
</div>
</div>
<div class="col-lg-3 col-md-4 col-6">
<div class="card">
<div class="card-body">
<h3>Column 4</h3>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing
elit. Ab vitae at in suscipit quod maxime dignissimos error architecto dolore
voluptatum?</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Output
For large Screen size there are 4 columns
9
For medium Screen there are 3 columns
10
Difference In Container and Container-Fluid
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-
4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQ
Iu9" crossorigin="anonymous">
<title>Bootstrap</title>
</head>
<body>
<div class="container my-2 ">
11
</div>
<div class="col bg-danger text-center my-2 ms-2 text-success">
2nd Lorem ipsum dolor sit amet consectetur adipisicing elit. Distinctio quia
quisquam ex architecto et eaque fuga aperiam recusandae! Repellendus consequatur
quisquam ea rem est error beatae, quo doloribus illo voluptate.
</div>
</div>
<div class="row bg-dark"><p class="text-center text-light">This is
Footer</p></div>
</div>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-
HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
crossorigin="anonymous"></script>
</body>
</html>
12
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-
4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQ
Iu9" crossorigin="anonymous">
<title>Bootstrap</title>
</head>
<body>
<div class="container-fluid my-2 ">
</div>
<div class="col bg-danger text-center my-2 ms-2 text-success">
13
2nd Lorem ipsum dolor sit amet consectetur adipisicing elit. Distinctio quia
quisquam ex architecto et eaque fuga aperiam recusandae! Repellendus consequatur
quisquam ea rem est error beatae, quo doloribus illo voluptate.
</div>
</div>
<div class="row bg-dark"><p class="text-center text-light">This is
Footer</p></div>
</div>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-
HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
crossorigin="anonymous"></script>
</body>
</html>
14
Experiment Number 3: To deploy different types of buttons, progress bars,
modals and navigation bars using Bootstrap.
15
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Something else
here</a></li>
</ul>
</li>
</ul>
<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search"
aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
<form>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Email
address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-
describedby="emailHelp">
<div id="emailHelp" class="form-text">We'll never share your email with
anyone else.</div>
</div>
17
<div class="mb-3">
<label for="exampleInputPassword1" class="form-
label">Password</label>
<input type="password" class="form-control"
id="exampleInputPassword1">
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me
out</label>
</div>
<button type="submit" class="btn btn-danger">Submit</button>
</form>
18
Experiment Number 4: To create and setup the Git repository on Bitbucket
or github using SSH.
19
20
This is the place where SSH Key is generated
C:\Users\rajat\.ssh
cat ~/.ssh/id_ed25519.pub
Go to GitHub account settings, under "SSH and GPG keys," click "New SSH key," and paste public
keythere.
21
Step 6: Create a New Repository on GitHub
On GitHub, click the "+" icon in the top right corner and select "New repository." Fill in the
repositoryname, description, and other options.
22
Experiment Number 5: To perform push, c lone and patch operation to Git
repository.
CLONE:
git clone <repository-url>
git clone https://github.com/rajat-28/myportfolio
PUSH:
git push <remote-name> <branch-name>
git push origin main
PATCH:
1. Generate the patch:
git diff > some-changes.patch
23
24
Experiment Number 6: To install and setup the CodeIgniter Framework
and to understand its MVC architecture.
25
26
Experiment Number 7: To construct a simple login page web application
to authenticate users using CodeIgniter Framework and also perform CURD
operations.
CURD stands for Create, Update, Read and Delete.
• Create a new project using composer.
• Start the Xampp server
• Create a database named as demo
We will create a form for user details in which users can add their details and
can update, delete and view those details.
1.Create: This will take input from user in a form.
2.Update: This will enable user to update the details.
3.Read: This will display the details of users in a table.
4.Delete: This will enable user to delete their details.
27
padding-top: 5px;
font-size: 14px;
color: red;
}
</style>
</head>
<body>
<div class="container mt-5">
<form method="post" id="add_create" name="add_create"
action="<?= site_url('/submit-form') ?>">
<div class="form-group">
<label>Name</label>
<input type="text" name="name" class="form-control">
</div>
<div class="form-group">
<label>Email</label>
<input type="text" name="email" class="form-control">
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">Update
Data</button>
</div>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-
validate/1.19.2/jquery.validate.js"></script>
28
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-
validate/1.19.2/additional-methods.min.js"></script>
<script>
if ($("#add_create").length > 0) {
$("#add_create").validate({
rules: {
name: {
required: true,
},
email: {
required: true,
maxlength: 60,
email: true,
},
},
messages: {
name: {
required: "Name is required.",
},
email: {
required: "Email is required.",
email: "It does not seem to be a valid email.",
maxlength: "The email should be or equal to 60 chars.",
},
},
})
}
</script>
29
</body>
</html>
2. edit_view.php:
<!DOCTYPE html>
<html>
<head>
<title>Codeigniter 4 CRUD - Edit User Demo</title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
>
<style>
.container {
max-width: 500px;
}
.error {
display: block;
padding-top: 5px;
font-size: 14px;
color: red;
}
</style>
</head>
<body>
<div class="container mt-5">
<form method="post" id="update_user" name="update_user"
action="<?= site_url('/update') ?>">
<input type="hidden" name="id" id="id" value="<?php echo
$user_obj['id']; ?>">
30
<div class="form-group">
<label>Name</label>
<input type="text" name="name" class="form-control" value="<?php echo
$user_obj['name']; ?>">
</div>
<div class="form-group">
<label>Email</label>
<input type="email" name="email" class="form-control" value="<?php
echo $user_obj['email']; ?>">
</div>
<div class="form-group">
<button type="submit" class="btn btn-danger btn-block">Save
Data</button>
</div>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-
validate/1.19.2/jquery.validate.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-
validate/1.19.2/additional-methods.min.js"></script>
<script>
if ($("#update_user").length > 0) {
$("#update_user").validate({
rules: {
name: {
required: true,
},
email: {
31
required: true,
maxlength: 60,
email: true,
},
},
messages: {
name: {
required: "Name is required.",
},
email: {
required: "Email is required.",
email: "It does not seem to be a valid email.",
maxlength: "The email should be or equal to 60 chars.",
},
},
})
}
</script>
</body>
</html>
3.user_view.php:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-
to-fit=no">
32
<title>Codeigniter 4 CRUD App Example - positronx.io</title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
>
</head>
<body>
<div class="container mt-4">
<div class="d-flex justify-content-end">
<a href="<?php echo site_url('/user-form') ?>" class="btn btn-success mb-
2">Add User</a>
</div>
<?php
if(isset($_SESSION['msg'])){
echo $_SESSION['msg'];
}
?>
<div class="mt-3">
<table class="table table-bordered" id="users-list">
<thead>
<tr>
<th>User Id</th>
<th>Name</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php if($users): ?>
33
<?php foreach($users as $user): ?>
<tr>
<td><?php echo $user['id']; ?></td>
<td><?php echo $user['name']; ?></td>
<td><?php echo $user['email']; ?></td>
<td>
<a href="<?php echo base_url('edit_view/'.$user['id']);?>" class="btn
btn-primary btn-sm">Edit</a>
<a href="<?php echo base_url('delete/'.$user['id']);?>" class="btn btn-
danger btn-sm">Delete</a>
<a href="<?php echo base_url('delete/'.$user['id']);?>" class="btn btn-
danger btn-sm">Delete</a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<link rel="stylesheet" type="text/css"
href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css">
<script type="text/javascript"
src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready( function () {
$('#users-list').DataTable();
34
} );
</script>
</body>
</html>
Models:
UserModel.php:
<?php
namespace App\Models;
use CodeIgniter\Model;
class UserModel extends Model
{
protected $table = 'users';
protected $primaryKey = 'id';
Controller:
UserCrud.php
<?php
namespace App\Controllers;
use App\Models\UserModel;
use CodeIgniter\Controller;
class UserCrud extends Controller
{
// show users list
35
public function index(){
$userModel = new UserModel();
$data['users'] = $userModel->orderBy('id', 'DESC')->findAll();
return view('user_view', $data);
}
// add user form
public function create(){
return view('add_user');
}
// insert data
public function store() {
$userModel = new UserModel();
$data = [
'name' => $this->request->getVar('name'),
'email' => $this->request->getVar('email'),
];
$userModel->insert($data);
return $this->response->redirect(site_url('/users-list'));
}
// show single user
public function singleUser($id = null){
$userModel = new UserModel();
$data['user_obj'] = $userModel->where('id', $id)->first();
return view('edit_view', $data);
}
// update user data
36
public function update(){
$userModel = new UserModel();
$id = $this->request->getVar('id');
$data = [
'name' => $this->request->getVar('name'),
'email' => $this->request->getVar('email'),
];
$userModel->update($id, $data);
return $this->response->redirect(site_url('/users-list'));
}
// delete user
public function delete($id = null){
$userModel = new UserModel();
$data['user'] = $userModel->where('id', $id)->delete($id);
return $this->response->redirect(site_url('/users-list'));
}
}
<?php
use CodeIgniter\Router\RouteCollection;
/**
* @var RouteCollection $routes
*/
37
// CRUD RESTful Routes
$routes->get('/', 'UserCrud::index');
$routes->get('users-list', 'UserCrud::index');
$routes->get('user-form', 'UserCrud::create');
$routes->post('submit-form', 'UserCrud::store');
$routes->get('edit_view/(:num)', 'UserCrud::singleUser/$1');
$routes->post('update', 'UserCrud::update');
$routes->get('delete/(:num)', 'UserCrud::delete/$1');
38
'port' => 3306,
'numberNative' => false,
];
Add User:
User View:
Update data:
39
Add new user:
40
Experiment Number 8: To install and setup, configure the Laravel
Framework.
41
Start the development server:
42
Experiment Number 9: To construct the any simple web application using
Laravel Framework.
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use App\User;
use App\Http\Controllers\Controller;
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Controller;
Route::get('/', [Controller::class,'display']);
43
Now create the model Models/User.php
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
44
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
45