What is Basic Response in Laravel ?

Answers were Sorted based on User's Feedback



What is Basic Response in Laravel ?..

Answer / nafees ahmad

Laravel provides several different ways to return response.
Response can be sent either from route or from controller.
The basic response that can be sent is simple string as shown in the below sample code.
This string will be automatically converted to appropriate HTTP response.

Example :
Step 1 - Add the following code to app/Http/routes.php file.
app/Http/routes.php
Route::get('/basic_response', function () {
return 'Hai to One and All';
});

Step 2 - Visit the following URL to test the basic response.

http://localhost:8000/basic_response

Step 3 - The output will appear as shown in your screen.

Is This Answer Correct ?    0 Yes 0 No

What is Basic Response in Laravel ?..

Answer / Nirmal Kishore Pandey

A basic response in Laravel refers to a simple response that can be returned by a controller action. This can be done using the with() method followed by the json() method, like so: n`return response()->json($data);` where $data is your data.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Laravel PHP Framework Interview Questions

Tell me how to set database connection in laravel?

1 Answers  


How to assign a variable value for all view file?

1 Answers  


What do you mean by binding in laravel?

1 Answers  


How do I register a service provider?

1 Answers  


How can we check the laravel current version?

1 Answers  


What is localization?

1 Answers  


How to install homestead vagrant box?

1 Answers  


What is a service provider laravel?

1 Answers  


What the server requirements for laravel?

1 Answers  


What is a laravel collection?

1 Answers  


Explain what is laravel

1 Answers  


How to use ajax in any form submission?

1 Answers  


Categories