Zend Framework Interview Questions and Answers

1.What is a Framework?
In software development, a framework is a defined support structure in which another software project can be organized and developed.
  • An abstract design
  •  Set of common functionality
  •  Developed for a particular domain
 2.How to disable layout from controller?
$this->_helper->layout()->disableLayout();
Disable Zend Layout from controller for Ajax call only
if($this->getRequest()->isXmlHttpRequest()){
$this->_helper->layout()->disableLayout();
}
3.How to change the View render file from controller?
function listAction(){
//call another view file file
$this->render(“anotherViewFile”);
}
4.How to protect your site from sql injection in zend when using select query?
$select = $this->select()
from(array(‘u’ => ‘users’), array(‘id’, ‘username’))
where(‘name like ?’,”%php%”)
where(‘user_id=?’,’5′)
where(‘rating<=?’,10);
5.How to check post method in zend framework?
if($this->getRequest()->isPost()){
//Post
}else{
//Not post
}
6.How to get all POST data?
$this->getRequest()->getPost();
7.How to get all GET data?
$this->getRequest()->getParams();
8.How to redirect to another page from controller?
$this->_redirect(‘/users/login’);
9.How to get variable’s value from get?
$id= $this->getRequest()->getParam(‘id’);
10.Create Model file in zend framework?
class Application_Model_Users extends Zend_Db_Table_Abstract {
protected $_name = “users”;
protected $_primary = “id”;
}

11.How to create object of Model?
$userObj = new Application_Model_Users();
12.Which Class extend the Zend Controller?
Zend_Controller_Action
For Example:
class AjaxController extends Zend_Controller_Action {
}
13.Which Class extend the zend Model?
Zend_Db_Table_Abstract
For Example :
class Application_Model_Users extends Zend_Db_Table_Abstract { }
14.What is a framework?
In software development, a framework is a defined support structure in which another software project can be organized and developed.
15.Why should we use framework?
Framework is a structured system where we get following things
  • Rapid application development(RAD).
  • Source codes become more manageable.
  • Easy to extend features.
16.Where we set configuration in zend framework?
We set the config in application.ini which is located in application/configs/application.ini.
17.What is Front Controller?
It used Front Controller pattern. zend also use singleton pattern.
  •  routeStartup: This function is called before Zend_Controller_Front calls on the router to evaluate the request.
  •  routeShutdown: This function is called after the router finishes routing the request.
  •  dispatchLoopStartup: This is called before Zend_Controller_Front enters its dispatch loop.
  • preDispatch: called before an action is dispatched by the dispatcher.
  •  postDispatch: is called after an action is dispatched by the dispatcher.
18.What is full form of CLA in Zend Framework?
Contributor License Agreement
19.Should I sign an individual CLA or a corporate CLA?
If you are contributing code as an individual- and not as part of your job at a company- you should sign the individual CLA. If you are contributing code as part of your responsibilities as an employee at a company, you should submit a corporate CLA with the names of all co-workers that you foresee contributing to the project.
20.How to include js from controller and view in Zend?
From within a view file: $this->headScript()->appendFile(‘filename.js’); From within a controller: $this->view->headScript()->appendFile(‘filename.js’); And then somewhere in your layout you need to echo out your headScript object: $this->headScript();

Comments

Popular posts from this blog

SAP GRC Interview Questions and Answers

Advanced MS Excel