FAQ ZFv1

Frequently Asked Questions About ZF1
What is the difference between Zend_Auth and Zend_Acl?

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.

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 (CLA) or our corporate CLA. Once you have signed the CLA, 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 is this "username" I have to submit with my CLA, and why do I have to submit it?

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.

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 should I know about the Zend Framework CLA before submitting it?

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.

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.

I am a minor (under 18 years of age). Who should sign my CLA?

CLA's for contributors under the age of 18 should be signed by both the contributor and the contributor's legal guardian.

What kind of contribution requires that I submit a CLA? And what kind of contribution can I make without submitting a CLA?

You must sign a CLA before Zend Framework can accept any content that constitutes intellectual property. This includes anything that could carry a copyright or be patented. This includes code, patches, tests, documentation, and even proposals submitted on ourwiki. You do not need to submit a CLA to report a bug or make a feature request in our issue tracker, or to ask a question on the mailing lists. You can include code in emails to the mailing lists to illustrate your words, but your code cannot be incorporated into Zend Framework unless it is submitted under the terms of the CLA.

I've submitted the CLA, now how can I get started contributing to Zend Framework?

There are lots of ways to contribute to Zend Framework. Many major features are contributed to ZF through our proposal process. Most code contributors also commit bug fixes and tests. Another valuable form of contribution is manual translation and other forms of documentation. Contributors may also invest their time in updating the wiki or adding, commenting on, and voting on issues in our issue tracker. No matter how you plan to contribute, the best place to get started is our contributor guide.

Where is Zend Framework's ORM implementation?

Object Relational Maps (ORMs) are practically frameworks on their own, and consist of data access, repositories, identity maps, and many more components. We feel it makes sense to let ORM experts write such software, and allow integrating these solutions in Zend Framework. Popular projects include Doctrine and Propel.

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?

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 use Zend_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'),
    ));
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.

How can I add extra HTML (such as a link) to my form element?

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(
    '<strong>This contains HTML that will actually be parsed by the browser, not escaped</strong>'
);
Why can't Zend_Form render my File element without errors?

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')
));
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:

  • 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
Which version of PHP does Zend Framework require?

Zend Framework requires PHP 5.2.11 and up. Some Zend Framework components may work with earlier versions of PHP, but these components are tested and supported only on 5.2.11 and up. See the requirements appendix for more information.

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.

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.

>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 ZF community has not defined a model interface, class, or other formalism simply because we wanted to avoid introducing limitations without significant added value.

Is ZF a component library or a framework?

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.

How can I make all i18n-aware components aware of my Zend_Translate object?

A variety of components are translation aware (i.e., accept Zend_Translate objects), including:

  • Zend_View_Helper_Translate
  • Zend_Validate_*
  • Zend_Form

To have them all use the same Zend_Translate instance, simply place it in the registry with the key "Zend_Translate":

Zend_Registry::set('Zend_Translate', $translate);
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', $locale);

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.

Why are my dates formatted wrong? Why do I get the false year value?

When using own formats in your code you could come to a situation where you get for example 29.12.2009, but you expected to get 29.12.2008.

There is one year difference: 2009 instead of 2008. You should use the lower cased year constant. See this example:

$date->toString('dd.MM.yyyy');

Note the lower cased "y" which makes the difference and outputs the real year.

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 helpfull, but you could simply use getIso(). This format has all date informations available:

$date->getIso(); // could return '2009-10-21T15:00:02+01:00'

Note that using toString() and outputting only parts of a date does not show all needed informations. There could be a wrong used timezone, or a DST change which is suppressed by toString() but shown with getIso().

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 can I retrieve the view object within a plugin or arbitrary code?

ZF uses an action helper called the ViewRenderer by default. This action helper instantiates and stores a Zend_View object, which is subsequently injected into other objects. The view object is stored in the ViewRenderer's view property. You can get the ViewRenderer instance, and thereby the view instance, with the Action Helper broker:

$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer';
$view = $viewRenderer->view;

However, if you're accessing the view early in the dispatch process- before an action is actually dispatched, for example- then you may need to initialize the view first:

if (!isset($viewRenderer->view)) {
    $viewRenderer->initView();
}
$view = $viewRenderer->view;

If you are using and have already initialized Zend_Layout, you can access the view object much more succinctly:

$view = Zend_Layout::getMvcInstance()->getView();

This proxies to the ViewRenderer and performs all of the steps above for you.

I'm using the ContextSwitch or AjaxContext view helper and receiving an exception indicating the error.ajax.phtml view script is missing; what am I doing wrong?"

ContextSwitch makes the assumptions that (a) you are not calling _forward() and (b) that your application code will not throw an exception. If you see the above error, your code is throwing an exception - but the context is still in play, and the ViewRenderer is simply trying to load a view script for the current context from the ErrorController.

The easiest way to fix the situation is to have the ErrorController::errorAction() redefine the view script suffix, as follows:

class ErrorController extends Zend_Controller_Action
{
    public function errorAction()
    {
        $this->_helper->viewRenderer->setViewSuffix('phtml');
        // ...
    }
}
I'm using Apache, and passing urlencoded slashes via $_GET or as URL parameters – and I'm getting 404s!

Apache by default disallows urlencoded slashes (i.e., "%2F") in URL path parts or the query string. This feature can be disabled by enabling the "AllowEncodedSlashes" directive:

AllowEncodedSlashes On

However, this directive must be set at either a server-wide (httpd.conf) or virtual-host level.

For more information, read the AllowEncodedSlashes documentation.

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.

Can I use Zend_Search_Lucene to search my Java Lucene-generated indexes?

Yes! In fact, the Zend Framework site uses Zend_Search_Lucene with indexes created by our Java developer tools to provide site-wide search.

Can I use tools such as Luke with indexes generated by Zend_Search_Lucene?

Yes! We regularly use Luke to inspect our Zend_Search_Lucene-generated indexes for development and diagnosis purposes.

Why are client libraries for web services such as Akismet, Amazon, Audioscrobbler, Delicious, Flickr, Nirvanix, Simpy, StrikeIron, and Yahoo! part of the Zend Framework standard library?

Zend Framework has been designed to solve the most common problems in web application development. Web services are a big part of today's web development environment. So much so that many of our users consume our web service clients for services such as Amazon ECS, Akismet, and ReCaptcha before adopting more infrastructure-oriented components such as Zend_Registry and Zend_Log. Because these web services play such an important role in today's web applications, we consider them 'first-class citizens' in ZF.

I've tried sending an 'unsubscribe' mail to all ZF mailing lists, but I'm still getting messages from these lists. What do I have to do to stop getting these mails?

There is an 'fw-all' list that aggregates all other lists besides fw-announce, fw-general, fw-docs, and fw-svn. Please try sending an email to fw-all-subscribe@lists.zend.com to make sure you're not subscribed to this list. Also, please ensure that you mail all unsubscribe requests from the account that you subscribed with. You may be receiving list traffic on a different account if you have set up a mail forward from the original subscription account.

Where can I reset my password?

http://framework.zend.com/crowd

What services are available from Zend Technologies for Zend Framework?

Zend Technologies provides a comprehensive set of services for Zend Framework, including: