How to increase Zend Framework learning speed?

2020-05-11 10:09发布

问题:

A preamble: I've been using PHP for over 8 year every now and then, but never used a framework, only wrote scripts and addons. Mostly I used code generators like CodeCharge Studio or custom code for intranet apps. Since I am ok with design patterns, Zend framework doesn't look too hard for me to learn.

Starting with ZF: I've a read the QuickStart manual and wonder what can advance me to being fast with basic Zend web app development. As I understand there are repetitious tasks that take a lot of time.

Questions: For instance, for almost every site I develop there must be User Registration process and I don't want to reinvent the wheel and spend a week for Login/Profile forms.

1) Do you, Zend developers, use some kind of prototypes you've written to roll out a basic site quickly?

2) Or are there some site source codes to be built upon already available?

3) Is there some app generator or minor tool for pages with grids, records etc?

P.S. I stopped learning EJB over 6 years ago because I didn't have anyone to ask similar questions. TIA!

回答1:

1) Do ZF developers use some kind of prototypes to roll out a basic site quickly?

The Zend Framework is a little too young yet for components in this area, however there is an unofficial PEAR channel. As of March '09 the thought leaders still seem to be debating the best ways to organize everything. I personally am most excited about the domain-driven initiatives as they will be the most robust.

2) Are there some site source codes to be built upon already available?

The best sources right now are the blogs, sites, and repositories of ZF thought leaders. Here's some links to get you started:

  • Brian here in the comments notes Rob Allen's tutorial. It was the first to really go beyond the basics and is the foundation for his book Zend Framework In Action.

  • Padraic Brady's blog application tutorial and svn repository has been one of the most complete examples showing how a lot of the components fit together. It's being migrated to an online book called Survive The Deep End but will take some time as he mentions in his blog that he's extremely busy.

  • Matthew Weier O'Phinney has done a few interesting setups which you can read about and clone from his github repository. The 'bugapp' branch especially in that repo has some interesting techniques. He's been working locally lately so the latest updates are in his blog.

  • Damien Mathieu has been working on a DRY framework based on best practices.

3) Is there some app generator or minor tool for pages with grids, records etc?

There is a scaffolding-generator as a part of Zend_Tool slated for release in ZF v1.8. It's currently in the incubator, I tried it last week and it works, but there are not many components generated in its current state.

Last week I finally took the time to gather sources together (which includes the Stack Overflow ZF questions feed). I've put them under a Zend Framework tag in Google Reader and will be refining the feed sources over time. In case you'd rather manage them yourself, here is the current OPML.

Best of luck! -Matt

<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
    <head>
        <title>expertseries | Zend Framework | Google Reader</title>
    </head>
    <body>
        <outline title="Zend Framework" text="Zend Framework">
            <outline text="A.J. Brown" title="A.J. Brown" type="rss"
                xmlUrl="http://feeds.feedburner.com/ajbrowns_blog" htmlUrl="http://ajbrown.org/blog"/>
            <outline text="Armando Padilla" title="Armando Padilla"
                type="rss" xmlUrl="http://www.armando.ws/?feed=rss2" htmlUrl="http://www.armando.ws"/>
            <outline text="Benjamin Eberlei" title="Benjamin Eberlei"
                type="rss"
                xmlUrl="http://www.whitewashing.de/about/rss/all" htmlUrl="http://www.whitewashing.de"/>
            <outline text="Bradley Holt" title="Bradley Holt" type="rss"
                xmlUrl="http://bradley-holt.blogspot.com/feeds/posts/default" htmlUrl="http://bradley-holt.blogspot.com/"/>
            <outline text="Cal Evans" title="Cal Evans" type="rss"
                xmlUrl="http://blog.calevans.com/feed/" htmlUrl="http://blog.calevans.com"/>
            <outline text="Chris Hope" title="Chris Hope" type="rss"
                xmlUrl="http://feedproxy.google.com/ElectricToolboxBlog" htmlUrl="http://www.electrictoolbox.com"/>
            <outline text="Codecaine.co.za" title="Codecaine.co.za"
                type="rss" xmlUrl="http://www.codecaine.co.za/rss/" htmlUrl="http://www.codecaine.co.za/"/>
            <outline text="Douglas Brown" title="Douglas Brown"
                type="rss" xmlUrl="http://www.brownphp.com/feed/" htmlUrl="http://www.brownphp.com"/>
            <outline text="Federico Cargnelutti"
                title="Federico Cargnelutti" type="rss"
                xmlUrl="http://blog.fedecarg.com/feed/" htmlUrl="http://blog.fedecarg.com"/>
            <outline text="Jani Hartikainen" title="Jani Hartikainen"
                type="rss" xmlUrl="http://codeutopia.net/blog/feed/" htmlUrl="http://codeutopia.net/blog"/>
            <outline text="Juozas Kaziukėnas" title="Juozas Kaziukėnas"
                type="rss" xmlUrl="http://dev.juokaz.com/feed/rdf" htmlUrl="http://dev.juokaz.com"/>
            <outline text="Matthew Turland" title="Matthew Turland"
                type="rss" xmlUrl="http://ishouldbecoding.com/atom/1" htmlUrl="http://ishouldbecoding.com/"/>
            <outline text="Matthew Weier O'Phinney"
                title="Matthew Weier O'Phinney" type="rss"
                xmlUrl="http://weierophinney.net/matthew/feeds/index.rss2" htmlUrl="http://weierophinney.net/matthew/"/>
            <outline text="Michelangelo van Dam"
                title="Michelangelo van Dam" type="rss"
                xmlUrl="http://www.dragonbe.com/feeds/posts/default" htmlUrl="http://www.dragonbe.com/"/>
            <outline text="Mike Rötgers" title="Mike Rötgers" type="rss"
                xmlUrl="http://www.roetgers.org/feed/" htmlUrl="http://www.roetgers.org"/>
            <outline text="Nick Lo" title="Nick Lo" type="rss"
                xmlUrl="http://www.ingredients.com.au/nick/feed/" htmlUrl="http://www.ingredients.com.au/nick"/>
            <outline text="Pádraic Brady" title="Pádraic Brady"
                type="rss"
                xmlUrl="http://blog.astrumfutura.com/feeds/index.rss2" htmlUrl="http://blog.astrumfutura.com/"/>
            <outline text="Raphael Stolt" title="Raphael Stolt"
                type="rss"
                xmlUrl="http://raphaelstolt.blogspot.com/feeds/posts/default" htmlUrl="http://raphaelstolt.blogspot.com/"/>
            <outline text="Rob Allen" title="Rob Allen" type="rss"
                xmlUrl="http://akrabat.com/feed/" htmlUrl="http://akrabat.com"/>
            <outline text="Robert Basic" title="Robert Basic" type="rss"
                xmlUrl="http://feeds2.feedburner.com/robertbasic/blog/" htmlUrl="http://robertbasic.com/blog"/>
            <outline text="Stack Overflow ZF" title="Stack Overflow ZF"
                type="rss"
                xmlUrl="http://stackoverflow.com/feeds/tag/zend-framework" htmlUrl="http://stackoverflow.com/questions/tagged/zend-framework"/>
            <outline text="Thomas Weidner" title="Thomas Weidner"
                type="rss"
                xmlUrl="http://www.thomasweidner.com/flatpress/feed/rss2/" htmlUrl="http://www.thomasweidner.com/flatpress/"/>
            <outline text="Tom Graham" title="Tom Graham" type="rss"
                xmlUrl="http://www.noginn.com/feed/" htmlUrl="http://www.noginn.com"/>
            <outline text="Zend Dev Zone" title="Zend Dev Zone"
                type="rss"
                xmlUrl="http://feeds.feedburner.com/ZendDeveloperZone" htmlUrl="http://devzone.zend.com/"/>
        </outline>
    </body>
