Pages

Tuesday, December 30, 2008

Zend Framework Quickstart Tutorial - Todo List - MySQL version - part 1

Making a screencast takes me awful lots of time so instead I find easier to follow a tutorial written with screenshots and code samples.

0. Introduction

The main idea is to create a todo list application using Zend Framework with the following features:

  • todo lists (eg: Grocery list, chores, daily naps, etc.)
  • each lists can have todo items
  • each item can be active/done
  • mark items as done or delete them

That's about it.

0.1 Installing Zend Framework

I downloaded the 1.7.2 version of Zend Framework and unzip it in ../htdocs/ZendFramework-1.7.2
I edited my php.ini file so I have Zend Framework path in include_path:
include_path = ".;C:\web\Apache2.2\htdocs\ZendFramework-1.7.2\library"
If you are on a Unix platform, instead of ; use : as a separator.
Now, I can use:
require_once "Zend/Loader.php";
without using set_include_path()
1. Application structure My php5 development env is on a Windows Vista and my htdocs directory is located: C:\web\Apache2.2\htdocs
1.1 Create a new folder: zftodo
Create a new folder: zftodo in your htdocs directory.
1.2 Checkout the app structure from google code
svn checkout http://zfquickstartmysql.googlecode.com/svn/trunk/zftodo-start zfquickstartmysql-read-only
2. Creating database and granting access In scripts directory you will find a file: db.mysql.sql If you have privileges for creating a new database and granting access run that sql. If you don't have privileges for doing that, skip that and change application/config/app.ini:
[development]
database.adapter       = "PDO_MYSQL"
database.params.host   = "db host here"
database.params.username   = "db username here"
database.params.password   = "db password here"
database.params.dbname = "db name here"
3. Test your application Open your browser and go to the following url: http://localhost/zftodo/public/ (or change it depending on your web server configuration).
You'll see the following message:
Hello, from the Zend Framework MVC!
    I am the index controllers's view script. 
To change the contents you can edit:
  • application/layouts/scripts/layout.phtml (for the layout)
  • application/views/scripts/index/index.phtml (for index contents)

Now you are all set and we can proceed to part 2 of the tutorial where we actually get something working :)

No comments: