Fatskills
Practice. Master. Repeat.
Study Guide: All The Useful Zend Framework Interview Questions & Answers
Source: https://www.fatskills.com/php-programming/chapter/all-the-useful-zend-framework-interview-questions-answers

All The Useful Zend Framework Interview Questions & Answers

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~7 min read

Q 1. What is a Zend framework and why it is used?
Zend framework is an advanced collection of professional PHP packages which can be used to develop web services and applications using PHP 5.6+. It offers 100% object-oriented code using a broad spectrum of features related to languages. It has more than 379 million installations.

Q 2. Who developed the Zend Framework?
Zend Framework is developed by Zend Technologies, a Cupertino, California, U.S based world full web infrastructure software company founded by Andi Gutmans and Zeev Suraski in 1999. The Zend framework was initially released on March 3, 2006.

Q 3. What is the latest version of Zend Framework?
Zend Framework 3 is the latest version of Zend Framework. It was released on 28 June 2016.

Q 4. List some advantages of Zend Framework as compared to other frameworks.
Fully object-oriented framework and utilizes many object-oriented concepts such as interfaces and inheritance.
Build web applications more comfortable and faster.
Support for multiple vendors and database systems.
Excellent scope for customization.
Attractive and meaningful URL database.
Compose and send email features.

Q 5. How to install Zend on your local machine?
Here are the simple steps to install Zend in a local machine:

Create a new SSH user
Create a fully hosted domain or subdomain
Create a phprc file
Change the default PHP CLI the user shell uses
Download Zend framework
Log into the server via SSH
Change the directory of the project
Close the repository and change directory
Then, locally install the composer into the directory
Run the following syntax to install the Zend framework
[server]$ php composer.phar self-update

[server]$ php composer.phar install

Q 6. Explain the difference between Zend_registry and Zend_session in Zend.

Zend_registry    Vs  Zend_session

1.    It is used to store resources or objects in at runtime.    -   It is used to used to work with session extension present in PHP.
2.    It's request scope.    -   It's a session scope.

Q 7. Why do we need to disable layout & how we can do it?
Some time we need to disable layout of your page. No layout mean no header, no footer, no left bar, no right bar. You want to display the main page content part like if you are using AJAX at that time you need to disable layout for this ajax call page.

You need to add following code in your controller to disable page layout::

$this->_helper->layout->disableLayout();

Q  8. How to include css and js from the controller in the zend framework?
Create AppController.php
Include _getHelper() method in AppController.php
Create any controller in any module
From controller in the header section, append or prepend JavaScript/ CSS files dynamically in Zend framework
From the controller, append or prepend custom JavaScript code dynamically in HTML header
Then, from the controller, append or prepend custom javascript code dynamically just before at bottom to finish

Q  9. Explain the use of bootstrap used in Zend framework.
In the Zend framework, bootstrap is the process that loads the user application, but it's not limited to the session. Any resources required by the application to process the request is first bootstrapped before the request is fulfilled.

Q 10. What do you mean by Zend Engine?
It's an open-source scripting engine used to interpret the PHP programming language. It provides resource and memory management and other standard services required for the PHP language.

Q 11. How to protect your website from sql injection in Zend using Select Query?

$this->getAdapter ()->quote ( );
$select->where ( ' = ', );
$select->where ( ' = ? ', );

Q 12. How to render view file from controller in Zend framework?
Zend_View uses the PluginLoader to look up helper classes. This means that for each helper you call, Zend_View needs to pass the helper name to the PluginLoader, which then needs to determine the class name, load the class file if necessary, and then return the class name so it may be instantiated. Subsequent uses of the helper are much faster, as Zend_View keeps an internal registry of loaded helpers, but if you use many helpers, the calls add up.

Q 13. How we can check post method in Zend framework?
$this->getRequest() present in the context of a controller is annotated to return an object of class

Zend_Controller_Request_Abstract. Zend_Controller_Request_Http's isPost() method derived

