Warning: include_once(): Unable to allocate memory for pool. in /usr/share/php/Zend/Loader/PluginLoader.php on line 384 Call Stack: 0.0000 632112 1. {main}() /home/padraic/public_html/survivethedeepend.com/zfbook/website/public/index.php:0 0.0003 647176 2. Bootstrap::run() /home/padraic/public_html/survivethedeepend.com/zfbook/website/public/index.php:12 0.0124 2415456 3. Zend_Controller_Front->dispatch() /home/padraic/public_html/survivethedeepend.com/zfbook/website/library/Bootstrap.php:19 0.0231 2812440 4. Zend_Controller_Plugin_Broker->postDispatch() /usr/share/php/Zend/Controller/Front.php:957 0.0231 2812440 5. Zend_Layout_Controller_Plugin_Layout->postDispatch() /usr/share/php/Zend/Controller/Plugin/Broker.php:331 0.0232 2813168 6. Zend_Layout->render() /usr/share/php/Zend/Layout/Controller/Plugin/Layout.php:142 0.0237 2821816 7. Zend_View_Abstract->render() /usr/share/php/Zend/Layout.php:793 0.0238 2863584 8. Zend_View->_run() /usr/share/php/Zend/View/Abstract.php:833 0.0238 2864200 9. include('/home/padraic/public_html/survivethedeepend.com/zfbook/website/application/views/layouts/default.phtml') /usr/share/php/Zend/View.php:108 0.0279 2876912 10. Zend_View->layout() /home/padraic/public_html/survivethedeepend.com/zfbook/website/application/views/layouts/default.phtml:101 0.0279 2877304 11. Zend_View_Abstract->__call() /home/padraic/public_html/survivethedeepend.com/zfbook/website/application/views/layouts/default.phtml:101 0.0279 2877304 12. Zend_View_Abstract->getHelper() /usr/share/php/Zend/View/Abstract.php:336 0.0279 2877440 13. Zend_View_Abstract->_getPlugin() /usr/share/php/Zend/View/Abstract.php:569 0.0279 2877712 14. Zend_Loader_PluginLoader->load() /usr/share/php/Zend/View/Abstract.php:1118 Warning: include(): Unable to allocate memory for pool. in /usr/share/php/Zend/View.php on line 108 Call Stack: 0.0000 632112 1. {main}() /home/padraic/public_html/survivethedeepend.com/zfbook/website/public/index.php:0 0.0003 647176 2. Bootstrap::run() /home/padraic/public_html/survivethedeepend.com/zfbook/website/public/index.php:12 0.0124 2415456 3. Zend_Controller_Front->dispatch() /home/padraic/public_html/survivethedeepend.com/zfbook/website/library/Bootstrap.php:19 0.0139 2538976 4. Zend_Controller_Dispatcher_Standard->dispatch() /usr/share/php/Zend/Controller/Front.php:946 0.0176 2735104 5. Zend_Controller_Action->dispatch() /usr/share/php/Zend/Controller/Dispatcher/Standard.php:289 0.0178 2743984 6. Zend_Controller_Action_HelperBroker->notifyPostDispatch() /usr/share/php/Zend/Controller/Action.php:523 0.0179 2745896 7. Zend_Controller_Action_Helper_ViewRenderer->postDispatch() /usr/share/php/Zend/Controller/Action/HelperBroker.php:277 0.0179 2745896 8. Zend_Controller_Action_Helper_ViewRenderer->render() /usr/share/php/Zend/Controller/Action/Helper/ViewRenderer.php:963 0.0184 2746376 9. Zend_Controller_Action_Helper_ViewRenderer->renderScript() /usr/share/php/Zend/Controller/Action/Helper/ViewRenderer.php:924 0.0184 2746376 10. Zend_View_Abstract->render() /usr/share/php/Zend/Controller/Action/Helper/ViewRenderer.php:903 0.0185 2787832 11. Zend_View->_run() /usr/share/php/Zend/View/Abstract.php:833 0.0185 2788448 12. include('/home/padraic/public_html/survivethedeepend.com/zfbook/website/application/views/scripts/book/view.phtml') /usr/share/php/Zend/View.php:108 0.0185 2788968 13. Zend_View->partial() /home/padraic/public_html/survivethedeepend.com/zfbook/website/application/views/scripts/book/view.phtml:1 0.0185 2789480 14. Zend_View_Abstract->__call() /home/padraic/public_html/survivethedeepend.com/zfbook/website/application/views/scripts/book/view.phtml:1 0.0192 2796776 15. call_user_func_array() /usr/share/php/Zend/View/Abstract.php:342 0.0192 2797264 16. Zend_View_Helper_Partial->partial() /usr/share/php/Zend/View/Abstract.php:342 0.0193 2800768 17. Zend_View_Abstract->render() /usr/share/php/Zend/View/Helper/Partial.php:103 0.0194 2842256 18. Zend_View->_run() /usr/share/php/Zend/View/Abstract.php:833

Chapter 4. Installing The Zend Framework

4.1. Introduction

The past few chapters were replete with theory so it will be a nice break to do something concrete. Afterall there's only so much I can pummel your brain with before I surrender and get on with the show! I know books with tons of theory can be tough going but stick with it - it's well worth letting it all kick around at the back of your mind.

When I started writing this chapter about installing the Zend Framework I complained on Twitter that the Zend Framework would be easier to install if someone created a PEAR package for it (something Symfony and ezComponents do). Going by the responses this is actually a plan Zend are considering and which will make some of the following chapter obsolete if it does.

