In my last post, I discussed using Zend_Form as a combination input filter/value object within your models. In this post, I'll discuss using Access Control Lists (ACLs) as part of your modelling strategy.
ACLs are used to indicate who has access to do what on a given resource. In the paradigm I will put forward, your resource is your model, and the what are the various methods of the model. If you finesse a bit, you'll have "user" objects that act as your who.
Just like with forms, you want to put your ACLs as close to your domain logic as possible; in fact, ACLs are part of your domain.
A number of blog posts have sprung up lately in the Zend Framework community discussing the Model in the Model-View-Controller pattern. Zend Framework has never had a concrete Model class or interface; our stand has been that models are specific to the application, and only the developer can really know what would best suit it.
Many other frameworks tie the Model to data access -- typically via the ActiveRecord pattern or a Table Data Gateway -- which completely ignores the fact that this is tying the Model to the method by which it is persisted. What happens later if you start using memcached? or migrate to an SOA architecture? What if, from the very beginning, your data is coming from a web service? What if you do use a database, but your business logic relies on associations between tables?
While the aforementioned posts do an admirable job of discussing the various issues, they don't necessarily give any concrete approaches a developer can use when creating their models. As such, this will be the first in a series of posts aiming to provide some concrete patterns and techniques you can use when creating your models. The examples will primarily be drawing from Zend Framework components, but should apply equally well to a variety of other frameworks.
I've been playing a lot with Dojo lately, and have been very impressed by its elegant publish-subscribe system. Basically, any object can publish an event, and any other object can subscribe to it. This creates an incredibly flexible notification architecture that's completely opt-in.
The system has elements of Aspect Oriented Programming (AOP), as well as the Observer pattern. Its power, however, is in the fact that an individual object does not need to implement any specific interface in order to act as either a Subject or an Observer; the system is globally available.
Being a developer who recognizes good ideas when he sees them, of course I decided to port the idea to PHP. You can see the results on github.
I've fielded several questions about setting up an autocompleter with Zend Framework and Dojo, and decided it was time to create a HOWTO on the subject, particularly as there are some nuances you need to pay attention to.
Just about every day, I have an idea for a blog post, and most days, by the end of the day, I just don't have the time or energy to actually write anything up. The inner writer in me screams, "no excuses!" while the aging adult in me whispers, "time for bed, dear."
So, to keep my hand in the game, here are a few things running through my head, or that I'm working on, or that I'll be doing soon.
For this particular release, we tried very hard to leverage the community. The majority of new features present in 1.7.0 are from community proposals, or were primarily driven by community contributors. For me, this represents a milestone: ZF is now at a stage where fewer and fewer core components are necessary, and the community is able to build off it and add extra value to the project.
Chris Hartjes today was on a quest for a "find in project" feature for Vim. "Find in Project" was a feature of Textmate that he'd grown accustomed to and was having trouble finding an equivalent for.
The funny thing is that Textmate is a newcomer, and, of course, vim has had such a feature for years. The thing to remember with vim, of course, is its unix roots; typically if you know the unix command for doing something, you can find what you need in vim. In this case, the key is the vimgrep plugin, which ships in the standard vim distribution.
I've been getting a lot of interest in my Pastebin demo app -- partly by those wanting to play with Dojo+ZF, partly by those just interested in the application.
I'm constantly trying to improve the application. I've done one webinar and one UnCon session showcasing it, and will be presenting it at Dojo Develper Day in Boston this Monday as well as at php|works later this fall, and want to keep the materials up-to-date and freely available. To this end, I've created a Github repository so you can track the latest developments, as well as pull custom tarballs:
All patches and feedback are welcome!
I'm a bit late on my ZendCon'08 wrapup; the conference left me both exhausted and with a backlog of email and work that has consumed me since it ended. However, this, too, is good, as it has given me time to reflect... and to finally get my slides up on SlideShare.
ZendCon was alternately exhausting, rewarding, educational, fruitful, infurating, and ultimately wonderful. I've been to every single ZendCon so far -- I started at Zend a scant month before the inaugural event -- and have spoken at each. My first time speaking was a fluke; David Sklar had just started at Ning and had to back out of his "Configuring PHP" tutorial session. Mike Naberezny and I were drafted to take it over, and we had N+1 attendees, where N was the number of speakers. Since that inauspicious beginning, I've gradually taken on more sessions and stuck around to participate in the conference more. I can honestly say that this was the biggest, busiest, and most community focussed ZendCon I can remember.
Now that Zend_Test has shipped, developers are of course asking, "How do I setup my test suite?" Fortunately, after some discussion with my colleagues and a little experimenting on my one, I can answer that now.