Unit2 - Subjective Questions

INT221 • Practice Questions with Detailed Answers

1

Explain the Laravel Request Lifecycle from the moment a request enters the application until a response is sent back.

2

Define Basic Routing in Laravel and list the available router methods that correspond to HTTP verbs.

3

Differentiate between Required Parameters and Optional Parameters in Laravel Routing with syntax examples.

4

What are Named Routes? Explain their benefits and how to redirect to a named route.

5

Explain the concept of Views in Laravel and describe the directory structure where they are stored.

6

Discuss the different methods available for Passing Data to Views in Laravel.

7

How can you Share Data with All Views in an application? Provide a code example using a Service Provider.

8

Explain how to generate a JSON Response in Laravel. When is this primarily used?

9

Describe how to Attach Headers to a response in Laravel.

10

Explain the process of Attaching Cookies to a response in Laravel. How does Laravel handle cookie security?

11

How can you constrain routing parameters using Regular Expressions? Provide an example.

12

Detailed comparison: Redirecting to Named Routes vs. Redirecting to Controller Actions.

13

What is the role of public/index.php in the Laravel Request Lifecycle?

14

How do you handle Redirects with Flashed Session Data? Why is this useful?

15

Explain the significance of Service Providers in the Request Lifecycle.

16

What happens if a Route Parameter is defined but the matching URI segment is missing in the request? How do you fix it?

17

Describe the workflow of a request that utilizes Routing, Controllers, and Views together.

18

How does Laravel determine if a view exists before attempting to load it?

19

Explain the functionality of the redirect 'back' helper. When is it most commonly used?

20

In the context of Laravel Responses, distinguish between returning a String/Array versus returning a Response Object.