Friday 29 July 2016

Laravel Interview Questions and Answers

Laravel Interview Questions and Answers

Question: What is Laravel?
Laravel is a open-source PHP framework developed by Taylor Otwell used for Developing the websites.
Laravel helps you create applications using simple, expressive syntax.

Question: What are Advantages of Laravel?
  1. Easy and consistent syntax
  2. Set-up process is easy
  3. customization process is easy
  4. code is always regimented with Laravel

Question: Explain about Laravel Project?
Laravel is one of the most popular PHP frameworks used for Web Development.
This framework is with expressive, elegant syntax.
It is based on model–view–controller (MVC) architectural pattern.

Question: What are the feature of Laravel5.0?
  1. Method injection
  2. Contracts
  3. Route caching
  4. Events object
  5. Multiple file system
  6. Authentication Scaffolding
  7. dotenv – Environmental Detection
  8. Laravel Scheduler

Question: Compare Laravel with Codeigniter?
Laravel Codeigniter
Laravel is a framework with expressive, elegant syntax CodeIgniter is a powerful PHP framework
Development is enjoyable, creative experience Simple and elegant toolkit to create full-featured web applications.
Laravel is built for latest version of PHP Codeigniter is an older more mature framework
It is more object oriented compared to CodeIgniter. It is less object oriented compared to Laravel.
Laravel community is still small, but it is growing very fast. Codeigniter community is large.

Question: What are Bundles,Reverse Routing and The IoC container ?
Bundles: These are small functionality which you may download to add to your web application.
Reverse Routing: This allows you to change your routes and application will update all of the relevant links as per this link.
IoC container: It gives you Control gives you a method for generating new objects and optionally instantiating and referencing singletons.

Question: How to set Database connection in Laravel?
Database configuration file path is : config/database.php
Following are sample of database file
'mysql' => [
    'read' => [
        'host' => 'localhost',
    'write' => [
        'host' => 'localhost'
    'driver'    => 'mysql',
    'database'  => 'database',
    'username'  => 'root',
    'password'  => '',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',

Question: How to enable the Query Logging?

Question: How to use select query in Laravel?
$users = DB::select('select * from users where city_id = ?', 10);
    foreach($users as $user){


Question: How to use Insert Statement in Laravel?
DB::insert('insert into users (id, name, city_id) values (?, ?)', [1, 'Web technology',10]);

Question: How to use Update Statement in Laravel?
DB::update('update users set city_id = 10 where id = ?', [1015]);

Question: How to use Update Statement in Laravel?
DB::update('update users set city_id = 10 where id = ?', [1015]);

Question: How to use delete Statement in Laravel?
DB::delete('delete from  users where id = ?', [1015]);

Question: Does Laravel support caching?
Yes, Its provides.