PHP and Zend Framework
http://pankaj-kumar2010.blogspot.in/
This is a link for multiple authentication in zend frameowork
https://github.com/thebestsolution/ZendMultipleAuthentications
ZEND FRAMEWORK INTERVIEW QUESTION
This is a link for multiple authentication in zend frameowork
Zend login with Facebook, Twitter and Google
https://github.com/thebestsolution/ZendMultipleAuthentications
ZEND FRAMEWORK INTERVIEW QUESTION
1) Is ZF a component library or a framework?
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. It’s a testament to the use-at-will architecture of Zend Framework that the tooling component itself can be used standalone.
2) What is autoloader?
Autoloader is function that load all the object on start up.
Autoloader is function that load all the object on start up.
3) What is use of Zend front controller?
Routing and dispatching is managed in the front controller. It collects all the request from the server and handles it.
Routing and dispatching is managed in the front controller. It collects all the request from the server and handles it.
4) What is the use of Bootstrap?
Apart from index if we want to do any extra configuration regarding database and other things that is done within bootstrap.
Apart from index if we want to do any extra configuration regarding database and other things that is done within bootstrap.
5) Zend auth
It is used to authenticate user, for example like admin, general etc.
It is used to authenticate user, for example like admin, general etc.
6) Zend Acl
Based on the zend authentication it allows the user to access certain actions.
Based on the zend authentication it allows the user to access certain actions.
7) How do u set Module name, Controller name, and Action name in Zend framework?
a) $request->setModuleName(‘front’);
b) $request->setControllerName(‘address’);
c) $request->setActionName(‘addresslist’);
a) $request->setModuleName(‘front’);
b) $request->setControllerName(‘address’);
c) $request->setActionName(‘addresslist’);
8) Configuration in Zend Framework, application.ini file?
Configuration can be done in application.ini file in Zend framework. This file in the path application/configs/application.ini.
Configuration can be done in application.ini file in Zend framework. This file in the path application/configs/application.ini.
9) Checking whether form posted or not in Zend framework?
$request = $this->getRequest();
$_GET = $request->getParams();
$_POST = $request->getPost();
$request = $this->getRequest();
$_GET = $request->getParams();
$_POST = $request->getPost();
10) Does Zend Framework support PHP 4?
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.
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.
11) Fetch last inserted id, fetch all record and fetch a single record.
$this->_db->lastInsertId();
$this->_db->fetchAll($sql);
$this->_db->fetchRow($sql);
$this->_db->lastInsertId();
$this->_db->fetchAll($sql);
$this->_db->fetchRow($sql);
12) Difference between Zend_Registry and Zend_Session?
The basic difference between these objects is the ‘scope’ in which they are valid:
a) Zend_Registry : request scope
b) Zend_Session : session scope
The basic difference between these objects is the ‘scope’ in which they are valid:
a) Zend_Registry : request scope
b) Zend_Session : session scope
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.
13) When do we need to disable layout?
At the time of calling AJAX to fetch we need to disable layout.
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
At the time of calling AJAX to fetch we need to disable layout.
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
14) Filters in Zend Framework with Examples?
The Zend_Filter component provides a set of commonly needed data filters. It also provides a simple filter chaining mechanism by which multiple filters may be applied to a single datum in a user-defined order.
The Zend_Filter component provides a set of commonly needed data filters. It also provides a simple filter chaining mechanism by which multiple filters may be applied to a single datum in a user-defined order.
Example:
// Add an email element
$this->addElement(‘text’, ‘email’, array(
‘label’ => ‘Your email address:’,
‘required’ => true,
‘filters’ => array(‘StringTrim’),
‘validators’ => array(
‘EmailAddress’,
)
));
Other Filters:
// Add an email element
$this->addElement(‘text’, ‘email’, array(
‘label’ => ‘Your email address:’,
‘required’ => true,
‘filters’ => array(‘StringTrim’),
‘validators’ => array(
‘EmailAddress’,
)
));
Other Filters:
Alnum – Zend_Filter_Alnum is a filter which returns only alphabetic characters and digits. All other characters are supressed.
Alpha – Zend_Filter_Alpha is a filter which returns the string $value, removing all but alphabetic characters. This filter includes an option to also allow white space characters.
Alpha – Zend_Filter_Alpha is a filter which returns the string $value, removing all but alphabetic characters. This filter includes an option to also allow white space characters.
15) Name some Important component in zend framework?
Uses of Zend_Controller
Gives the request & reponse methods by using its sub-classes.
$request = new Zend_Controller_Request_Http()
$response = new Zend_Controller_Response_Http()
Uses of Zend_Controller
Gives the request & reponse methods by using its sub-classes.
$request = new Zend_Controller_Request_Http()
$response = new Zend_Controller_Response_Http()
Uses of Zend_Date
Date related processing can be done using this component.
Date related processing can be done using this component.
Uses of Zend_File_Transfer
it provides extensive support for file uploads and downloads.
it provides extensive support for file uploads and downloads.
Uses of Zend_Db
It is used to doing database related purpose in our appication.
It is used to doing database related purpose in our appication.
Uses of Zend_Paginator
Doing the pagination in our application.
Doing the pagination in our application.
Uses of Zend_Auth
It is used to authenticate a user.
It is used to authenticate a user.
$auth = Zend_Auth::getInstance();
$results = $auth->authenticate($adapter);
if ($results->isValid()){
/* user successfully authenticate into login process */
}
$results = $auth->authenticate($adapter);
if ($results->isValid()){
/* user successfully authenticate into login process */
}
Zend_Session_Namespace
This is a simple proxy class to use API into the Zend_Session managed $_SESSION Superglobal.
This is a simple proxy class to use API into the Zend_Session managed $_SESSION Superglobal.
16) Where is the model in ZF’s MVC implementation?
The model component can vary dramatically in responsibilities and data store from one MVC application to the next.
The model component can vary dramatically in responsibilities and data store from one MVC application to the next.
17) How to call two different views from same action?
Example1:
Public function indexAction() {
If(condition)
$this->render(‘yourview.phtml’);
Else
Index.phtml;
Example1:
Public function indexAction() {
If(condition)
$this->render(‘yourview.phtml’);
Else
Index.phtml;
Example2:
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’));
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’));
18) Can we call a model in view?
Yes, you can call a model in view. Simple create the object and call the method.
Yes, you can call a model in view. Simple create the object and call the method.
19) how do u define the library path in zend ?
create directory ‘library’, and put ‘Zend’ directory in it. Your directory structure will look like this:
wwwroot
application
lib
Zend
public
index.php
application
lib
Zend
public
index.php
now you should add library to your include path. Edit index.php file:
$includePath = array();
$includePath[] = ‘.’;
$includePath[] = ‘./../application’;
$includePath[] = ‘./../library’;
$includePath[] = get_include_path();
$includePath = implode(PATH_SEPARATOR,$includePath);
set_include_path($includePath);
19) Can we rename the application folder ?
yes you can rename the application folder
$includePath[] = ‘.’;
$includePath[] = ‘./../application’;
$includePath[] = ‘./../library’;
$includePath[] = get_include_path();
$includePath = implode(PATH_SEPARATOR,$includePath);
set_include_path($includePath);
19) Can we rename the application folder ?
yes you can rename the application folder
20) Can we move the index.php file outside the public folder?
yes you can move index.php file outside the public folder.
yes you can move index.php file outside the public folder.
21) 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();?>
22) How to include css from controller and view in zend
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();?>
23) How do you protect your site from sql injection in zend when using select query?
You 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> );
$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> );
24) How can you get a module name in bootstrap file.
$router = new Zend_Controller_Router_Rewrite();
$request = new Zend_Controller_Request_Http();
$router->route($request);
$request = new Zend_Controller_Request_Http();
$router->route($request);
$moduleName = $request->getModuleName();

Comments
Post a Comment