views:

1535

answers:

8

I am a newbie of Zend Framework.

I downloaded the Zend Framework and then followed the official quickstart tutorial to build a very simple registration form. But after that, I find very hard to learn different elements of Zend Framework.

Many tutorials mention frontController and registerAutoload() in the bootstrap file. However, it seems that I can't see it again in the code in version 1.8 (both in the official quickstart tutorial and Getting Started with Zend Framework 1.8). Many tutorials contain the old version of code and it seems very different in v1.8.

I start with writing registration form with password confirmation. I read the official document and find the custom validator for password confirmation. It just puts the class there and doesn't mention how I can use it. I don't know where I should put this file and I can't find any hints in Google. The "class not found" error always makes me sick (I've tried addPrefixElement, set_include_path but they don't work).

User registration, email activation, login, access control are very common tasks. But I don't even find a piece of sample code in v1.8 that I can run in my machine. I am very frustrated about Zend Framework.

Does anyone give me some advices?

+7  A: 

I have also just started learning the zend framework. I also find alot of old tutorials that make learning confusing and hard, but there are some resources that I find help in learning the zend framework:

Some useful blogs that might help:

Forums to ask your questions:

As to class not found, I think you didn't autoload?

iceangel89
+3  A: 

Parts of Zend Framework have changed slightly in the 1.8 release but everything should be backwards compatible so all code example written using the 1.* release series should still work with little or no modification. The main areas that are different are

  • Zend Loader (related to register_autoload) which now has several improvements related to performance and some slight differences in its API (with a PHP warning if you use the old way). I wouldn't worry about this too much as a beginner - just follow the tutorial or continue to use include/require statements until you become annoyed with adding them all the time!

  • Zend Application which basically allows you to create your set-up and initialisation code with less fuss. Again, you don't have to use it and you can happily write a manual bootstrap class to get you used to how the framework is put together.

With regards to getting started I would highly recommend getting your head around the Zend Controller component, particularly the front controller part and this diagram. For authentication look at Zend Auth, for e-mail see Zend Mail, for access control see Zend Acl and for forms and validation see Zend Form, Zend Validate and Zend Filter. The form and validation components will explain about paths and adding your own custom validators and form elements.

The other area of importance is Zend Db which allows you to persist your data to a database. There is also Zend View which represents the view layer in the MVC stack. In my opinion these are the key components of a basic ZF application. From there you can explore the other components as and when you need them.

Don't forget that the Zend Framework is specifically designed to be loosely coupled and it is very easy to use a different component from another project for a particular task. Sometimes it is necessary to write your own components too. If there is a component you would prefer to use over the Zend component then go ahead and do so.

Honestly, the documentation is very good although it is hard to navigate for beginners. Once you get your head around the core components everything will become a lot clearer.

Also try following this tutorial. It will help explain a lot of the basics.

Tim Wardle
A: 

The Front Range PHP Users Group website has some presentations on Zend Framework which may be of use.

Cal Jacobson
A: 

I have so much sympathy with you Billy. I am a newbie and the confusion between the old way and the new way is almost just too much to handle. Also see here for someone who points out some of the main differences:

http://crossfunctional.wordpress.com/2009/05/

A: 

All documentation, particularly Zend's documentation is absolutely horrible. It all assumes that you "know" where to put the snippets they are referring to and how they work together. If I already knew those things, I wouldn't need the documentation. No full example applications with authentication etc. that you can download and modify. I'm seriously regretting putting any time into trying to learning this framework. All examples that I can find are apparently for older versions. I followed one for authentication on youtube that was designed for 1.8 to the letter. It fails to work in 1.9.x. Can't get it to work for the life of me. Completely frustrated with Zend Framework!

Joel
+2  A: 

I recommend these video tutorials pu up by a guy called Alex, he keeps them up to date and releases new ones all the time,they are all relevant to ZF 1.8 and 1.9.

He has even a detailed video tutorial covering ACL, login forms etc. (my first steps with Zend were easier thanks to him!)

http://alex-tech-adventures.com/development/zend-framework.html?start=15 - his site is a bit comfusing but worth the time in figuring it out :)

Cheers Roman

Romansky
A: 

Zend Framework has shifted from being a relatively accessible and simple system to a more complex entity. It has gone through a number of rapid developments over the past couple of years which have left a lot of older documentation around.

We have projects that are stuck on Version 1.7.x because the differences between that and the latest version are too great which makes the dev and testing time too expensive.

I like Zend Framework because it has so much depth to it but it is definitely a two edged sword for beginners.

I'd certainly recommend making use of the expertise of other users and search out some simple framework examples. ZF is highly adaptable but you need to try and work from the simplest case possible for your needs.

I think Matthew Weier o'Phinney, (search for 'Phly, boy, phly') is one of the more approachable members of the dev team and has loads of examples and ideas on his website.

Good luck!

Ian Lewis
+1  A: 

Some tips:

Here is a nice diagram of the Dispatch process

http://nethands.de/download/zenddispatch_en.pdf

It is much easier to understand ZF if you are experienced in OOP / OOP Design Patterns

When I first stumbled across ZF I had little knowledge of OOP. ZF prompted me to learn OOP which was a very good thing.

Distinguish between the 'magic' of ZF and the actual ZF Architecture

Although I have a good understanding of ZF Classes I still get confused when ZF adds its 'magic' to the mix.

When I say 'magic' I am referring to things like

  • the default objects loaded and used if none specified, and
  • url-controllername-filepath-filename inflections / naming conventions.
  • config settings-to-class-instantiation mappings

ZF is a bit like a crack-dealer in the sense that the 'Getting Started Tutorials' get you hooked straight away. They perform so much magic that it makes you think .oO(Wow - how simple was that! This framework is cool!)

Then as soon as you start to try to do your own thing - the magic starts to get really confusing.

So - my tactic is to remove as much ZF magic as possible. If you have the option to specify a class to use, or a router to use, then specify it. Don't let Zend do it for you.

Then when something weird is happening you can find the bugs more easily.

Also, if you specify the locations of classes/ paths as (opposed to letting ZF magically inflect paths and find scripts), then you do not have to worry about questions of 'where to put this? , where to put that?' - you just put things where you want them to be and explicitly point ZF to them.

As you get more familiar with ZF you might then want to let it take over and do some magic for you. Only then can you really understand why that magic is convenient.

As Tim Wardle said in another answer - favour require statements over zend loader until you really need it.

If you are a PHP design house that churns out 10 website projects a week, then ZF Magic can be really useful. If you are designing your first ZF app - then 'reducing complexity' is a more important design goal than 're-usability'.

Browse the code

It might seem obvious but one of the best ways to learn about the ZF is to look at the code.

Again the ZF magic can get in the way - I often want to look at a method's arguments to discover what i need to pass in only to discover that it expects an ambiguous 'options array' (not exactly helpful). After a while, though, you start to notice the conventions used in how an 'option key' marries up to a getter/setter method. So, keep looking at the code and familiarising yourself with the 'ZF way'.

I 'ope that 'elps.

JW
Having written my piece on ZF magic it made me think that it might be good to have some kind of 'ZF Magic Info' component that 'observes' the framework and lets you output something like 'phpinfo()' at the end so we can see whats gwan on. - just a thought
JW