Writing a Zend_Auth_Adapter with Doctrine

January 23rd, 2010

I’ve been using Doctrine a lot in my own work, and recently found myself itching to have tighter integration between Zend and Doctrine when it comes to user logins. Luckily, Zend provides a very simple interface with regards to Zend_Auth. This way, it’s easy to decouple your persistence layer (in my case Doctrine) from the authentication layer. I’ve borrowed from Palo Verede’s wonderful article on Doctrine and Zend_Auth and I invite you to check his blog out.

Grab a copy of the project or browse the repository.

Also, a big thank you to ServerGrove for extending their support of Zendcasts for January. ServerGrove specializes in Zend Framework hosting and they’ve offered a 10% rebate on hosting with coupon code “zc”. If you’re looking for a host, be sure to check them out (referral). They’ve also added an additional coupon for “Mini Hosting” plans, get $2 off by using code “zcmini”.

 

discuss video in the forum

9 Responses to “Writing a Zend_Auth_Adapter with Doctrine”

  1. [...] ZF Authentication using Doctrine January 24th, 2010 by Jim Li Leave a reply » As one of my everyday morning tasks, I just checked the rss feeds from my news reader. Interesting enough, one of my favourite blog authors, Jon Lebensold from ZendCasts, just published a new post on “Writing a Zend_Auth_Adapter with Doctrine“. [...]

  2. marsbomber says:

    Hi Jon,
    I’ve tried to implement my doctrine auth adapter base on Palo Verede’s post a while back. but I had some issues with it myself. It’s great to see you showing us how to make a working solution from zendcasts.

    However there’s something I want to share with the rest of the community too. My made an implementation with the use of ZendX_Doctrine_Auth_Adapter from the ZendX incubator.

    Because of the length of the explanation, instead of posting my alternative solution here, I’ve just written a blog post at http://blog.elinkmedia.net.au/2010/01/24/zf-authentication-using-doctrine/

    It’ll be great if I can get your opinions on my implementation.

  3. jon says:

    Hy Jim,

    I think you put together a great post with a solid implementation. My only comment is that with this design, you’ve now coupled the object creation code to your Controller. On Monday I’ll be posting the IndexController code that will actually use the Zend_Auth_Adaoter written in this tutorial. I’d prefer this approach simply because after you’ve performed the authenticate() method, you don’t have to do any storage->write() business, but simply let Zend_Auth do its thing.

  4. marsbomber says:

    Hi Jon,

    You are spot on. I should be able to pull logic inside the _getAuthAdapter function out of the controller, and put in a login service class, or something like that. What do you think?

  5. [...] Writing a Zend_Auth_Adapter with Doctrine [...]

  6. [...] from the ZendCasts.com site today there’s this new screencast looking at the integration of the Zend_Auth_Adapter component of the Zend Framework and the [...]

  7. Jasper says:

    These tutorials are very useful… I’m going through all of them and really appreciate the level of detail.

    Keep up the good work!
    Jasper

  8. [...] Jon Lebensold hat ein weiteres Video veröffentlicht, dieses Mal über einen Zend_Auth_Adapter für Doctrine [...]

  9. John says:

    Hey,

    Really great tutorials!

    I downloaded the source code and I got a mysql error when trying to reload the tables. The mysql string was output to the cmd prompt, so I copied it into mysql query browser.

    I started with, create table user, as was shown in the command prompt, but i noticed that user was a reserved mysql word, I tried putting user in backticks in the yml, but that actually created a file called `user`.php… Alas, I just changed schema.yml to create userS, and everything worked great. You the man, Jon!

Leave a Reply

Desktop RSS feed iPhone + iPod