PHP Laravel Interview Questions and Answers

PHP Laravel Interview Questions and Answers

Today, We want to share with you PHP Laravel Interview Questions and Answers.
In this post we will show you Interview Questions and Answers on Laravel PHP Framework, hear for Top Laravel Interview Questions and Answers we will give you demo and example for implement.
In this post, we will learn about Top 10 PHP Laravel Interview Questions And Answers with an example.

1st : What is Laravel?

Laravel -> open-source PHP framework
developed -> Taylor Otwell
used -> Developing the websites.
Laravel -> create applications using simple and expressive syntax.
based -> model–view–controller (MVC) OOP architectural pattern.

2nd : List of Advantages of Laravel

1st : Easy and consistent(regular) syntax
2nd : Set-up process is easy(cmd)
3rd : customization process is easy
4th : code is always regimented with Laravel

3rd : set Database connection in Laravel

Database Connection file is : config/database.php

 
'mysql' => [
    'read' => [
        'host' => 'localhost',
    ],
    'write' => [
        'host' => 'localhost'
    ],
    'driver'    => 'mysql',
    'database'  => 'ngstude',
    'username'  => 'pakainfo_admin',
    'password'  => 'Admin@9856',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
],

4th :enable the Query Logging

//Enable the Query Logging
DB::connection()->enableQueryLog();

5th: select query in Laravel

$salesorder = DB::select('select * from salesdata where salesid = ?', 10);
if(!empty($salesorder)){
    foreach($salesorder as $sales){
		
    }
} 

6th : Insert Statement in Laravel

DB::insert('insert into salesdata (salesid, salesname, orderid) values (?, ?)', [1, 'mayur dhameliya',58]);

7th : Update Statement in Laravel

DB::update('update salesdata set orderid = 10 where salesid = ?', [1015]);

8th : delete Statement in Laravel

DB::delete('delete from  salesdata where salesid = ?', [1015]);

9th : Laravel support caching?

yes,It is Provides.

10th : Laravel framework requirements

-PHP >= 5.4
-Mcrypt PHP Extension endable
-OpenSSL PHP Extension endable
-Mbstring PHP Extension endable
-Tokenizer PHP Extension endable

11th : Laravel Get Url Parameters.

$getparmname = Input::get('parametername');
$getparmname = Input::get('parametername','default');
$datallparms = Input::all(); // returns all the params in array

12th : Laravel get last inserted Id.

DB::insert('insert into salesdata (salesid, salesname, orderid) values (?, ?)', [1, 'Hitesh dhameliya',58]);
$get_lastInsertedId = DB::connection('mysql')->pdo->lastInsertId();// get last id

13: How to Laravel get Base URL ?

$get_baseurl = url(); //print to url

Leave a Comment