Sunday 24 March 2019

50 TOP Zend Framework Interview Questions and Answers pdf 2019

Latest Zend Framework Interview Questions, Most recently asked Zend Framework interview questions and answers, Experienced Zend Framework interview questions and answers

zend framework interview questions

Q-1 Is Zend Framework a component library or a framework?
Ans. ZF is both. Zend Framework provides all the components required for most web applications in a single distribution. But Zend Framework components are also loosely coupled, making it easy to use just a few components in a web application- even alongside other frameworks! Using this use-at-will architecture, we are implementing features commonly found in more monolithic frameworks. In fact, we are currently working on a tooling component for the 1.8 release that will make it simpler to build applications using ZF components, yet will not sacrifice the use-at-will nature of existing ZF components.

Q-2 What is autoloader?
Ans. Autoloader is function that load all the object on start up.

Q-3 What is use of Zend front controller?
Ans. Routing and dispatching is managed in the front controller. It collects all the request from the server and handles it.

Q-4 What is the use of Bootstrap?
Ans. Apart from index if we want to do any extra configuration regarding database and other things that is done within bootstrap.

Q-5 How you can set Module name, Controller name, and Action name in Zend framework?
Ans.
$request->setModuleName(‘front’);
 $request->setControllerName(‘address’);
 $request->setActionName(‘addresslist’);

Q-6 Configuration in Zend Framework, application.ini file?
Ans. Configuration can be done in application.ini file in Zend framework. This file in the path application/configs/application.ini.

Q-7 Checking whether form posted or not in Zend framework?
Ans.
$request = $this->getRequest();
$getData = $request->getParams();
$postData = $request->getPost();
$isPost = $request->isPost();

Q-8 Fetch last inserted id, fetch all record,find and fetch a single record.
Ans.
$this->_db->lastInsertId();
$this->_db->fetchAll($sql);
$this->_db->find($id);
$this->_db->fetchRow($sql);

Q-9 Difference between Zend_Registry and Zend_Session?
Ans.
Zend_Registry is used to store objects/values for the current request. In short, anything that you commit to Registry in index.php can be accessed from other controllers/actions (because EVERY request is first routed to the index.php bootstrapper via the .htaccess file). Config parameters and db parameters are generally prepped for global use using the Zend_Registry object.

Zend_Session actually uses PHP sessions. Data stored using Zend_Session can be accessed in different/all pages. So, if you want to create a variable named ‘UserRole’ in the /auth/login script and want it to be accessible in /auth/redirect, you would use Zend_Session.

Q-10 When do we need to disable layout?
Ans. At the time of calling AJAX to fetch we need to disable layout.
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);

Q-11 How to call two different views from same action?
Ans.
Example1:
Public function indexAction() {
If(condition)
$this->render(‘yourview.phtml’);
Else
Index.phtml;
Example2:
?
1
2
Public function indexAction() {
}
Now in your index.phtml you can have this statement to call other view
$this->action(‘action name’,’controller name’,’module name’,array(‘parameter name’=>’parameter value’));

Q-12 Can we call a model in view?
Ans. Yes, you can call a model in view. Simple create the object and call the method.
$modelObj = new Application_Model_User();

Q-13 Can we rename the application folder ?
Ans. yes, we can

Q-14 Can we move the index.php file outside the public folder?
Ans. yes, we can

Q-15 How to include js from controller and view in zend?
Ans.
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();?>

Q-16 How to include css from controller and view in zend?
Ans.
From within a view file:
$this->headLink()->appendStylesheet(‘filename.css’);
From within a controller:
$this->view->headLink()->appendStylesheet(‘filename.css’);
And then somewhere in your layout you need to echo out your headLink object:
<!--=$this--->headLink();?>

Q-17 How do you protect your site from sql injection in zend when using select query?
Ans.
We have to quote the strings,
$this->getAdapter ()->quote ( <variable name=""> );
$select->where ( ” <field name=""> = “, <variable name=""> );
OR (If you are using the question mark after equal to sign)
$select->where ( ” <field name=""> = ? “, <variable name=""> );
</variable></field></variable></field></variable>

Q-18 What is zend framework?
Ans. It is opensource framework created by zend.com (PHP company). It is object oriented and follow the MVC. Zend Framework is focused on building more secure, reliable and fast development.

Q-19 How to add extra HTML (i.e link) in Zend_Form?
Ans. use Desciption decorator with (escape =false in second parameter).

Q-20 How can I detect if an optional file has been uploaded?
Ans. Zend_File_Transfer_Adapter_Http's receive() return true.

Q-21 What is Zend registry?
Ans. It is container for object and values in applications, when you set an object in zend_registry you can access in whole site.

Q-22 What is Zend_Form?
Ans. It is mainly used to display the form. but along with this we use for filter, validation and formating our form. It have following elements
Element filter
Element validation
Element ordering.
Decorator
Grouping
Sub form
Rendering form elments in single call or one by one for elements.

Q-23 What is zend helpers?
Ans. It can be divided in two parts,
a) Action Helper: the helper is created for controller
b) View Helper: the helper is created for view files (.phtml).

