0% found this document useful (0 votes)
28 views46 pages

WDF Manual

The document details the steps to demonstrate Laravel fundamentals by installing Laravel, creating a project, and implementing basic features like database migrations, Eloquent models and relationships. It provides detailed instructions on setting up the development environment and creating database tables and models.

Uploaded by

baljitsingh.test
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views46 pages

WDF Manual

The document details the steps to demonstrate Laravel fundamentals by installing Laravel, creating a project, and implementing basic features like database migrations, Eloquent models and relationships. It provides detailed instructions on setting up the development environment and creating database tables and models.

Uploaded by

baljitsingh.test
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Faculty of Engineering & Technology

Subject Name: WDF LAB


Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

PRACTICAL-1

AIM:- Write a code to demonstrate Laravel Fundamentals.

Introduction:-

➢ Laravel is a free and open-source PHP web framework, created by Taylor Otwell
and intended for the development of web applications following the model–view–
controller architectural pattern and based on Symfony.
➢ Laravel is an easy-to-use web framework that will help you create extensible PHP-
based websites and web applications at scale.

Installation:-

Installing Laravel in windows:


Follow the below steps to install Laravel on Windows:

Step 1: Open Chrome. Search “composer”. Click on download link.

Step 2: Visit this website using any web browser. Click on Composer-Setup.exe.

1
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

Step 3: View your Downloads in file manager and click on composer-setup.

Step 4: In select install mode, click on ‘Install for all users’.

Step 5: Allow the permission and in Installation Option, don’t forget to click on ‘Developer
mode’ checkbox. Then ‘next’.

2
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

Step 6: Then select the destination path for composer. And click on ‘next’

Step 7: In Settings Check, Choose the command line PHP that u want to use. The PHP will be
given in your xampp file when you download your xampp in the PC. Then click on ‘next’.

Step 8: Don’t put any proxy server and click on ‘next’.

3
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

Step 9: Check your details and start Install.

Step 10: You will get a confirmation of ‘Completing composer Setup’. Click ‘Finish’ to
complete the setup.

Step 11: After the Composer is installed, check the installation by typing the Composer
command in the command prompt as shown in the following screenshot.

4
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

Step 12: Create a new directory anywhere in your system for your new Laravel project. After
that, move to path where you have created the new directory and type the following command
there to install Laravel.

5
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

Step 13: Installation of version 5.7. In Laravel version 5.7, you can install the complete
framework by typing the following command

Step 14: Now Create a Project using Laravel as show below.

Step 15: After executing the above command, you will see a screen as shown below

Step 16: Copy the URL underlined in gray in the above screenshot and open that URL in the
browser. If you see the following screen, it implies Laravel has been installed successfully.
We will See this welcome plate after searching the url.

6
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

Step 17: Creating an welcome page in the project.

Output:-

7
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

Step 18: Creating the home page as given below

Output:-

8
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

PRACTICAL-2

Aim: Demonstrate the practical of prepping the database.


A. Implement Database migration
B. Implement eloquent models
C. Implement eloquent relationships

A. implement Database migration:-

➢ Database migration in Laravel allows you to define database schema and manipulate it
through PHP code rather than SQL queries directly. This provides a more consistent and
version-controlled way to manage your database structure.
➢ Let's say we want to create a ‘diya’ table
➢ Create a migration file using Artisan CLI

➢ Open the generated migration file (located in database/migrations) and define the schema
in the up() method:

Code:-

9
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

➢ For migration first we can start Apache and MySQL server.

➢ Run the migration to create the table in the database:

10
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

B. implement eloquent models

➢ Eloquent is Laravel's built-in ORM that allows you to interact with your database tables
using PHP syntax.
➢ Let's create a corresponding Eloquent model for the diya table
➢ Generate the model using Artisan CLI

➢ Open the generated model file (located in app/Models/diya.php) and define the table
name and any relationships:

11
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

C. Implement Eloquent Relationships

➢ Eloquent allows you to define relationships between different models easily.


➢ For example, let's establish a relationship between the users table and another hypothetical
posts table:
➢ Create a migration for the posts table and a model for the Post:

➢ Define the schema for the posts table in the migration file and the corresponding
properties in the Post model.

➢ Define the relationship in the neha model:

12
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

Code:-

OUTPUT:

13
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B.Tech-IT Semester-6th Year-3rd

14
Enrollment No - 210303108064
Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

Practical – 3
Aim: Build a REST API with Laravel.

Step 1: Create a New Laravel Project:

composer create-project laravel/laravel pract3

Configure the Database:


Update the .env file with your database credentials:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=prac3
DB_USERNAME=root
DB_PASSWORD=

Enrollment No.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

Enrollment No.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

Generate Migration and Model:


Create a migration for your table structure:
php artisan make:migration prac3imp

Generate a model for the table:


php artisan make:model prac3model

Define Resource Routes:


Add resource routes in routes/api.php:
Route::resource('items', 'ItemController');

Develop Controllers:
Create a controller to handle API logic:
php artisan make:controller ItemController –api

Run the Application:

Start the Laravel development server:

php artisan serve

Enrollment No.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

Testing:

Use tools like Postman to test your API endpoints for CRUD operations.

Enrollment No.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

Practical-4

Aim:- Implement routing in Laravel.


a. Displaying a view
b. Authentication
c. The Task controller

The route is a way of creating a request URL for your application. These URLs do not have
to map to specific files on a website, and are both human readable and SEO friendly.

In Laravel, routes are created inside the routes folder. They are created in the web.php file
for websites. And for APIs, they are created inside api.php.

Open the project folder in Visual Studio code.

Enrollment no. 210303108064 Page | 1


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

a) Displaying a view

Step 1: Create a Route


Open routes/web.php and define a route to the desired view.
Route::get('/home', function () { return view('home'); });

Step 2: Create a View


Create a new Blade view file in resources/views directory, for example, home.blade.php. You
can add your HTML content here.

Enrollment no. 210303108064 Page | 2


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

Step 3: Access the View


Navigate to http://127.0.0.1:8000//home in your browser. You should see the contents of the
home.blade.php view rendered in the browser.

b) Authentication
Laravel provides built-in authentication scaffolding to quickly set up user authentication. Here's
how to implement it:

Step 1: Install Laravel Authentication


Run the following Artisan command to install Laravel's authentication scaffolding:
php artisan make:auth

Enrollment no. 210303108064 Page | 3


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

Connecting database using migration in Laravel.

Step 1 : Open Xampp


Step 2 : start Apache and Mysql server

Step 3 : Open Admin panel of Mysql (It will redirect to localhost/phpmyadmin in browser)
Step 4 : Create new database with name "laravel"

Enrollment no. 210303108064 Page | 4


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

Step 5 : Open your project folder "migration" in VScode and go to .env file
Step 6 : Search for DB_DATABASE and give the name of your database
(DB_DATABASE= laravel)

Step 7 : Open New terminal and run command " php artisan make:migration create_mytable "
It will create a new file in database/migrations folder

Step 8 : run command "php artisan migrate"

Navigate to http://yourdomain.com/register to register a new user and


http://yourdomain.com/login to log in. Laravel provides these routes by default after running
make:auth.

Enrollment no. 210303108064 Page | 5


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

c) The Task Controller

Step 1: Create a Controller


Run the following Artisan command to create a controller named TaskController:

php artisan make:controller TaskController

Step 2: Define Controller Actions


Open TaskController.php in the app/Http/Controllers directory. Define your controller actions
to handle tasks-related functionalities like create, read, update, and delete tasks.

Step 3: Define Routes


Define routes in routes/web.php to map URLs to controller actions. For example:

Route::get('/task-create',[TaskController::class,"create"]);
Route::post('/task-save',[TaskController::class,"store"]);
Route::get('/task-read',[TaskController::class,"show"]);
Route::get('/task-edit/{id}',[TaskController::class,"edit"]);

Enrollment no. 210303108064 Page | 6


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

Step 4: Implement Controller Logic


Inside your TaskController, implement the logic for each action (index, store, show, update,
destroy) to interact with your task data (e.g., CRUD operations).

Enrollment no. 210303108064 Page | 7


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

Step 5: Access Task Routes


