What is Zend framework?
Zend framework is an open source PHP framework. It is object oriented and MVC web application framework.
What are the main features of Zend framework?
- It is object oriented web application framework.
- Full support MVC implementation
- Zend framework code is reused and easy write.
- Data encryption and cloud API
- Flexible URI Routing
- It supports multi databases including PostgreSQL, SQLite etc.,
- Provides RESTful API development support.
- Supports Cryptography tools and password hashing techniques.
What is autoloader?
Autoloader is function that load all the object on start up.
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.
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.
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.
What is Zend Auth?
It is used to authenticate user, for example like admin, general etc.
What is Zend Acl?
Based on the zend authentication it allows the user to access certain actions.
How Do You Set Module Name, Controller Name, And Action Name in Zend Framework?
$request->setModuleName(‘front’);
$request->setControllerName(‘address’);
$request->setActionName(‘addresslist’);
What is 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.
Checking whether form posted or not in zend framework?
$request = $this->getRequest();
$_GET = $request->getParams();
$_POST = $request->getPost();
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.
fetch last inserted id, fetch all record and fetch a single record.
$this->_db->lastInsertId();
$this->_db->fetchAll($sql);
$this->_db->fetchRow($sql);
What is the difference between zend_registry and zend_session?
The basic difference between these objects is the ‘scope’ in which they are valid:
Zend_Registry: request scope
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 prepared 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.
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);
Where is the model in ZF MVC implementation?
The model component can vary dramatically in responsibilities and data store from one MVC application to the next.
How to call two different views from same action?
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’));
Can we call a model in view?
Yes, you can call a model in view. Simple create the object and call the method.
Which version of PHP does Zend framework require?
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.
Where's the Model?
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.
How Do U Set Module Name, Controller Name, And Action Name In Zend Framework?
$request->setModuleName(‘front’);
$request->setControllerName(‘address’);
$request->setActionName(‘addresslist’);
Can we rename the application folder?
Yes, you can rename the application folder.
Can we move the index.php file outside the public folder?
Yes, you can move index.php file outside the public folder.
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:
headScript();?>
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:
headLink();?>
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>);
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);
$moduleName = $request->getModuleName();
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
Why should we use framework?
Framework is a structured system
- Source codes become more manageable
- Easy to extend features
- Rapid application development.
What is bootstrapping?
Many PHP applications funnel server requests into a single (or few) PHP source file that sets up the environment and configuration for the application, manages sessions and caching, and invokes the dispatcher for their MVC framework. They can do more, but their main job is to take care of the consistent needs of every page of a web application.
In our Blueprint for PHP Applications, we will have a core bootstrapper that receives all dynamic requests for an application and applies a template for application behavior that we can later extend. It will allow us to later customize the functionality for each unique application.
What is zend engine?
Zend Engine is used internally by PHP as a compiler and run time engine. PHP Scripts are loaded into memory and compiled into Zend opcodes.
What is zend engine in php?
Zend engine is like a virtual machine and is an open source, and is known for its role in automating the web using PHP. Zend is named after its developers Zeev and Aandi. Its reliability, performance and extensibility has a significant role in increasing the PHP’s popularity. The Zend Engine II is the heart of PHP 5. It is an open source project and freely available under BSD style license.
What is routing and how it's work?
Zend_Controller_Router_Rewrite is the standard framework router. Routing is the process of taking a URI endpoint (that part of the URI which comes after the base URL) and decomposing it into parameters to determine which module, controller, and action of that controller should receive the request. This values of the module, controller, action and other parameters are packaged into a Zend_Controller_Request_Http object which is then processed by Zend_Controller_Dispatcher_Standard. Routing occurs only once: when the request is initially received and before the first controller is dispatched.
Zend_Controller_Router_Rewrite is designed to allow for mod_rewrite-like functionality using pure PHP structures. It is very loosely based on Ruby on Rails routing and does not require any prior knowledge of webserver URL rewriting. It is designed to work with a single Apache mod_rewrite rule.
What are plugins in zend framework?
- Triggered by front controller events
- Events bookend each major process of the front controller
- Allow automating actions that apply globally
Creating Plugins:
- Extend Zend_Controller_Plugin_Abstract
- Extend one or more of the event methods.
What is MVC?
Model-View-Controller development pattern.
MVC is a software approach that separates application logic from presentation.
Model: The “stuff” you are using in the application data, – web services, feeds.
View: The display returned to the user.
Controller: Manages the request environment, and determines what happens.
What are the features of MVC in zend framework?
Declare custom routing rules Not limited to “controller/action/param” format
Optional Controller Plugins, Action Helpers, and View Helpers ErrorHandler plugin handles exceptions, 404 errors, etc. FlashMessenger, Redirector, ViewRenderer helpers Output common HTML elements in views
Extensible interfaces write your own plugins and helpers.
How can I customize the appearance of forms generated by zend_form?
You’re probably looking for decorators. All forms and form elements in Zend_Form use decorators to render their output.
Why does the zend framework project have a cla at all?
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.
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.
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.
can you explain about Zend Framework?
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 Strike iron and ProgrammableWeb.
What do I have to do to contribute to zend framework?
The only requirement for contributing to Zend Framework is submitting our either our Individual Contributors License Agreement ((LA) or our corporate CLA. Once you have signed the CL you can visit our contributors wiki to get started.
We strongly recommend you read and understand the terms of our New BSD License-style license, under which all parts of Zend Framework are licensed, all contributions inclusive.
What version of PHP is zend framework 2 based on?
Zend Framework 2 Is based on PHP 5.3. We expect to add support For PHP 5.4 once it starts to be adopted by the PHP community.
Does this mean that zend framework 1 is about to be end-of-lifed?
Definitely not! We currently plan to fully support Zend Framework I until at least early 20 14, including maintenance and security updates.
What new features will find in zend framework 2?
Some highlights:
- An entirely re-written event-driven MVC layer
- Dependency injection support
- A powerful module management system
- An EventManager, for writing event-driven systems, as well as for creating cut points in your software for introducing cross-cutting concerns.
- A new view layer, architected around analyzing the request and generating a suitable response, be it plain old HTML, or Atom feeds or JSON.
What services are available from zend technologies for zend framework?
Zend Technologies provides a comprehensive set of services for Zend Framework, including:
- Support
- Training
- Consulting
- Certification
What is Lucene?
Lucene is a high-performance, full-featured text search engine that utilizes an open, binary format for storing search indexes and a standardized query format for querying against the indexes. Lucene was originally written in java as part of the Apache project. Zend_Search_Lucene is a PHP implementation that provides full binary compatibility with Java Lucene.
How can I debug zend_date in a simple way?
When you think that you are getting wrong output from Zend_Date then it’s often needed to see what Zend_Date really uses internally.
Well., a var_dump of Zend_Date is not really helpful,l but you could simply use getIso(). This format has all date inform actions
available:
$date- >getIso(); I/could return 2009-10-21 T!5:OO:O2O 1:00’
Note that using toString() and outputting only parts of a date does not show all needed information’s. There could be a wrong used timezone, or a DST change which is suppressed by toString() but shown with getIso().
How can I detect if an optional file has been uploaded?
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:
- isUploaded which returns a boolean
- Use getFileName which returns null in this case (note that you must use the latest release for this behavior)
- getFileInfo which will have an empty ‘file’ key and the flag ‘isUploaded’ set to false
How can I use the same locale everywhere?
With ZF 1.7 an application wide locale is supported. You can do the following in your bootstrap file:
$locale = new Zend_Locale(’en’);
Zend_Registry::set(’Zend_Locale $locaIe;
From now on, all locale aware components will use your locale object stored in the registry as long as you don’t give another one manually.