from end_Controller_Request_Abstract. So, IDE can't offer this method, but it's present there.

Q 14. How to get all post data in Zend framework?
$this->getRequest()->getPost();

Q 15. How to get all get data in Zend framework?
$this->getRequest()->getParams();

Q 16. How we can redirect to another page from controller in Zend framework?
$this->_redirect('/dashboard/page');

Q 17. How to get variable value from getting in Zend framework?
$pageID = $this->getRequest()->getParam('pageID');

Q 18. In which file we can configuration in Zend framework?
We can set the config in an application.ini file which is located in application/configs/application.ini.

Q 19. What is routing in zend in Zend framework?
It's an act to match a request to a given controller. Routing will examine the request URI and will attempt to match the URI path segment against the provided constraints.

Q 20. What is the purpose of autoloader in Zend Framework?
The Zend_Loader_Autoloader or autoloader has introduced a comprehensive autoloading solution to the Zend framework. It provides an accurate namespace autoloader and allows registering arbitrary callbacks as autoloaders.

Q 21. Explain Authorization and Authentication in Zend Framework?

Authorization    -  Authentication

1.    It's a process to determine the access permissions of users to resources. The Zend_Acl component handles this task.    It's the process to decide whether to allow or not entity access or perform operations upon. The Zend\Authentication handles the task.

Q 22. How to create an object of Model in Zend Framework?
$pageObj = new Application_Model_Pages();

Q 23. How to create a Model file in zend framework?


class Application_Model_Pages extends Zend_Db_Table_Abstract {
   protected $_name = "pages";
   protected $_primary = "id";
}

Q 24. Does Zend support PHP 4? Explain.
No. Zend was built to use all of the object-oriented features of PHP 5 and take benefits of significant performance and security enhancements.

Q  25. Explain the difference between Zend 2 & Zend 3.

Zend 2 vs Zend 3

1.    Doesn't support backward compatibility. -    Supports backward compatibility.
2.    Components are stored in a single GIT repository.    - Components are stored in multiple GIT repositories.
3.    No availability of component installer.    - Introduction of the component installer.
4.    Average ServiceManager and EventManager Performance. -    Improved ServiceManager and EventManager Performance.

Q 26. What are the advantages of Zend framework 3? Explain.
Zend framework 3 supports PHP 7 which was released with various improvements for developers.
The improved modular approach through separation of concerns and decoupling of packages.
Improved project documentation.
Introduction of Microframework.

Q 27. How to Install Zend 2 using composer?
$ composer require zendframework/zend-mvc

Q 28. What is the difference between Zend Framework and Laravel?

Zend Framework    Vs  Laravel

1.    It's architecture development principle is built on convention over configuration.    - Its architecture development principle is built on configuration over convention.
2.    It supports database such as SQLite, MySQL, PostgreSQL, Redis, and MongoDB.    - It supports database such as MariaDB, IBM DB2, Oracle and Microsoft SQL Server 2012.
3.    No iOS development support.    - Supports iOS development.

Q 29. How to Change layout for module level in Zend Framework 2?
Open the module.config.php of the module and its path is module\{module}\config\module.config.php
Add/Update given code in the view_manager array
'template_map' => array(
   'layout/layout' => __DIR__ . '/../view/layout/layout.phtml', //Setup the layout file here
   'error/404' => __DIR__ . '/../view/error/404.phtml', //Setup the error from here
),

Q 30. How we can add custom view helpers to Zend Framework 2?
To create custom view helpers to Zend framework 2, follow these steps:

Create a helper under the src directory. In this case, we name it Testhelper.
Build Testhelper content to:
namespace Test\View\Helper;

use Zend\View\Helper\AbstractHelper;

class Testhelper extends AbstractHelper

{

public function __invoke($str, $find)

{

if (! is_string($str)){

return 'must be string';

 }

if (strpos($str, $find) === false){

return 'not found';

 }

return 'found';

 }

}

Now register it in Module.php
Call it in the view
echo $this->test_helper("me","e");



ADVERTISEMENT