PHP Frameworks

PHP Frameworks: Frameworks help developers to create applications rapidly and robust applications. Here you can read interview questions on Popular PHP Frameworks like Laravel, CakePHP, CodeIgniter, Phalcon and many more

  • What are pros and cons of using Laravel Framework?
    Laravel

    Posted By: Bharathi

    Pros of Laravel

    1. It uses Blade template engine that helps in speed up compilation tasks and writing cleaner code.
    2. Bundled modularity forces code reusability.
    3. Easy to understand Eloquent ORM.
    4. Outstanding Command Line Interface Artisan.
    5. Clean, clear easily understandable documentation.

    Cons of Laravel

    1. Quite slow because of loading multiple vendors.
    2. Amature developers face some difficulties in staring, but once they are familiar it will be fun to code in Laravel.
    3. Community support is not as wide as a comparison to other frameworks.
    4. Upgrading framework is a headache.

  • What is Laravel service container?
    Laravel

    Posted By: Addison

    Service Container in Laravel is a Dependency Injection Container and a Registry for the application. It is one of the most powerful tool for managing class dependencies and performing dependency injection.

  • How To Use Delete Query In Laravel ?
    Laravel

    Posted By: Titus

    DB::table('table_name')->delete($id);

    is the simplest way to delete a record in Laravel.

  • How To Use Update Query In Laravel ?
    Laravel

    Posted By: Edie

    Updating a record in Laravel using Eloquent.

    $user=User::where(['id'=>1])->first();
    $user->name='abc';
    $user->age='22';
    $user->save();
    
    

  • What is Laravel Dusk?
    Laravel

    Posted By: Gabe

    Laravel Dusk is browser automation and testing tool introduced in Laravel 5.4. It uses ChromeDriver to perform browser automation testing.

  • What is Laravel Echo?
    Laravel

    Posted By: Firman

    Laravel Echo is a tool that makes it easy for you to bring the power of WebSockets to your Laravel applications. It simplifies some of the more common—and more complex—aspects of building complex WebSockets interactions.

    Echo comes in two parts: a series of improvements to Laravel's Event broadcasting system, and a new JavaScript package.

    Source: https://mattstauffer.com/blog/introducing-laravel-echo/

  • What is Laravel Homestead ?
    Laravel

    Posted By: Robin

    Laravel Homestead is an official, pre-packaged Vagrant "box" that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine.

  • What is Tagging?
    Laravel

    Posted By: Esta

    Tagging is a package in Laravel that allow you to tag your content like pages/ post to a keyword.

  • What is dependency injection in Laravel ?
    Laravel

    Posted By: Leander

    Dependency injection or (D.I) is a technique in software Engineering whereby one object (or static method) supplies the dependencies of another object. A dependency is an object that can be used (a service). Injection is the passing of dependency to a dependent object (a client) that would use it.

    Basically, You can found 3 types of dependency injection:

    • Constructor injection
    • Setter injection
    • Interface injection

  • What are named routes in Laravel?
    Laravel

    Posted By: Vernie

    Named routing is another amazing feature of the Laravel framework. Named routes allow referring to routes when generating redirects or URLs more comfortably. You can specify named routes by chaining the name method onto the route definition:

    Example:

    Route::get('user/profile', function () {
        //
    })->name('profile');
    

    You can specify route names for controller actions:

    Route::get('user/profile', 'UserController@showProfile')->name('profile');
    
    

    Once you have assigned a name to your routes, you may use the route's name when generating URLs or redirects via the global route function:

    // Generating URLs...
    $url = route('profile');
    
    // Generating Redirects...
    return redirect()->route('profile');
    

    Source: http://www.laravelinterviewquestions.com/2017/07/named-routes-laravel.html

  • What are Laravel eloquent?
    Laravel

    Posted By: Hershel

    Eloquent is an ORM in Laravel that implements active record pattern and is used to interact with relational databases.

  • What is a Facade?
    Laravel

    Posted By: Thad

    In Programming, Facade is a software design pattern which is often used in object-oriented programming. Laravel facade is a class which provides a static-like interface to services inside the container.

  • How To Use Delete Statement In Laravel?
    Laravel

    Posted By: Loren

    Use delete statement in Laravel:

    In Query Builder Way:

    \DB::table('users')->delete($id); // delete with id
    \DB::table('users')->where('name', $name)->delete(); \\ delete with where condition
    

    In Eloquent Way:

     User::find($id)->delete() // delete with id
     User::where(['name'=>$name])->delete();  \\ delete with where condition
    
    

  • What is an Observer in Laravel?
    Laravel

    Posted By: Tommy

    An observer attaches to an Eloquent Model for Laravel.

    This observer can listen to many different events that happen on the model such as: creating, created, saving, saved, deleting, deleted and many more... All of which you can find here:

    https://laravel.com/docs/5.8/eloquent#events

    The observer listens for these events and fires whenever said action is triggered, letting you preform pre or post procedure statements whenever an action is taken.

     For instance, if you have a user registration page, and every time you create a user, you want to ensure that the password is hashed... You can hook into the User "creating" event.

     public function creating(User $user) {
      $user->password = bcrypt($user->password);

    }

     This will ensure that every time a user is created with a password, that password is automatically hashed.

     In order to register the Observer, you should place it in either the boot() section of your AppServiceProvider or your own custom provider. Note: if you use a custom provider, be sure to register it in config/app.php

    You will need the model and the observer. IE:

     

    boot() {
       User::observe(new UserObserver);
    }

    // That's it...

     

    Now any events that the User model fires will be performed by the User Observer if you have identified any in the observer.

  • How to get current Url in Laravel ?
    Laravel

    Posted By: Andreasdli

    In Laravel 5.5 or above you can use url()->current(); to get current URL without query string and  url()->full(); with the query string.

  • How To Use Select Query In Laravel?
    Laravel

    Posted By: Doctor

    DB::select('name')->table('users')->get();

    This will create a collection that only contains the 'name' property of ever user...

    DB::select('name','username')->table('users')->get();

    This will select name and username from users

  • Which template engine Laravel use ?
    Laravel

    Posted By: Webki Mad

    Laravel uses Blade template Engine.

  • How to use custom table in Laravel Model ?
    Laravel

    Posted By: Martha

    protected $table = 'custom_table_name';

    Attach this to your CustomModel.php

     

     

  • What are Closures in laravel ?
    Laravel

    Posted By: Oscar

    A Closure is an anonymous function that often used as callback methods and can be used as a parameter in a function.

    Example of Laravel Closure

    User::with('profile', function ($builder) {
    	// Get me all collapsed comments
    	return $builder->whereCollapsed(true);
    	
    });
    

  • How to get Logged in user info in Laravel ?
    Laravel

    Posted By: Cora

  • Does laravel support php 7?
    Laravel

    Posted By: Najim Mulla

    Yes, Laravel supports PHP 7.

  • What is Laravel Elixir ?
    Laravel

    Posted By: kristen gorge

    Laravel Elixir provides a clean, fluent API for defining basic Gulp tasks for your Laravel application. Elixir supports several common CSS and JavaScript pre-processors, and even testing tools. Using method chaining, Elixir allows you to fluently define your asset pipeline.

    Laravel Elixir Example

    elixir(function(mix) {
        mix.sass('app.scss')
           .coffee('app.coffee');
    });
    

  • What is the latest version of laravel?
    Laravel

    Posted By: Franklin

  • How can you display HTML with Blade in laravel
    Laravel

    Posted By: Bessie

  • How to install laravel via composer ?Syntax
    Laravel

    Posted By: Irwin

  • What are Cookies ? How to get , set , distroy cookies in Laravel ?
    Laravel

    Posted By: Clifton

  • How can you Exclude URIs From CSRF Protection in Laravel ?
    Laravel

    Posted By: Cecil

  • What getFacadeAccessor method does
    Laravel

    Posted By: Dell

  • How to get current URL in CakePHP ?
    Cakephp

    Posted By: Kausalya

    Getting current URL in CakePHP In CakePHP View

    <?php echo $this->here; ?>
    

    In Controller

    	<?php echo Router::url( $this->here, true ); ?> 
    

  • List some features of CakePHP framework ?
    Cakephp

    Posted By: Alcee

     Some features of CakePHP Frameworks are -

    •   Model Veiw Controller Pattern
    •   Object Relational Mapping
    •   Class inheritance
    •   No Configuration
    •   CRUD Scaffolding
    •   Built in Validation
    •   Easily extends with Plug-ins

  • What is MVC in CakePHP ?
    Cakephp

    Posted By: Lafayette

    Model View Controller (MVC) - targets the modern programming needs. CakePHP uses it just right with all the entities working together excellently and providing a great way to work on different aspects of development in a vitally planned system of data processing. 

    Model layer represents the logical part of our Application.It retrieves the data and convert it into meaningful concepts.

    Veiw layer shows the output to the end user.It process the input provided by the Model Layer and generates specific out put to the end user.

    Controller Layer is responsible for handling all requests coming from all users. It Collects the input from users and coordinate for the model and veiw codes.

     

     

  • How to write, read and delete the Session in cakephp?
    Cakephp

    Posted By: Haywood

    Reading session in cakePHP -

    $session->read('Config.language');

    Deleting session in cakePHP -

    $session->delete('Some.value');

  • What is symfony? List some features?
    Symfony

    Posted By: BorisIncive

  • What are symfony bundles?
    Symfony

    Posted By: Theodore

  • what are components in symfony?
    Symfony

    Posted By: Levy

  • Does laravel use symfony?
    Symfony

    Posted By: Sterling

  • Symfony logs are stored in which directory?
    Symfony

    Posted By: Hoyt

  • How to clear cache in Symfony?
    Symfony

    Posted By: Anamika Kumari

  • how to create a bundle in Symfony?
    Symfony

    Posted By: Authur

  • what are annotations in Symfony?
    Symfony

    Posted By: Elonzo

  • How to create an remove session in Symfony Framework?
    Symfony

    Posted By: Bascom

  • Explain What is FuelPHP?
    Fuel Php

    Posted By: Milo

  • What HMVC is Framework?
    Fuel Php

    Posted By: Herbertbot

  • List some advantages of FuelPHP?
    Fuel Php

    Posted By: Shivprasad

  • What is Presenter in FuelPHP?
    Fuel Php

    Posted By: Ed

  • List out the reserved routes in FuelPHP?
    Fuel Php

    Posted By: Eliseo

  • What is offical website of FulePHP?
    Fuel Php

    Posted By: David

  • List few benefits of HMVC?
    Fuel Php

    Posted By: Nomaan

  • How to get Query in FulePHP?
    Fuel Php

    Posted By: admin

  • What is Scaffolding in FuelPHP?
    Fuel Php

    Posted By: Pleas

  • What are the minimum server requirement to install Fuelphp?
    Fuel Php

    Posted By: jai

  • What is Lumen?
    Laravel

    Posted By: Orla

    Lumen is micro-framework by Laravel. It is developed by the creator of Laravel Taylor Otwell for creating smart and blazing fast API’s. Lumen is built on top components of Laravel. As Lumen is a micro-framework not a complete web framework like Laravel and used for creating API’s only, so most of the components as HTTP sessions, cookies, and templating are excluded from Lumen and only features like routing, logging, caching, queues, validation, error handling, database abstraction, controllers, middleware, dependency injection, Blade templating, command scheduler, the service container, and the Eloquent ORM are kept.

  • Difference between Contracts and Facades?
    Laravel

    Posted By: Freeman

    Contracts are an interface, while Facades are not an interface. it is a class. 

    Contracts are a set of interfaces that define the core services provided by the framework, while Facades provide a static interface to classes that are available in the application's service container.

     

  • How to set csrf token in codeigniter?
    Codeigniter

    Posted By: Guy

    CSRF stands for Cross-Site Request Forgery. It is an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated.

    Adding a CSRF token in your forms is a way to prevent your website by CSRF Attack.

    CSRF in CodeIgniter:

    First, we have to enable CSRF in Config file by adding

    $config['csrf_regenerate'] = TRUE;

    To add CSRF token in Custom Form

       $csrf = array(
        'name' => $this->security->get_csrf_token_name(),
        'hash' => $this->security->get_csrf_hash()
        );
    
         <input name="<?=$csrf['name'];?>" value="<?=$csrf['hash'];?>" type="hidden" />
    

    If you are creating your form using CodeIgniter helper then it will be enabled By default.

  • What is CakePHP?
    Cakephp

    Posted By: Najim Mulla

    CakePHP is rapid development framework for PHP like Laravel it also flows MVC Design Pattern. It completly written in PHP and modeled after the concepts of Ruby on Rails. It is free use and and distributed under the MIT License.

    Some facts About CakePHP
    Distributed UnderMIT License
    First Released OnApril 2005
    Current Stable Version3.7.8
    ArchitetureMVC
    Written InPHP

  • Enlist few key features of Silex Framework?
    Silex Framework

    Posted By: Vernon

  • Explain middleware in Silex?
    Silex Framework

    Posted By: Emil

  • How to install csrf in Silex?
    Silex Framework

    Posted By: Llewellyn

  • Explain what is Phalcon?
    Phalcon

    Posted By: Percival

    Phalcon is a loosely coupled PHP framework which is based on MVC (Model-View-Controller) architecture and delivered as C extension.

  • What is lazy initialization in Phalcon?
    Phalcon

    Posted By: Francis

  • What is MVC in Phalcon?
    Phalcon

    Posted By: sandeep chegu

  • Explain PHQL In Phalcon?
    Phalcon

    Posted By: Anonymous

  • What is ODM in Phalcon?
    Phalcon

    Posted By: Verner

  • Enlist few features of Phalcon Framework?
    Phalcon

    Posted By: Richard

  • Phalcon is written in which Language?
    Phalcon

    Posted By: Bill

  • What is zephir in Phalcon?
    Phalcon

    Posted By: Page

  • Explain dependency injection in Phalcon?
    Phalcon

    Posted By: Anderson

  • Which template engine is used in Phalcon?
    Phalcon

    Posted By: Early

  • List some database related functions available in Phalcon?
    Phalcon

    Posted By: Augustus

  • How can you inject Services into a Volt Template?
    Phalcon

    Posted By: Ivan

  • How to increase CSRF timeout in Phalcon?
    Phalcon

    Posted By: Mrudula

  • List Database engines supported by Phalcon?
    Phalcon

    Posted By: Rupert

  • How to pass data from the controller to view in Phalcon?
    Phalcon

    Posted By: Orie

  • Explain Routing in Phalcon?
    Phalcon

    Posted By: Everett

  • What are Single or Multi-Module Applications in Phalcon?
    Phalcon

    Posted By: Bedford

  • Enlist various types of application events available in Phalcon?
    Phalcon

    Posted By: waqas

  • How many type of views are avilable in Phalcon?
    Phalcon

    Posted By: Newman

  • What is Slim framework?
    Slim Framework

    Posted By: Nels

  • How would you define a middleware in Slim?
    Slim Framework

    Posted By: Edmond

  • How can you install Slim Framework v2?
    Slim Framework

    Posted By: Olin

  • What kind of applications you create in slim Framework.
    Slim Framework

    Posted By: Vikram Patil

  • Is Slim is better than Silex?
    Slim Framework

    Posted By: R S RUSSELL

  • Who is the creater of Slim?
    Slim Framework

    Posted By: Percival

  • How can you configure Slim with Doctrine?
    Slim Framework

    Posted By: kristen gorge

  • How to set charset for DB in slim framework?
    Slim Framework

    Posted By: Suresh

  • How can you set and get a cookie in Slim Framework?
    Slim Framework

    Posted By: Tyler

  • How to define route groups in Slim Framework?
    Slim Framework

    Posted By: Budd

  • Enlist some Environment Variables available in Slim Framework?
    Slim Framework

    Posted By: Calvin

  • What is a hook in Slim Framework?
    Slim Framework

    Posted By: Otto

  • How to enable CORS in Slim Framework?
    Slim Framework

    Posted By: Gabriel

  • How to get remote IP address in Slim Framework?
    Slim Framework

    Posted By: Jessee

  • Enlist the Request Method available in Slim Framework?
    Slim Framework

    Posted By: Ethan

  • What is Yii2?
    Yii 2

    Posted By: Willam

  • What are the prerequisites to install Yii2 Framework?
    Yii 2

    Posted By: Isaac

  • List few benifits of Yii over other PHP Frameworks?
    Yii 2

    Posted By: Roshan Kumar

  • Enlist few major features of Yii Framework?
    Yii 2

    Posted By: Dipali Sharma

  • Explain request Life Cycle in Yii2 framework?
    Yii 2

    Posted By: Bhagyashri

  • What is the difference between YII & YII2?
    Yii 2

    Posted By: Marshall

  • What is Active Record(AR) in Yii?
    Yii 2

    Posted By: Auguste

  • What are Yii helpers?
    Yii 2

    Posted By: Colonel