You can now access your task routes (e.g., http://127.0.0.1:8000/tasks) to interact with your
tasks through the defined controller actions.

Conclusion:
By following the steps outlined in this manual, one should now have a good understanding of
how to implement routing in Laravel, display views, set up authentication, and create
controllers for managing tasks. Experiment further with Laravel's rich feature set to build
robust web applications efficiently.

Enrollment no. 210303108064 Page | 8


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

Practical-5

Aim:- Demonstrate how to build layouts and Views


a. Defining the layout
b. Defining the child view

a) Defining the Layout

When you're structuring a web application, having a consistent layout across multiple pages is
crucial for maintaining a cohesive user experience. In Laravel, this is achieved through the
concept of layouts.

1] Create Layout File: The layout file, often named something like master.blade.php, serves as
a blueprint for the structure shared among various pages of your application. This file resides
within the resources/views/layouts directory. It contains the foundational HTML structure,
including common elements like headers, footers, navigation bars, and any necessary CSS or
JavaScript includes.
Within the layout file, you'll use Blade directives such as @yield('section_name') to define
placeholders for dynamic content. These placeholders allow child views to inject specific
content into predefined sections of the layout.

Enrollment no. 210303108064 Page | 21


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

b) Defining the Child View


While the layout provides a consistent framework, each page of your application may have
distinct content and functionality. Child views, which extend the layout, allow you to tailor
the content of individual pages while inheriting the overarching layout structure and styling.

1]Create Child View File: Child view files, such as about.blade.php, are created within the
resources/views directory.

These files extend the layout by utilizing the @extends('layouts.master') directive, where
'layouts.master' refers to the path of the layout file relative to the views directory.

Within the child view file, you define the specific content for the page using Blade directives
such as @section('section_name') and @endsection. These sections correspond to the
placeholders defined in the layout file and allow you to inject content unique to each page.

Enrollment no. 210303108064 Page | 22


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

Using the Layout and Child View

Once you've established the layout and defined child views, integrating them into your
application involves routing requests and rendering the appropriate views.
1] Define Route: In Laravel, routes are defined in the routes/web.php file. Each route specifies
a URL pattern and a corresponding action to be taken when that URL is accessed. Typically,
these actions return views, allowing you to dynamically render content based on the requested
URL.
For example, you might define a route like Route::get('/', function () { return view('home'); });.
This route instructs Laravel to render the home.blade.php view when the user visits the root
URL of your application.

Enrollment no. 210303108064 Page | 23


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

2] Access the Page: Users interact with your application by navigating to its URLs in their web
browsers. When a user accesses a URL that matches a defined route, Laravel renders the
associated view. This process involves injecting the content of the child view into the
placeholders defined within the layout, resulting in a complete HTML response sent back to
the user's browser.

Enrollment no. 210303108064 Page | 24


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code:203108484
B.Tech: IT Year: 3rd Semester: 6th

Conclusion:

By implementing layouts and child views in Laravel, you establish a structured approach to
building web applications that promotes code reusability, maintainability, and scalability. The
separation of concerns between layout and content allows for efficient development and easier
management of complex applications as they evolve over time. Additionally, the flexibility
provided by Blade directives enables you to create dynamic and engaging user experiences
while maintaining a consistent visual identity across your application.

Enrollment no. 210303108064 Page | 25


Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

Practical:06
Aim: Implement adding tasks, displaying existing tasks and deleting tasks with
code in Laravel.

1. Database Setup:
• Create a migration to define a tasks table:

• Run the migration to create the table:


php artisan migrate

2. Task Model:
• Create a model for Task:

3. Task Controller:
• Create a controller for managing tasks:

Enrollment N0.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

Enrollment N0.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

4. Blade Templates (views):


• Create views for displaying and managing tasks:

Enrollment N0.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

Conclusion: This practical successfully demonstrated the implementation of CRUD (Create,


Read, Update, Delete) functionality for tasks in a Laravel application. It covered creating a
database table, defining a task model, developing a controller for handling task-related actions
(listing, creating, editing, deleting), and utilizing Blade templates for displaying and managing
tasks. This provides a solid foundation for building more complex task management
applications in Laravel.

Enrollment N0.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

Practical:08
Aim: Authentication with Laravel

Laravel provides built-in authentication scaffolding to quickly set up user authentication. Here's how to
implement it:

Step 1: Install Laravel Authentication


Run the following Artisan command to install Laravel's authentication scaffolding:
php artisan make:auth

Connecting database using migration in Laravel.


Step 1 : Open Xampp
Step 2 : start Apache and Mysql server

Step 3 : Open Admin panel of Mysql (It will redirect to localhost/phpmyadmin in browser)
Step 4 : Create new database with name "new_demo"

Enrollment N0.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

Step 5 : Open your project folder "migration" in VScode and go to .env file
Step 6 : Search for DB_DATABASE and give the name of your database
(DB_DATABASE= laravel)

Step 7 : Open New terminal and run command " php artisan make:migration create_mytable "
It will create a new file in database/migrations folder
Step 8 : run command "php artisan migrate"

Navigate to http://yourdomain.com/register to register a new user and http://yourdomain.com/login to log


in. Laravel provides these routes by default after running make:auth.

Enrollment N0.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF Laboratory
Subject Code:
B. Tech: IT Year: 3rd Semester:6th

Conclusion: In Laravel authentication practices, we've explored securing your application by


implementing user registration, login, and logout functionalities. This ensures only authorized users can
access specific resources and actions within your application. We've leveraged Laravel's built-in
authentication features like user models, controllers, and middleware to streamline this process. By
following these practices, you can effectively protect your application from unauthorized access and
maintain data integrity. This paves the way for building secure and robust web applications in the
Laravel framework.

Enrollment N0.:2303031089001
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B. Tech: IT Year: 3rd Semester: 6 th

Practical:07
Aim: Process Payments with Stripe and Laravel Cashier
Procedure:-
To configure Laravel Cashier, follow the steps below:

1.Install Laravel Cashier using Composer by running the following


command in your terminal:
2.write this command “composer require laravel/cashier”.
3. Add the Cashier service provider to the providers array in your
config/app.php file:
'providers' => [
// ...
Laravel\Cashier\CashierServiceProvider::class,
],
4. Publish the Cashier configuration file:
php artisan vendor:publish --
provider="Laravel\Cashier\CashierServiceProvider" --
tag="config"
5. In your .env file, add the following configuration values:
STRIPE_KEY=your_stripe_key
STRIPE_SECRET=your_stripe_secret
Replace your_stripe_key and your_stripe_secret with your actual Stripe API
keys.

Enrollment no.210303108061 Page No.:38


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B. Tech: IT Year: 3rd Semester: 6 th

6. In your app/Providers/AppServiceProvider.php file, add the following code


to the register method:\
use Laravel\Cashier\Cashier;
/**
* Register any application services.
*
* @return void
*/
public function register()
{
Cashier::useCustomerModel(App\Models\User::class);
}
Replace App\Models\User with the path to your user model.
7. In your User model, add the hasPaymentMethods and subscribes To Plan
methods:
use Laravel\Cashier\Billable;
class User extends Authenticatable
{
use Billable;
// ...
public function hasPaymentMethods()
{
return $this->payment_methods->isNotEmpty();
}
public function subscribesToPlan($plan, $quantity = null)
{
return $this->subscriptions()->where('name', $plan)->first();
}
}

8. In your routes/web.php file, add the following code to register your


subscriptions:
use Laravel\Cashier\Subscription;
Route::get('/register', function () {
$user = Auth::user()
$user->newSubscription('default', 'price_123456789')
->create($paymentMethod, [
'email' => $user->email,
]);
return redirect()->route('home');
})->name('register');
Route::get('/cancel', function () {
$user = Auth::user();
Enrollment no.210303108061 Page No.:39
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B. Tech: IT Year: 3rd Semester: 6 th

$subscription = $user->subscription('default');
$subscription->cancel();
return redirect()->route('home');
})->name('cancel');

Replace price_123456789 with the actual Stripe plan ID.

EXAMPLE:
Code:
\Stripe\Stripe::setApiKey(config('services.stripe.secret'));
$paymentMethod = $request->payment_method;
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => $amount,
'currency' => 'usd',
'payment_method_types' => ['card'],
'payment_method' => $paymentMethod,
'confirm' => true,
]);
if ($paymentIntent->status === 'succeeded') {
// Payment has been processed successfully
// You can create an order, update your database, or send a
confirmation email
// For example, to create a new order:
$order = Order::create([
'user_id' => $user->id,
'amount' => $amount,
'payment_intent_id' => $paymentIntent->id,
'status' => 'completed',
]);
// Redirect the user to a success page or display a confirmation
message
} else {
// Payment was not successful. You can handle the error or display
a message to the user
}

