Tuesday, November 30, 2010

Creating a blog with the Zend Framework part 2: Laying the groundwork

This is the second part in a series on creating a blog using the Zend Framework and the Zend Tool. If you missed part one, don't forget to check it out.

Using the Zend Tool on the command line is a quick way to get a project up and running. Through the Zend Tool, you can easily create the project, create controllers, and create actions and views through those controllers. There is also quite a bit more you can do, but we'll just focus on these actions for this step.

Let's look at what controllers we'll need. Keeping it simple, we can have an index controller to view the blog and a post controller to handle the viewing of the posts, all the CRUD (create, read, update, delete) and posting of comments.

Now we'll go over the layout.
  • index controller

    • index action

    • page action

  • post

    • index action (by default)

    • create action

    • read action

    • update action

    • delete action



And now we can start actually creating the project. From the command line (I'm running this in windows) type the following:

zf create project blog


We are given a couple controllers when we create the project; an index and an error controller. Great, that is one less step we need to do. We just need a post controller now which is created by typing the following:

zf create controller post


Since each controller comes with a default "index" action as a default, we'll just create the others now:

zf create action page index
zf create action create post
zf create action read post
zf create action update post
zf create action delete post


While we've created the controller and the actions, we still need a model. Let's go ahead and create the base for those as well.

zf create model posts
zf create model comments
zf create model users


Voila. Our framework has been layed. Of course there is still quite a bit to do but we have the very basic basics down.

2 comments:

  1. By using Zend Framework Service we can develop any kind of web application - portal, business tool, usual module - and spend less time on it when compared to usual PHP development. This Zend Framework advantage enables us to develop high-end and cost-effective solutions satisfying our clients' requirements.

    ReplyDelete