</opml>


回答2:

Akra's DevNotes has a great tutorial that creates a sample application:

http://akrabat.com/zend-framework-tutorial/

This is where I started working with the ZF.



回答3:

If you're already acquainted with MVC and design patterns, then why not look into tools to helps you code faster?

Although I generally like free tools, I must say using Zend Studio IDE (based on Eclipse) helps going faster (30-day free trial).

The main points (apart from the debugger/profiler):

  • it can generate a skeleton for MVC applications
  • default code skeletons for basic bricks (controllers, views, models)

and -last but not least-

  • auto-completion for all Zend classes (and you can Ctrl+click through the classes names to open them). Very convenient I must say.

Just make sure to have a computer with a whole lot of memory!



回答4:

I'm in your exact situation right now (just less years with php :P)

Currently i'm using Zend FrameWork in action as reference and for what i've seen till now it's pretty easy to reuse your structure from old jobs. Once you've setted up your preferred options and tree structure you can reuse it over and over.

So I think that it's better not rely to third party generators and create your own skeleton. In this mode you will be much more comfortable with the code structure, and you'll have better code's grasp.



回答5:

  • for basic site, just follow the QuickStart;
  • more advanced stuff, e.g. on http://devzone.zend.com/ or http://www.zftutorials.com/

Using framework means, that you're not going to have to do all of that tedious repetitive stuff.



回答6:

As I understand there are repetitious tasks that take a lot of time.

This is true, and as you stated, just about every website has a registration process and the like. While I agree that implementing such features over and over again can be repetitive, to some extent, each application will have its own unique set of requirements - meaning there will be at least a little customization work involved, even if you're reusing code from an older ZF-based project. I will now have a bash at answering your numbered questions

Do you, Zend developers, use some kind of prototypes you've written to roll out a basic site quickly?

Not really. I would not choose the ZF for a 'basic' site, nor would I use any MVC framework. My current assumption is that a basic site consists of about 8 to 12 separate parts, with no really special functionality, and finite requirements. Remember that once we say 'framework', there is almost always a noticeable performance hit, in addition to whatever bugs and issues which might be inherent within that framework. The 'prototypes' you speak of would be in the classes available within the Zend Framework, for example, Zend_Auth for creating a fully featured authentication system in about 15 minutes.

2) Or are there some site source codes to be built upon already available?

Probably, though I have to say, my worst nightmare would be having to support an application built on some kind of framework that wraps another framework. Image how much fun debugging it would be. Imagine how much fun teaching someone to support it would be. You're already using a framework, let's not get greedy now.

3) Is there some app generator or minor tool for pages with grids, records etc?

I'm not quite sure what you mean by this, but if I had to chance a guess, perhaps Zend Studio?



回答7:

There is a good german book, you can find a starter app in an archive on this site and study the code: http://www.zend-framework-buch.de/



回答8:

We have a tool that can help: nWire for PHP analyzes your code, helps you navigate through it and visually represents components and associations. You will eventually need to read the code and with nWire this becomes much easier.



回答9:

For a jump-start you can read the "Learn ZF2" book. It is written with the help of core Zend Framework 2 (ZF2) team members and ZF2 course creators and is probably the best match for getting good insight about Zend Framework 2 and its features. The books is accompanied by source code and it leads you step by step through the different concepts. Interesting read that gets better with every page.