Enrollment no.210303108061 Page No.:40


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B. Tech: IT Year: 3rd Semester: 6 th

We first set the Stripe API key to the secret key provided in the .env file. We then
create a new payment intent using the payment_method obtained from the request.
Once the payment intent has been created, we can check its status to see if the
payment was successful. If the payment was successful, we can create a new order
or update the database accordingly. If the payment was not successful, we can
handle the error or display a message to the user.
Note that you need to have the stripe package installed in your Laravel project.
You can install it using composer:
Command :- composer require stripe/stripe-php
Also, make sure that you have configured the .env file with your Stripe API keys
and other required settings.

OUTPUT:-
Scenario 1: Payment Succeeded

Scenario 2: Payment Failed

Enrollment no.210303108061 Page No.:41


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B. Tech: IT Year: 3rd Semester: 6 th

Practical:09
Aim: Demonstrate How It Has Made: Laravel Router
Step 1:
Create a Controller
First, let's create a controller that will handle the incoming requests. In your
terminal, run the following command to generate a controller:
php artisan make:controller MyController
Step 2:
Define Routes
Next, you need to define routes in the ‘routes/web.php’ file. Open the file
and define your routes. Here's an example:
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\MyController;
Route::get('/hello', [MyController::class, 'hello']);
Route::get('/goodbye', [MyController::class, 'goodbye']);
Step 3:
Implement Controller Methods
Now, let's implement the methods in the MyController controller. Open
MyController.php in the app/Http/Controllers directory and define the hello
and goodbye methods:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class MyController extends Controller
{
public function hello()
{
return "Hello, World!";
}
public function goodbye()
{
return "Goodbye, World!";
}
}
Step 4:
Run the Application
That's it! You have created a basic router in Laravel. Now, you can run your
Laravel application using the following command:
php artisan serve

Enrollment no.210303108061 Page No.:42


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B. Tech: IT Year: 3rd Semester: 6 th

OUTPUT:-

Navigating to http://localhost:8000/hello will display:

Navigating to http://localhost:8000/goodbye will display:

Enrollment no.210303108061 Page No.:43


Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B. Tech: IT Year: 3rd Semester: 6th

Practical:10
Aim: Build a CMS with Larevel.
Step 1:
• Setting up laravel
composer create-project --prefer-dist laravel/laravel cms
• Configure Database: Update the ‘.env’ file with your database credentials.
• Create Database Tables: Use Laravel migrations to define your
database schema.
php artisan make:migration create_posts_table
• Update the migration file with the necessary columns and then run:
php artisan migrate
Step 2: Authentication.
• Install Laravel UI (Optional): Laravel UI provides a simple way to
scaffold authentication and frontend components.
composer require laravel/ui
php artisan ui vue --auth
npm install && npm run
dev

Step 3: CRUD Operations.


• Generate Models and Controllers: Use Artisan commands to
generate models and controllers.
php artisan make:model Post -m
php artisan make:controller PostController –resource
• Define Routes: Define routes for CRUD operations in routes/web.php.
• Implement CRUD Functionality: Implement CRUD functionality in
your controller.
Step 4: views.
Step 5: Authentication Middleware
Step 6: Frontend
Step 7: Additional Features
Step 8: Testing
Step 9: Deployment
Step 10: Maintenance

Enrollment No.:2303031089003
Faculty of Engineering & Technology
Subject Name: WDF LAB
Subject Code: 203108484
B. Tech: IT Year: 3rd Semester: 6th
OUTPUT:-
Exampole (Build blogs + CMS).

CONCLUSION:-Building a CMS with Laravel provides a robust framework for


efficient content management, offering scalability, customization, and security.
Leveraging Laravel's ecosystem facilitates the development of feature-rich CMS
platforms tailored to diverse project requirements, ensuring a seamless user
experience and streamlined content management.

Enrollment No.:2303031089003

You might also like