Q-24 What do you know about zend layout.
Ans. It work as a site template and have following features.
Automatic selection and rendering layout
Provide separate scope for calling element i.e parital, render, partialLoop

Q-25 What is Inflection?
Ans. It is class in zend used to modify the string like convert to lowercase, change to url by removing special chars and convert underscore to hyphen.

Q-26 What is Front Controller?
Ans. 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.

Q-27 What is Zend_filter?
Ans. Zend_filter is used to filter the data as remove the tags, trailing the spaces, remove all except digits.

Q-28 Tell me about Zend Framework
Ans. Extending the art & spirit of PHP, Zend Framework is based on simplicity, object-oriented best practices, corporate friendly licensing, and a rigorously tested agile codebase. Zend Framework is focused on building more secure, reliable, and modern Web 2.0 applications & web services, and consuming widely available APIs from leading vendors like Google, Amazon, Yahoo!, Flickr, as well as API providers and cataloguers like StrikeIron and ProgrammableWeb.

Q-29 Which version of PHP does Zend Framework require?
Ans. Zend Framework requires PHP 5.2.4 and up. Some Zend Framework components may work with earlier versions of PHP, but these components are tested and supported only on 5.2.4 and up. See the requirements appendix for more information.

Q-29 Does Zend Framework support PHP 4?
Ans. No. Zend Framework was built to use all of the sophisticated object oriented features of PHP 5 and take advantage of significant performance and security enhancements. Another consideration was support of the platform ZF would be running on. The PHP community officially discontinued support for PHP 4 as of 2008-01-01, and no critical security updates will be published for PHP 4 after 2008-08-08. These factors, among others, convinced us that PHP 5 was the best platform for Zend Framework and applications built on ZF.

Q-30 Where is the model in ZF's MVC implementation?
Ans. The model component can vary dramatically in responsibilities and data store from one MVC application to the next. The ZF community has not defined a model interface, class, or other formalism simply because we wanted to avoid introducing limitations without significant added value.

Q-31 Is ZF a component library or a framework?
Ans. Simple answer: both. Zend Framework provides all the components required for most web applications in a single distribution. But Zend Framework components are also loosely coupled, making it easy to use just a few components in a web application- even alongside other frameworks! Using this use-at-will architecture, we are implementing features commonly found in more monolithic frameworks. In fact, we are currently working on a tooling component for the 1.8 release that will make it simpler to build applications using ZF components, yet will not sacrifice the use-at-will nature of existing ZF components. It's a testament to the use-at-will architecture of Zend Framework that the tooling component itself can be used standalone.

