Things I love about CakePHP

I’ve been developing with CakePHP for about 2 weeks now. Figured I’d post 10 reasons I love CakePHP:

  1. Model-View-Controller Architecture
    After hard-coding a million failed dynamic websites, it was refreshing to learn about MVC programming. Rather than fretting about data, presentation, and logic at the same time, Cake separates these into individual parts. Specify your data, implement the logic, create a view. A chimp could do it.
  2. Pages Controller for static content (with support for hierarchies)
    In all of this dynamic insanity, it’s nice to have a pre-coded controller for managing static pages. Every site has static pages (about, contact, etc.) The pages controller allows for these parts to be added simply to the rest of your more complex project.
  3. Easy as pie (or cake) Authorization component
    While coding authentication modules may not be the worst thing one could be tasked with, CakePHP makes it irrelivant. In about 10 lines of code you can have a simple login system up and running, blocking the outside world from whatever you don’t want them to see. By default the Auth component blocks all methods in a controller unless you explicitly allow them. This makes it less likely for methods specified later on the be accidentally open to the public (unless of course you want that).
  4. Router for clean, tidy, and powerful URL handling
    Cake has a rather straightforward URL convention as it is, but if you don’t like it, Router allows you to change it however you like.  It allows you to link specific urls or patterns to specific controllers. The possibilities with this are limitless, and I know I’ve barely scraped the capability of this module. Sure beats tearing your hair out over .htaccess files all day.
  5. Components, Behaviours, Layouts, and Helpers
    Components share logic between controllers. Behaviours add functionality to models. Layouts allow re-use of code in views. Helpers just help with everything from forming links to creating forms (and more).
  6. Clean Conventions for Everything
    Cake’s power is in its strict conventions. A lot of overhead is saved by enforcing a strict set of rules regarding how you use it. This allows the framework to make a large number of assumptions about your application, saving you the time it takes to explicitly specify such things. It can be frustrating at first, but as you pick each bug out of your code, you become more familiar with these guidelines in an intuitive way.
  7. Dead Simple Installation
    Copy, Paste, open up 2 text files,  set up your database connection, and change the security salt value (I believe it’s used in hashes). You’re rolling (assuming Apache has all the needed modules running, mod_rewrite being the key to Cake’s awesome URL magic).
  8. Admin Routing
    So you have say a song controller, and an edit method. We access it at http://%cakedomain%/songs/edit/.  For normal authenticated users, this will display the edit page. Say you had additional parameters that couldn’t be edited by standard users though. Enter admin routing. Now at http://%cakedomain%/admin/songs/edit/, we will be forwarded to the admin_edit() method of the songs controller. No need to code any fancy access control or custom control panels (although you could rather simply, or just use Routing). Very sexy.
  9. The all-mighty beforeFilter() function
    Want to run a set of logic before each controller method is called? Done. Useful for allowing certain pages without authorization in conjunction with the Auth module.
  10. The webroot folder
    Keep all your CSS, Images, and JS in one location. Easily reference all these files without getting tangled up in hideous piles of path. One advantage to this is that your CSS files can be static, as the path to the respective image resources is constant.

I’m enjoying this thoroughly.

Advertisement

0 Responses to “Things I love about CakePHP”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s





Follow

Get every new post delivered to your Inbox.