Published: Friday, January 11th, 2008

This is the second installment of my Auth Component Tutorial. I included a link to download a file for during the first installment:

Download: CakePHP Auth 1  CakePHP Auth 1 (4.3 KB, 1,631 hits)

I just think that some of the stuff in there warrants some explanation.

isAuthorized()

This function is needed when $this-Auth->authorize = ‘controller’. Theory has it, you can do something similar in app_model if $this-Auth->authorize = ‘model’, but I haven’t looked into this.

The thing that confused me about this is that I thought you were required to perform your own validation. But oh no, this is additional authorization. Sort of like what beforeSave() does, where you can cancel the save after the validation. isAuthorized() is performed after the user has been logged in. If after that, you need some additional stuff, then you can put it in there. I’m not sure why it doesn’t default to return true like beforeSave() (if everything goes well), but if it’s not present, it errors out.

$this->Auth->user(’group_id’)

In my User Model I have a field called group_id. So you guessed it, this just returns the group_id of the user that’s logged in. Things couldn’t be simpler.

If you're new here, you may want to subscribe to my Full RSS feed. Thanks for visiting!



Published: Tuesday, January 8th, 2008

First off, I would like to say much thanks to Gwoo for finally helping me to understand this thing.

So I know what you're thinking; I'm probably the last person to finally figure out the CakePHP's Auth Component. For the past few months, I've been using obAuth because that's the only authentication I could get to work with CakePHP. I think that I was just making it more difficult than it should have been.

My main resource for learning the Auth Component has been Chris's tutorial, but even then I still needed help. Also, I'm the type that doesn't really learn much without code.

Note that I'm running off of the CaekPHP 1.2 beta.

Getting Started

Now you can modify this however you like, but I'm starting out with the basics. You're going to need the following:

  • A user database with fields username, password. Of course they don't need to be named that way, but defaults are fun.
  • A User Model with Controller and Views - This can be baked from CakePHP
  • A login view for the user.
  • And a base app_controller.php. That's it.

The Setup - app_controller and users_controller

So here's the minimum in app_controller:



Published: Monday, January 7th, 2008

So I guess the CakePHP development staff doesn't take any holidays. Bright and early New Years Day 2008, we're greeted with a fresh new release of CakePHP 1.2.6331 beta. No, not pre-beta a full blown beta. Needless to say I'm excited about this.

There have been some nice changes which have gone through all through the Christmas season. Guys, I thank you for your dedication. The one major thing I'm excited about is the way that the Form Helper now processes dates and times; there's no longer a cleanUpFields() function, everything is automatic (or should I say automagic). You'll have modify your code since the result in $this->data is slightly different. There's been some stuff deprecated and some stuff added.

The Model::generateList() function has also be deprecated, in favor of Model::find('list'). It's not an exact duplicate of generateList() but it gets the job done. Check out the cakebaker for more essential tips for upgrading from CakePHP 1.2 pre-beta to the fresh new CakePHP 1.2 beta.

Enjoy and Happy Baking!

Popularity: 46%



Published: Tuesday, January 1st, 2008

One problem that I've always had with finding CakePHP related information over the internet is the multiple sources. I wouldn't so much mind if all these sources were legit. The thing that pisses me off is those scrapers who scrape the entire CakePHP mailing list. To me, there's nothing worse than asking a question in the mailing list, then searching on Google for an answer, just to find some idiot has scraped your question from the mailing list. I try to report them when I can, but I just can't seem to keep up.

Sorry for the rant, back to my point. Sharan over on the CakePHP mailing list has made the process of finding the latest CakePHP information a lil' bit easier. Using Yahoo Pipes, he's taken feeds the most popular CakePHP RSS feeds and consolidated them into one giant feed - http://feeds.feedburner.com/cakephp. The great thing is that he's also taken some of the non-english blog feeds and slapped on some translation. What more could you want?

