It’s been a while since I’ve written a blog post because I’ve been extremely tied up with projects at work up for the last year+. However, now comes a time when I want to go back, explore what I’ve learned, and in the process develop a short set of tutorials explaining it all. The tools and code that I post up are going to be used in my everyday work, things I find useful and even things to make my personal coding experience easier (hopefully yours too).
The first part of this series will focus solely on downloading the starter kit, how to pull it down from the SVN, and how to make sure your apache is configured to handle it. The rest of the series will focus on using this starter kit to make some awesome apps.
To start with, this series will assume that you have a basic knowledge of the following:
- Configuring your own local apache test environment or using a live apache server.
- Basic understanding of PHP syntax, functions and usage.
- Some knowledge of OOP, understanding of classes and methods.
Basically I will be giving you a “Starter Kit”, which will require you to have a functional PHP/Apache setup in order to run. From here on out, instead of referring to the package as the “Zend Framework Starter Kit”, I will simply be calling it ZF-Starter. You are free to use this code however you see fit, without attribution! Read on to check out all the steps in getting the code and getting started!
Exporting your copy of ZF-Starter
For ease of updating on my part, and since most developers already use some form of Version Control, I’ve added a public SVN Repository to greymass.com that contains a “Zend Framework Starter Kit”. If you are unfamiliar with using a SVN, I would like to direct you to a Round-Up post on Smashing Magazine with SVN resources. It’s a little older, but the resources within are still valid and good for learning about source control with SVN.
So, before you download the code itself, we should probably talk about how Apache or your Web Server needs to be configured in order to run this sample code. I will list off some of the basics that you need to have setup/enabled:
- Enable apache’s mod_rewrite (or your web server’s equivalent extension)
- PHP 5.3+ (5.2.x for earlier tutorials, but we will get into some things that require 5.3, so upgrading is recommended)
- Enable PHP’s short_open_tag in your php.ini or .htaccess
- The DocumentRoot for running this example will be the /public_html folder within the repository, not the root.
- You will need your web server setup to use the .htaccess included within the /public_html folder.
If anyone has any specific questions or setup problems with setting up their instance of a web server, I’d like to direct you to ServerFault.com. I really want to focus on the actual implementation of Zend Framework and less on the millions of configurations web servers can have. Onto the repository!
ZF-Starter Repository URL: http://greymass.com/code/zf-starter
Once you have some form of SVN installed on the operating system of your choice, there are 2 methods that you can download the ZF-Starter Kit. Both methods I will recommend use the “Export” feature of SVN, which will download the code and remove the “Version Control” from the code. You could also simply do a “Check Out” of this code, however if you started making changes, you’d be unable to commit them back to my public repository, so really checking out isn’t needed.
- SVN Export (Command Line) - If you are running from a command line, you can download the code from this command:
-
svn export http://greymass.com/code/zf-starter c:/path/to/your/web/folder
- SVN Export (GUI)
- Windows/TortoiseSVN: Right click in the folder you wish to download the code. On the menu that pop’s up, hover over “Tortoise SVN” and on the sub-menu, click “Export”. The first box, “URL of the Repository” on the export screen should be the repository URL located above.

After the export is complete, browse to the folder that you downloaded, it should look something like this:

What are all these folders?
The starter kit is all about organization and establishing the base hierarchy of what you will be building. There are a few different ways you can use and implement the Zend Framework, this method is using the MVC pattern. The 2nd section of the Zend Framework – Quick Start gives a nice short overview of what these pieces do. Here’s a quick breakdown in my own words:
- Controllers – Controllers are objects that parse user input, call upon the models the user may need, redirect the user to a view and control the flow of traffic.
- Models – The model is the “data” object, the source of your information. MySQL tables can be used in models to fetch and store data, along with many other DB/NoDB solutions (which we will get into later in the series)
- Views – In one word: Templates. These are the files that hold your HTML, fill in the actual pages, and know how to display the data that the user has requested.
As you can see in the ZF-Starter, these are all folders with the /application folder. The other two folders not mentioned in the MVC structure that are included in the /applications folder are the layouts and configs folders. The layouts folder is a view technically, as it is used to create generic templates used site-wide, which will be used later in this series. The configs folder is probably a little more simple, it’s basically a location to store your server-based configuration options for your application (ie your DB connection string, analytics code, etc).
Also included as a folder you will find the /library and /scripts folders. The /library folder contains the Zend Framework as well as any other libraries you may require and/or create. The /scripts folder is a utility folder, which I use to store shell scripts/batch files to automate some routine tasks. For now, we will leave these folders alone, and come back to them later.
The last folder included is the /public_html folder, which is exactly what it sounds like, the root of your website. Images, Stylesheets, Javascript and all other files that aren’t part of your code can be placed in here just like any other website. The index.php and .htaccess files are already configured in those folders to run the site, and should need very little modifications for basic usage.
So what needs to be done?
The only thing that needs to be done after Apache is configured and the code is placed in the proper location is one step: rename the configuration file. In the folder /application/configs/ you will find a file named application.ini.template. This file just needs to be renamed to application.ini. Take a look in the file if you want to see some common configuration options, we will be changing this file in the future to add more flexibility to the application.
After you rename/copy your application.ini, try loading up the site and you should see the following (with a different time obviously):

That’s pretty much it… throughout this small tutorial you should have completed the following steps.
- 1) Have a functional Apache/IIS configuration with a mod_rewrite compatible extension.
- 2) Check-Out / Export the ZF-Starter Kit onto your local machine/web server.
- 3) Configure Apache/IIS site to point the DocumentRoot to the /public_html folder.
- 4) Rename/Copy the application.ini.template file to application.ini.
- 5) Check your site via a browser and see a page with some examples and the current time.
I plan (time permitting) on creating an entire series of “How-To’s” based on this ZF-Starter kit explaining how to integrate Databases, Frameworks and other libraries into the mix, if you have any requests, or end up creating anything cool with the kit, feel free to drop a comment and let me know!
Enjoy!
