Zend Framework 1.10.7 Released

No Comments

Zend Framework 1.10.7 was release on July 28th, 2010. This is the seventh maintenance release in the 1.10 series, and includes numerous bugfixes (around 60). No new functionality was added, but users of Zend_Service_Twitter should upgrade to 1.10.6 or 1.10.7 as soon as possible, as Twitter is soon changing their API to force OAuth authentication, which these two releases will use by default.

All other users are encouraged to upgrade to the newest versions to reap the benefits of the bug fixes.

For a full list of changes, see the Zend Framework 1.10.7 changelog.

Download the latest version of the Zend Framework.

Decompressing Archive Files Using the Zend Framework

1 Comment

Working with archives such as Zip, Tar, and Gz in PHP can be cumbersome at best and nightmarish at worst. The native Zip extension can be unpredictable and difficult to work with…but luckily, Zend to the rescue!

The Zend Framework has an extensive library of filter components that can modify and format your data in a dizzying array of different ways, including working with archives. The component we are interested is Zend_Filter_Decompress.

To decompress an archive file, we simply create an instance of the Zend_Filter_Decompress class, tell it which type of archive we are working with and where to save the decompressed files, then call the object’s filter() method, passing in the path to the archive file.

1 //Create filter object
2 $filter = new Zend_Filter_Decompress(array(
3 'adapter' => 'Zip', //Or 'Tar', or 'Gz'
4 'options' => array(
5 'target' => '/path/to/output/directory'
6 )
7 ));
8
9 $filter->filter('/path/to/archive/file.zip');

That’s all there is to it. If you look at the contents of your output directory, you’ll see the contents of your archive file. Compressing files into an archive is slightly more involved (but still simplified by the Zend Framework!) and will be covered in a future article.

Autoloading with the Zend Framework

No Comments

By adding autoloading to your application, you can make your code cleaner, save time, and even make your application run faster. The Zend Framework makes autoloading very easy, for both projects using Zend_Application or Zend’s MVC components and those that simply use Zend components to supplement their existing code.

Benefits

Autoloading is a feature of PHP that allows files to be (automatically) included at the last minute. Traditionally, to include another file you would use something like:

1 require_once '/path/to/somefile.php';
2 include '/path/to/includefile.php';

which works fine, but will break down on large scale applications with high traffic levels. require_once and include_once are both computationally expensive, meaning that you want to avoid them if you are concerned about performance (and who isn’t?), especially now that Google is factoring your site’s speed into their rankings.

Autoloading removes the need for these types of calls (and performance degradations) by handing off all loading of files to PHP itself. This is often called ‘lazy loading’…all requires and includes are done at the last possible minute, conserving resources and avoiding the expensive require_once and include_once calls.

NOTE: Autoloading is only applicable to loading classes on the fly. Files that include only function definitions or configurations cannot be autoloaded.

Getting Started

Autoloading with Zend is incredibly simple. Just place the following code into one of your application’s early running boot-up files. By simply adding this code, Zend will attempt to autoload all of your classes (assuming they follow a logical and consistent naming structure, discussed below). Of course you can replace MyLibrary with whatever name you desire.

1 //Must still do one require_once, to load the Autoloader class itself
2 require_once 'Zend/Loader/Autoloader.php';
3
4 $autoloader = Zend_Loader_Autoloader::getInstance();
5 $autoloader->registerNamespace('MyLibrary_');

It really is as simple as that. By calling the registerNamespace() method of the Zend_Loader_Autoloader class, Zend sets up everything you need to start autoloading. The above code assumes two things:

  1. You have a set of PHP classes that follow a conventional naming structure…the same naming structure of the Zend Framework itself. For example, if your application uses a class called MyLibrary_Users_Guest, your file would need to be named MyLibrary/Users/Guest.php.
  2. Your classes are on the PHP include path.

NOTE: The above code will also setup autoloading for the Zend Framework, so you no longer need to include the files yourself. For example, immediately after the above code, without any include statements, you can call any part of the Zend Framework (and your MyLibrary classes). For example, $date = new Zend_Date();

Extra Credit

The Zend Framework, in all it’s powerful, flexible glory, has a weakness…it is somewhat slow. The blame lies in several areas, including but not limited to the number of files that go into the Framework (all the require_once‘s that must be executed for any given component) and the complexities of the code itself (which gives the Framework it’s tremendous power and flexibility).