Q-32 Where's the model?
Ans. Unlike the view and the controller components, the model component can vary dramatically in responsibilities and data storage from one MVC application to the next. It should represent what your application does in the abstract. The Zend Framework community has not defined a model interface, class, or other formalism because we haven't identified enough added value to justify limitations on what constitutes a model.

Q-33 I want to use a SQL function or perform calculations in a statement I'm generating with Zend_Db_Select. How can I do this?
Ans. Actually, by default, if your expression includes parentheses, Zend_Db_Select will cast the statement appopriately. However, if it does not, or you are having problems, you can useZend_Db_Expr to explicitly create the expression:
* Build the SQL:
* SELECT p."product_id", p.cost * 1.08 AS cost_plus_tax
* FROM "products" AS p
*/
$select = $db->select()
->from(array('p' => 'products'),
array(
'product_id',
'cost_plus_tax' => new Zend_Db_Expr('p.cost * 1.08'),
));

Q-34 What is the difference between Zend_Auth and Zend_Acl?
Ans. Zend_Auth is used for authenticating users with a variety of authentication methods, including LDAP, OpenID, and HTTP. Authentication is the process of verifying that the provided credentials are valid for the system. By authenticating to your system, your users can prove that they are who they say they are. For more information on Zend Framework's authentication implementation, see the Zend_Auth documentation.
Zend_Acl is an implementation of Access Control List (ACL) authorization. Generally speaking, ACLs are lists of roles that are authorized to perform a particular operation on specific resources in your system. Zend_Acl can support advanced rule definitions with features such as multiple inheritance for roles and assertions for conditional rules. For more information on Zend_Acl, see the Zend_Acl documentation.
Zend_Auth and Zend_Acl can be used together to build very sophisticated security systems: first the user confirms their identity with Zend_Auth, then this identity is used to assign one or more Zend_Acl roles to the user for authorization to use or modify resources in the system

Q-35 What is this "username" I have to submit with my CLA, and why do I have to submit it?
Ans. This is the username you use to access the issue tracker, wiki, code browser, etc. If you don't have a username yet, you can sign up here.When we process your CLA, we need to grant the appropriate privileges to your user. To do this, we need to know your username.

Q-36 Should I sign an individual CLA or a corporate CLA?
Ans. 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.

Q-37 What should I know about the Zend Framework CLA before submitting it?
Ans. By signing a CLA, the person contributing source code provides a copyright license to Zend to use the source code he or she submitted to the Zend Framework project. By doing so, the contributor does not give up his or her own rights or copyright to his or her own code, but provides us with a copyright license. In addition, the purpose of the CLA is to clearly define the terms under which intellectual property has been contributed to Zend Framework and to make sure that, to the best of the contributor's knowledge, he or she is entitled to make such contribution and is not violating anyone else's intellectual property.

Q-38 Why does the Zend Framework project have a CLA at all?
Ans. The CLA protects all users including individuals, small and medium businesses, and large corporations. By having a CLA in place, we mitigate the risk that companies who claim intellectual property infringement may demand royalties or fees from users of Zend Framework, whether individuals or companies. This is especially important for companies basing their business or products on Zend Framework. The Zend Framework CLA helps to ensure that code and other IP in Zend Framework remains free.

Q-39 I am a minor (under 18 years of age). Who should sign my CLA?
Ans. CLA's for contributors under the age of 18 should be signed by both the contributor and the contributor's legal guardian.

Q-40 I want to use a SQL function or perform calculations in a statement I'm generating with Zend_Db_Select. How can I do this?
Ans.
/* Build the SQL:
 * SELECT p."product_id", p.cost * 1.08 AS cost_plus_tax
 * FROM "products" AS p
 */
$select = $db->select()
        ->from(array('p' => 'products'),
               array(
                   'product_id',
                   'cost_plus_tax' => new Zend_Db_Expr('p.cost * 1.08'),
                ));

Q-41 How can I customize the appearance of forms generated by Zend_Form?
Ans. You're probably looking for decorators. All forms and form elements in Zend_Form use decorators to render their output.

Q-42 How can I add extra HTML (such as a link) to my form element?
Ans. This can easily be done using decorators. For instance using the Description decorator. It is important to note though that you will need to turn off escaping for the output of the decorator:
$element->setDecorators(array(
    array('ViewHelper'),
    array('Description', array('escape', false)),
    array('Errors'),
    array('HtmlTag', array('tag' => 'dd')),
    array('Label', array('tag' => 'dt')),
));
Now, you can use the following to add extra HTML to the element:
$element->setDescription('This contains HTML that will actually be parsed by the browser, not escaped');

Q-43 Why can't Zend_Form render my File element without errors?
Ans. The file element needs a special file decorator, which is added by default. When you set your own decorators for file elements, you delete the default decorators. For example:
$element->setDecorators(array(
    array('ViewHelper'),
    array('Errors')
));
You should use a File decorator instead of the ViewHelper for the file element, like so:
$element->setDecorators(array(
    array('File'),
    array('Errors')
));

Q-44 How can I detect if an optional file has been uploaded?
Ans. The receive() method will return true for file elements that are not required. The reason is that you said "the file can be omitted, and that's ok for me". The receive() method will return false only in the event of a failure.
Still there are several ways to detect if a file has been uploaded or not:

Use isUploaded which returns a boolean
Use getFileName which returns null in this case (note that you must use the latest release for this behaviour)
Use getFileInfo which will have an empty 'file' key and the flag 'isUploaded' set to false

Wednesday 17 February 2016

What are the major differences between services and Web services?

Service-Oriented Architecture is an IT business system design methodology that is focused on reusability, breaking down silos, and enabling rapid and on-going optimization of business processes. An SOA can be implemented using any number of technologies. However, in practice the Web services standards and technologies (XML, SOAP, WSDL, WS-Security, WS-Policy, etc.) are at the heart of forming every organization's SOA implementation.

More => WCF Interview Questions & Answers

What is service host factory in WCF?

1. Service host factory is the mechanism by which we can create the instances of service host dynamically as the request comes in.
2. This is useful when we need to implement the event handlers for opening and closing the service.
3. WCF provides ServiceFactory class for this purpose.

More => WCF Interview Questions & Answers

What is the difference WCF and Web services?

WCF can create services that are similar in concept to ASMX, but it can do much more !!!
WCF is implemented on a different pipeline much more efficient than ASP.Net. It uses different serialization defaults. We can say that under the hood almost everything is different (and better)
WCF has a much better security mechanisms
WCF implement most WS* standards – Asmx Don’t. Thus WCF has security, reliability, transactions, one-way messaging and much more.
With WCF you can use any transport very easily.
As WCF is implemented on a different pipeline it does not have all Http context capabilities (Http session, cache etc)
You can host WCF on any process including a window service. It is very common.

More => WCF Interview Questions & Answers

How can we use MSMQ bindings in WCF?

The NetMsmqBinding is the Queued binding provided in WCF for two WCF endpoints to communicate using MSMQ. The binding therefore, exposes specific properties that are MSMQ-specific. However, not all MSMQ features and properties are exposed in the NetMsmqBinding. The NetMsmqBinding is a compact feature designed with the optimal set of features that the majority of customers would find sufficient.

More => WCF Interview Questions & Answers

What are tha advantages of hosting WCF service in WAS?

WAS (Windows Activation Service) is a component of IIS 7.0. Following are few advantages : 
1. We are not only limited to HTTP protocol. We can also use supported protocols like TCP, named pipes and MSMQ
2. No need to completely install IIS. We can only install WAS component and keep away the WebServer.

More => WCF Interview Questions & Answers


In WCF which bindings supports the reliable session?

In WCF, following bindings supports the reliable session :
1. wsHttpBinding
2. wsDualHttpBinding
3. wsFederationHttpBinding
4. netTcpBinding

More => WCF Interview Questions & Answers