I'm not sure how much the author values his privacy, so if you want to get in contact with him and/or view the Yahoo Pipes source for this feed, head over to the CakePHP mailing list and search for: "http://pipes.yahoo.com/sharanbrar/cakephp". If you think that their's a blog missing, just leave a comment here and I'll route it to the author.



Published: Friday, December 28th, 2007

One of the nice things about CakePHP is that it includes ready to use CSS compression. Granted, compressed CSS can be buggy at times, but for the most part it works just fine.

I've always wondered why no one has included something like this for Javascript, since that's usually the bigger culprit when we're talking about document size. I've tried using Minify in the past. However, it took a lot to get it working right. And I really hate hacking stuff just to work with CakePHP. That, coupled with the fact that I'm a lazy bastard, meant that I gave up the Minify train rather quickly.

Mark Story To The Rescue - JSMIN Javascript Helper

At the time, I hadn't heard about the JSMIN library, which does pretty much the same thing the Minify does, but without the CSS. Luckily, Mr. Story had some vision after his Christmas festivities and cake up with a JSMin Helper for CakePHP. This helper works by Minifying the chosen Javascript. This involves stripping unnecessary characters (line breaks, comments, spaces, etc) from the .JS file.

It also includes functionality to cache the resulting files. What more can you ask for?

Usage:



Published: Friday, November 30th, 2007

Prototype: Image by robdup

Before I start let me say that CakePHP is great. I love it to death. Currently, I'm coding a semester long class project for a friend. I'm trying to illustrate just how much faster it is to create a web application using CakePHP than anything else the other students are using.

The Project

The project consists of computerizing some department of the local university. What she's chosen is to computerize the Audio Visual Department. Specifically the process of submitting equipment requests to the department so they can take the equipment to different classes.

The Competition

The other students are using things like C#, Visual Basic, and other high level programming languages. With all these things, you need to design an interface (and everything else for that matter) from scratch.

You're also on your own when it comes to controls and binding them to the database fields. Not to mention, you need to do all the database relationships by yourself. The other problem is that the project is a multi-user application by definition. That means a central database. This is generally more difficult to implement on a desktop application. The project, to me, just screams Web App!



Published: Friday, November 23rd, 2007

XHTML
Now i doubt it has crossed anyone's mind to use CakePHP to create a custom content management system (CMS). Even though you're not designing a full blown CMS, sometimes it's nice to give novice users a way to create HTML content for a website or web application. The simplest way to do this is to integrate a WYSIWYG (What You See Is What You Get) editor.

When it comes to WYSIWYG editors, they are a dime a dozen. There is of course the world famous TinyMCE. There is already an article in the bakery on how to use TinyMCE with CakePHP. There's htmlArea and even openWYSIWYG.

Although I generally love TinyMCE, for my last project I needed to give the user the option to upload images. FCKeditor is the only editor that offers this functionality for free. Some say that it's bloated, but you can always trim it down to only what you need. Actually the new (October 10th, 2007) version is pretty snazzy. They've done away with the font tag and just made it a lot cleaner.



Published: Wednesday, November 21st, 2007

Oven Knob

Patty Cake, Patty Cake, Baker's Man

One of the things that sold me on CakePHP is the bake routine. This is basically code generation for the lazy types like myself. It was good in CakePHP version 1.1, now it's just awesome. The only way they can make it better is to implement a web version, but that's another story.

What Baking Does

In CakePHP we refer to the automatic code generation as baking (get it now?). An entire application can be baked from nothing more than a few tables in a database. CakePHP uses some skeleton templates, which you can of course customize to your needs, to generate your Models, Views and Controllers. The controllers and views come with the standard CRUD (create, read, update, and delete) functions and can also contain admin functions.

Currently, we run the Bake routine from the command line. I'm hoping sooner or later this can change, but with a lot of hosts allowing shell access to your account, this isn't a priority with the developers.



Pages (3): [1] 2 3 Next Entries »