Since applications can use bits and pieces of the Zend Framework without having autoloading setup, the Zend Framework must contain a require_once call for every dependent file. This can get slow, especially at high load levels. To increase performance, you can perform a Search and Replace in your favorite code editor and comment out all the require_once calls inside the Zend directory. The ecommerce software Magento is based on the Zend Framework and includes the Framework with all require_once‘s removed in this way.

Easily Format and Output Currency Values with Zend Framework

No Comments

Currency can be a pain. Different currency symbols, different formats, rounding, etc, etc. Zend makes it easy!

At it’s simplest, you can output formatted currency values as follows:

$currency = new Zend_Currency();
//prints $1000.00 if user is in US
echo $currency->toCurrency(1000);

But Zend_Currency can do so much more than that. For example, it is compatible with Zend’s localization components, meaning that you can setup a Zend_Locale object once in your application, and Zend_Currency sees it and automatically performs the necessary formatting and conversions. For example, suppose you have an early running resource in your Zend MVC application that determines the appropriate locale for the application. In your bootstrap or resource file, you would have something like this:

//Detect user locale automatically
$locale = new Zend_Locale();

//Or pass a locale to use that locale
//$locale = new Zend_Locale('en_US');

//Save to registry
Zend_Registry::set('Zend_Locale', $locale);

Once you save the Zend_Locale object to the registry (using the key ‘Zend_Locale‘), all locale aware components of the Zend Framework will automatically use that locale for any conversions and translations.

The defaults will be sufficient for most uses, but many options are available to help you customize how Zend_Currency operates. For a full listing of options, please see the Zend Framework reference guide.

Calculating with Currencies

Zend_Currency allows you to do many calculation and comparisons with currencies, such as addition, subtraction, multiply, divide, modulo, and equality operations such as equals, greater than and less than.

For example, suppose we have a currency object with a starting value of $1000. The easiest way to perform operations on our object is to use Zend_Currency‘s built in functions, like so:

$currency = new Zend_Currency(array('value' => 1000));

//Add $100 to the currency
$currency->add(100);

//Subtract $100 from the currency
$currency->sub(100);

In this way, you can easily perform arithmetic operations on your currency objects, without the need for first retrieving the value in the currency object, then performing the operation on the value, which would then be a number rather than a Zend_Currency object, which would remove all the handy formatting and conversion possibilities.

Exchange Rates

Zend Framework does not supply a way to convert currencies out of the box, but it does make quite easy to do so. Basically, you need to write a simple class that will talk to a conversion rate web service and then return the exchange rate to Zend_Currency, which handles all the math itself. For more information, please see the Zend Framework reference guide on exchange rates.

Performance

For most websites, performance will not be much of an issue as far as the Zend Framework is concerned. On websites that get a decent amount of traffic, however, the complicated nature of the Zend Framework can lead to decreased performance. Luckily, the authors of ZF have thoughtfully made many components caching enabled, meaning you can tell them to use a cache and they will automatically speed themselves up. Zend_Currency can use a cache object to increase performance. To use caching in Zend_Currency, simple set a cache object like so:

Zend_Currency::setCache($cache);

NOTE: the $cache object must be an instance of Zend_Cache. For more information on how to create cache objects with ZF, see How to use Memcache with the Zend Framework.

Registering Amazon S3 Stream Wrapper in Zend Framework

No Comments

Amazon’s S3 (Simple Storage Service) is an unlimited, reliable, and affordable storage solution for storing any type and amount of data. Some example uses are:

* User uploaded photos and documents
* Video
* Backups
* Log file storage
* Any other large amount of data that can be burdensome to store locally

Amazon S3 can provide peace of mind and significant cost savings to organizations of all sizes. But how do you get your data in and out? The easiest way is probably by registering a stream wrapper. A stream wrapper is simply a way for your code to interact with various sources of data (streams), handling all the technical details of reading and writing for you.

Of course, to use Amazon’s S3, you’ll need an account. Head over to aws.amazon.com and get signed up, and bring back your Access Key and Secret Access Key.

Let’s see some code:

$s3 = new Zend_Service_Amazon_S3($awsKey, $awsSecretKey);
$s3->registerStreamWrapper();

And that’s it! Now to use S3, you can use PHP’s file functions you’re already used to, such as file(), file_put_contents(), file_get_contents(), mkdir(), and many others, in the following way:

$contents = file_get_contents('s3://mybucket/myfilename.txt');

$size = filesize('s3://mybucket/myfilename.txt');

//Create new BUCKET (not directory)
mkdir('s3://mynewbucket');

Note the use of the ‘s3://’ prefix…This tells PHP to use the S3 stream wrapper we just registered, instead of accessing the files normally.

Nearly all of PHP’s file and directory functions will operate seamlessly with the S3 wrapper.

NOTE: all directory functions such as mkdir and is_dir operate on buckets rather than actual directories. In S3, you have buckets and files…not directories. You can mimic directory structure by naming your files such as ‘/pseudofolder/myfile.txt’, though.

The most useful way to use S3 is to stick the above code into an early running plugin or resource (on Zend MVC applications) and then save the $s3 object into the registry for application wide use.

Good luck and have fun!

Configure Nginx for Use with the Zend Framework MVC

10 Comments

Nginx is a powerful HTTP server that is quickly gaining widespread usage on the internet, due to its flexibility and performance benefits. I highly recommend using Nginx over Apache for all new web applications. I use Nginx on all my own sites, and am very pleased with it.

To run an MVC (Model – View – Controller) application with the Zend Framework, your HTTP server must be properly configured in order to correctly rewrite requests. This is how it can be accomplished with Nginx.

In the ‘sites-enabled’ directory for Nginx (usually at ‘/etc/nginx/sites-enabled’ on Unix), you’ll need to create a configuration file for your site. Name this file ‘mysite‘ (use your real site name) with no extension. Now open up the file, and let’s tell Nginx what to do.

Contents of ‘mysite‘. Be sure to replace mysite.com (and all paths) with the correct values:

server {
	listen 80;
	server_name mysite.com;
	root /var/www/mysite/public;
	index /index.php;

	location / {
		if (!-f $request_filename) {
			rewrite ^(.*)$ /index.php?q=$1 last;
			break;
		}
	}

	location ~* ^.+.(css|js|jpeg|jpg|gif|png|ico) {
		expires 30d;
	}

	location ~ .(php|phtml)$ {
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index /index.php;
		fastcgi_param SCRIPT_FILENAME /var/www/mysite/public$fastcgi_script_name;

		include /etc/nginx/fastcgi_params;
	}
}

What this does is tells Nginx to listen for requests to ‘mysite.com’, and rewrite then to /index.php, so that Zend can take care of them from there.

Running PHP with Nginx is slightly more involved than running it with Apache. This article assumes you have PHP configured to run with FastCGI, if not, please see this article on running PHP with Nginx.

Where is the Best Place to Install the Zend Framework?

1 Comment

Choosing where you install the Zend Framework is one of the more important decisions you’ll make in your application’s life cycle. Knowing the pro’s and con’s of the different options will allow you to make the most informed (and correct) decision when installing it.

In general there are 3 basic options to consider when choosing where to install the Zend Framework, each with strengths and weaknesses. Which one is right for you depends on your individual situation.

Using the Repositories

This is perhaps the easiest option for installing the Zend Framework. If your server runs on Unix/Linux, the Zend Framework is part of the standard repositories and can be installed with a command similar to the following:

sudo apt-get install zend-framework

A recent version of the Zend Framework will be installed, and made available to your PHP include path, making this an extremely simple way to get started. However, this method has several drawbacks, including:

  • The repo version is not the latest release, so you won’t have access to the newest features
  • If you don’t have shell access to your server, you must rely on others to install and update the Framework
  • If you have several sites using the Zend Framework and you upgrade to a newer release, there is a possibility that some parts of your sites will not be compatible with the new version, effectively breaking those sites all at once, until you can track down all the bugs.

Using the repositories for installation of the Zend Framework is a good beginners strategy, and indeed very easy and fast. If you plan on running anything but the most trivial sites, however, this is not the recommended method.

Installation Available in the Include Path

The second method involves downloading the latest release of the Zend Framework and uploading it to your server in a location accessible to all sites that you run. This means that you upload it to one place, make it available with the include_path directive in php.ini, and away you go. This is similar to the first method in that all websites share the same installation, and to upgrade the Zend Framework, you only need to upgrade in one place.

Using a shared installation approach has advantages over using repositories, such as:

  • You are no longer reliant on system administrators to install the Zend Framework and keep it up to date
  • You control the specific version of the Zend Framework in use. If you want the latest version, you can easily install it by downloading it from Zend

This is a good solution for a small number of simple, non critical websites. However, if you run mission critical applications, or a large number of sites, there is still a better way.

Individual Installations for Each Application

The third, and most flexible, place to install the Zend Framework is individually with every application that uses it. This may seem like excessive overhead, but it has some serious advantages:

  • Control the version of the Zend Framework used by each application, individually. This is extremely important when dealing with upgrades, as newer versions of the Zend Framework may not be 100% compatible with your existing code. It is much better to upgrade one site at a time, searching out and fixing all the bugs. You may find that certain sites don’t need an upgrade at all
  • The site becomes self contained and less reliant on the environment it is run in. If you migrate servers, for example, your sites will ‘just work‘ without the need to install the Zend Framework in the same manner and location that it was previously installed in (in a shared installation approach). Instead, the Zend Framework is contained entirely within the site, and will always be available to it

Generally, the ‘library‘ folder (outside of the public directory) is the best place for the Zend Framework.

Yes the Zend Framework is, in theory, backward compatible with previous versions. This is not always the case, however. The smallest changes to its code can wreak havok on your existing sites, so it is preferrable to upgrade one site at a time, if needed at all. This allows you to setup individual testing environments, fix all the bugs, then make the newest version live on a site by site basis, without risking breaking all of your sites in ways you won’t find out about until 3 months down the road.

Conclusion

Where to install the Zend Framework is a question largely dependent on your needs and the sites you run. Taking a moment to consider the available options will pay off down the road, especially when you’d like to upgrade to a newer version.

How to use a Database for Session Handling in the Zend Framework

1 Comment

For many sites, session handling does not get a second thought; it happens automatically and behind the scenes with no intervention from the developer. This default method of operation is fine for most websites with low amounts of traffic. However, by default, PHP stores session information in flat files in the file system, which means that the system is not as performant as it can be, and if you have a large number of open sessions at one time, you may reach hard operating system limits on how many files can reliably exist in one directory at a time.

A better solution

Think Facebook is using flat files to store session info for the millions of users online at any given moment? Think again.

If your site is growing and slowing, improving how sessions are handled can bring back life to your site. There are several ways to do this, each with its own pros and cons, but in this article we will use a reliable, performant, and easy to setup solution that probably already exists on your server…the database.

Databases aren’t just for content

Databases can be significantly more performant than flat files, and many more sessions can be handled at one time, making them an ideal solution for sites looking to boost performance.

Fortunately, PHP provides developers with the ability to setup custom session handlers, using any type of backend. The downside is that setting this up can be a bit involved and complicated. Enter Zend_Session.

Custom session handling made easy

The Zend_Session component of the Zend Framework makes custom session handling a breeze. What’s even better, is that the Zend Framework provides a built in class for using a database as a session handler: Zend_Session_SaveHandler_DbTable. To get started, we first need to create a table to hold our sessions:

CREATE TABLE `session` (
	`id` char(32),
	`modified` int,
	`lifetime` int,
	`data` text,
	PRIMARY KEY (`id`)
);

Once your table has been created, we must make sure a database connection is available for the Zend_Session component to use. If you already have a connection to the appropriate database in your application, you can skip this step.

$db = Zend_Db::factory('Pdo_Mysql', array(
	'host'        	=> 'example.com',
	'username'    	=> 'dbuser',
	'password'    	=> '******',
	'dbname'    	=> 'dbname')
);

Now that we have a database object setup, we need to setup a simple configuration for the Zend_Session_SaveHandler to use:

$config = array(
	'name'           => 'session',
	'primary'        => 'id',
	'modifiedColumn' => 'modified',
	'dataColumn'     => 'data',
	'lifetimeColumn' => 'lifetime',
	'db'             => $db
);

Note: You may also use an instance of Zend_Config as your config object if you wish

Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));

//start your session
Zend_Session::start();

Note: You MUST set up the save handler before the session begins — before calling Zend_Session::start(), or accessing any $_SESSION variables.

And that’s it! Place the above code in an early running part of your application, and any subsequent calls to Zend_Session_Namespace or $_SESSION variables directly will use your database instead of flat files. Garbage collection (the removal of old records) is done automatically for you.

Conclusion

By following these simple steps, you can improve the performance and stability of your web application by storing session data in a reliable and performant container, the database. Any database system can be used, from Mysql to Postgresql, to Sqlite, and all will increase the reliability and speed of your site.

Improving session handling with the Zend Framework is so simple that it should be one of the first things you do when creating a new site or application.

Zend Framework 1.8.0 Released

No Comments

The 1.8.0 branch of the Zend Framework, the first in the 1.8 series, was recently released and features some new tools for Rapid Application Development and Cloud Computing, and over 200 bugfixes.

Rapid Application Development

One feature that has always been lacking in the Zend Framework was tools for rapid application development. The new Zend_Tool component aims to fill this gap by providing a command line interface to easily create project trees, controllers, actions, models, and more. Previously, to create a new controller, one would have to create both the controller class and associated view scripts manually; now, a command line tool can easily create both of these for you.

For example, creating a new controller is now as simple as:

zf.sh create controller [controller-name]

For more information on using this exciting new feature, check out the Zend Framework Quickstart.

Cloud Computing

The Zend Framework now integrates closely with Amazon’s Simple Storage Service (S3) and the Elastic Compute Cloud (E2) using the Zend_Service_Amazon_S3 and Zend_Service_Amazon_E2 components, respectively.

These are exciting tools for web applications that need distributed storage and/or variable amounts of computing power at affordable prices.

Other Contributions of Note

Zend Framework 1.8.0 also contains numerous other contributions, the most notable being:

  • Zend_Application – Designed to encompass an entire application in an object oriented way to give access to app-wide resources. Especially useful if you have specialty scripts (like cronjobs) that only need access to certain parts of the app, say the database layer
  • Zend_CodeGenerator – Object oriented way to generate source code
  • Zend_Navigation – A component to handle the creation of navigation menus on a site
  • Zend_Tag_Cloud – Generate tag clouds based on lists of tags

Zend Framework 1.8.0 marks a large step forward in the framework’s life cycle, and makes it even more powerful and easy to use. For more information, view the official 1.8.0 announcement and be sure to download Zend Framework 1.8.

Pagination with PHP and the Zend Framework

1 Comment

The pagination (breaking into multiple pages) of collections of data is a critical user interface element of any website the provides search or other lists of content. Paginating your data prevents the user from being overwhelmed with unmanageable amounts of content and makes your site much more professional. The Zend Framework makes this common and necessary task as simple as it can be.

The simplest and probably most common collection of data that will need pagination is a set of rows returned from a database. If you are using the Zend_Db components for interacting with your database, paginating then is extremely simple. Even if you are not using Zend’s database components, you can paginate simple arrays with Zend_Paginator.

Fundamentals

Zend’s paginate component is centered around adapters, which provide access to the data, and pagination controls, which render the ‘Previous’, ‘Next’, and page number links.

The built in adapters are usually sufficient for most cases, but as with everything in Zend, you can always write your own. The built in adapters are as follows:

  • Array – uses a simple PHP array.
  • DbSelect - uses a Zend_Db_Select instance that returns an array
  • DbTableSelect - uses a Zend_Db_Table_Select instance
  • Iterator – implements the Iterator interface

The most common use case is the DbTableSelect adapter, which we’ll discuss in this article.

Once you have collected your data, usually in the form of a Zend_Db_Table_Rowset object (as the result of a database query), or an array, you’ll need to tell the Zend_Paginator object a few things, such as how many items per page you’d like, and what the current page is. Once you’ve set these options, all that’s left is rendering the items, which is done very conveniently, as demonstrated later, and rendering your paginator control, which is also very easy. So suppose we want to show a paginated list of articles in a database. First, simply select the objects:

Collecting Data

//Select rows from the database, don't worry about limits and offsets in your query. The DbTableSelect will automatically add these in once you tell it which page and how many items per page you'd like
$select = $articleTable->select()->order('created DESC');

Setting up an Adapter

The preceding code assumes you’ve already setup a Zend_Db_Table_Abstract table object in the var $articleTable. Then simply pass the $select object to a new Zend_Paginator_Adapter_DbTableSelect object, which in turn is passed to a new Zend_Paginator object, like this:

//Setup the adapter object$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
//And setup the actual paginator object$paginator = new Zend_Paginator($adapter);

Configuration

Now we’re ready to configure our paginator:

//Figure out which page we want
$page = ($_GET['page']) ? $_GET['page'] : 1; $paginator->setCurrentPageNumber($page);
//Set the number of items per page
$paginator->setItemCountPerPage(15);

Rendering Data

Now all that’s left is rendering. Fortunately, Zend_Paginator uses the IteratorAggregate interface, so you can count() and loop over the $paginator object directly:

if(count($paginator)){
	//This foreach only loops over the items on the current page
	foreach($paginator as $item){
		//Since each item is a Zend_Db_Table_Row_Abstract object, we can call any column name in that table
		echo $item->title;
	}
} else{
	echo 'No articles found';
}

Rendering the Pagination Control

Perhaps the most complicated part of paginating data with the Zend Framework is rendering the pagination control, which is simply the links to the various pages that normally appear at the bottom of the page.

There are several different types of pagination controls:

  • All – Returns every page. Only useful for small data collections, such as a short, paginated article
  • Elastic – A Google-like scrolling style that expands and contracts as a user scrolls through the pages. It starts out very short on the first page, and expands as a user advances
  • Jumping – As users scroll through, the page number advances to the end of a given range, then starts again at the beginning of the new range
  • Sliding – A Yahoo!-like scrolling style that positions the current page number in the center of the page range, or as close as possible. This is the default style

The most important concept to understand when working with pagination controls is that of ‘ranges‘. The range is simply the amount of pages that are currently displayed to the user, for example pages 2-11 may be visible in the control, with buttons for ‘Next’, ‘Previous’, ‘Last’, and ‘First’.

Depending on the type of pagination you decide on, Zend_Paginate will automatically calculate the appropriate range to be displayed.

The easiest way to render the pagination control is to set the default pagination control, and then echo the paginator directly:

Zend_Paginator::setDefaultScrollingStyle('Elastic');
Zend_View_Helper_PaginationControl::setDefaultViewPartial('my_pagination_control.phtml');
<?php if ($this->pageCount): ?>

    <div class="pager">

        <div class="pager-counter">

            Showing <strong><?php echo Zend_Locale_Format::toNumber($this->firstItemNumber)?> - <?php echo Zend_Locale_Format::toNumber($this->lastItemNumber)?></strong>

            of <strong><?php echo Zend_Locale_Format::toNumber($this->totalItemCount)?></strong>

        </div>

        <div class="pager-outer">

            <div class="pager-inner">

                <!-- Previous page link -->

                <?php if (isset($this->previous)): ?>

                  <a href="<?php echo $this->url(array('page' => $this->previous), 'default', false); ?>" class="page-mover">

                    &lt; Prev

                  </a>

                <?php endif; ?>

                <?php //Now put the first page link

                if($this->current > 1 && $this->firstPageInRange > 1){ ?>

                    <a href="<?php echo $this->url(array('page' => 1), 'default', false); ?>" class="page-mover page-mover-numeric"><?php echo Zend_Locale_Format::toNumber(1)?></a> ..

                <?php } ?>

                <!-- Numbered page links -->

                <?php foreach ($this->pagesInRange as $page): ?>

                  <?php if ($page != $this->current): ?>

                    <a href="<?php echo $this->url(array('page' => $page), 'default', false); ?>" class="page-mover-numeric page-mover">

                        <?php echo Zend_Locale_Format::toNumber($page); ?>

                    </a>

                  <?php else: ?>

                    <span class="page-mover-numeric pave-mover page-mover-current"><?php echo Zend_Locale_Format::toNumber($page); ?></span>

                  <?php endif; ?>

                <?php endforeach; ?>

                <?php //Now put the last page link

                if($this->current != $this->last && $this->last > $this->lastPageInRange){ ?>

                    .. <a href="<?php echo $this->url(array('page' => $this->last), 'default', false); ?>" class="page-mover-numeric"><?php echo Zend_Locale_Format::toNumber($this->last); ?></a>

                <?php } ?>

                <!-- Next page link -->

                <?php if (isset($this->next)): ?>

                  <a href="<?php echo $this->url(array('page' => $this->next), 'default', false); ?>" class="page-mover">

                    Next &gt;

                  </a>

                <?php endif; ?>

            </div>

        </div>

    </div>

<?php endif; ?>

And that’s it! Zend_Paginator handles all the math involved and makes your items easily available in a paginated way.

Older Entries

Switch to our mobile site