4.2. Before You Install The Framework

Before installing the Zend Framework you're going to need a fully functional development system. While writing this book I used Ubuntu Linux 9.04 (the Jaunty Jackalope), Apache 2.2, MySQL 5.0.65 and PHP 5.2.6 - a typical up to date LAMP system from the Ubuntu repositories in other words. Any Windows equivelant using similar versions of Apache, MySQL and PHP would be equally usable. To follow this book, I'm making the assumption that you are at least using the Apache web server and MySQL database management system. If you want to use ISS and MSSQL, I'm not going to stop you or anything but be aware some steps in the next couple of chapters will need to be tweaked to apply to those systems. Where it's needed throughout the book, I will mention Windows specific instructions below the Linux ones.

Installing all these is not something I'm going to cover. The internet is practically swamped with installation guides for every conceivable system and scenario, and you should use your preferred search engine to search for relevant instructions. The PHP manual is a good place to start but you can also either use your Linux distro's update system (like aptitude for Ubuntu) or even grab an all-in-one development system for Windows like XAMPP to get this done in fewer steps.

4.3. Getting The Zend Framework

You can currently get the Zend Framework in a few ways. You need to be careful however since some methods tend to be a bit...dodgy.

4.3.1. Download As Compressed Archive File

The simplest is to grab the most recent version from http://framework.zend.com/download/latest. As I'm writing this, the latest version is 1.9.1. You will need to extract the downloaded archive to a working location like your OS desktop. We'll cover the structure of the downloaded files shortly.

Once you have the framework files downloaded it's worth taking some time to learn your way around them. You see the Zend Framework, as we discussed in the last chapter, has four different collections of useful classes: Standard, Standard Incubator, Extras, and Extras Incubator. The most important one is Standard - it's the main collection you will be used. This complicates things a little since the major part of any initial setup is knowing what to add to your PHP include_path, whether you intend editing it in a php.ini configuration file or changing it with set_include_path() when you are creating a new application. Here's where to find each of those four collections relative to the parent Zend Framework directory you extracted:

Standard: /library
Standard Incubator: /incubator/library
Extras: /extras/library
Extras Incubator: /extras/incubator/library

Inside each of those locations is a directory called either Zend or ZendX. The "X" postfix identifies extra components distributed for which Zend offers no official support (the lack of support doesn't prevent them being very useful however!). It is the above paths (the full path from your root or drive letter) you'll need to eventually add to the PHP include_path. For example if I copied the framework files to /usr/share/php/zf the full path to add to my include_path for the Extras Incubator would be /usr/share/php/zf/extras/incubator/library. This should be enough to go away and edit php.ini if you want to (not a bad idea) and I'll show you how to manage the PHP include_path for a Zend Framework application in subsequent chapters if you don't wish to perform any php.ini editing.

With the information above go copy the framework files somewhere more permanant. I use /usr/share/php/zf on Ubuntu but any location will work. Just try not to forget where you put it!

4.3.2. Checkout From Subversion

If you prefer keeping pace with active development in trunk, or keeping your fixes updated from the current release branch, you can also "checkout" the framework from it's subversion repository at http://framework.zend.com/svn/framework/. Subversion is a version control system which developers use to maintain a central online repository for source code they are developing. Its attraction is allowing multiple developers to work on the same source code without constantly swapping notes or taking turns.

I would suggest creating a permanent location like /usr/share/php/zf and checking out the repository into that directory. The only problem with subversion is that there is a lot (by a lot I mean a mind blowing crazy number) of files when you include all the branches and tags. To grab only the needed files from subversion you'll need to make four separate checkouts only updating from the locations of the main four file collections whose URLs are:

Standard: http://framework.zend.com/svn/framework/standard/trunk/library/
Standard Incubator: http://framework.zend.com/svn/framework/standard/incubator/library/
Extras: http://framework.zend.com/svn/framework/extras/trunk/library/
Extras Incubator: http://framework.zend.com/svn/framework/extras/incubator/library/

If using trunk for each is not your thing, you can instead use the relevant release branch for each.

Simplest way to do this is to create the parent directory as usual, for example at /usr/share/php/zf, and inside this run the svn checkout command referencing four other directories named for the collection name, similar to standard, standard_incubator, extras, extras_incubator.

Whenever you want to update to the latest development code, you only need to perform a subversion update for each of those four directories.

4.3.3. Download As A Linux Distribution Package

There is a third option - grab it from your Linux distribution's update server using apt-get or aptitude (if using a Debian based distribution). I really don't recommend this since you may end up with a framework version that was released months behind the latest one. This is borderline dangerous if you are writing to a version with a significant security issue (possible). On Ubuntu you would simply run a command similar to:

sudo aptitude install zendframework

If you are certain the latest version is available from your distribution's update server, only then consider it. At the time of writing this appears not to be the case though.

4.3.4. Nightly Build Download

I won't describe this further since it's currently not operable on the Zend Framework website. In the future however, this would allow you to grab the most recent nightly built version without going through Subversion.

4.4. Post Installation

That's about it for installing the Zend Framework. The only complex step is being aware the source code is packaged into four distinct parts, each of which would need to be separately added to the PHP include_path at some time. If you are comfortable with editing php.ini, you may do this immediately. If you do I suggest ordering included paths so that the Incubator paths are last. This ensures Incubator component classes do not take precedence over all others, but still allows access to any new original Incubator components. This ordering of include_paths also counts as a minor performance optimisation as described in this book's appendices.

Powered by jQuery Powered by Zend Framework Powered by Nginx Http Server