Setting Up CakePHP with IIS

Published on Jun 11, 2013 by Jamie Munro

Iíve found myself doing this several times over the past little while as I had to switch computers.† Each time I would struggle with a few of the steps, so I thought I would document them this time and share for future me (or you if you like).

Read more >

Tags: CakePHP | php | PHP | mysql | iis | CakePHP

Setting Up CakePHP with IIS

Published on Jun 11, 2013 by Jamie Munro

Iíve found myself doing this several times over the past little while as I had to switch computers.† Each time I would struggle with a few of the steps, so I thought I would document them this time and share for future me (or you if you like).

Read more >

Tags: CakePHP | php | PHP | mysql | iis | CakePHP

Implementing the Repository Pattern with CakePHP

Published on Jun 3, 2013 by Jamie Munro

I must admit, my recent articles are becoming a bit obsessed around the repository pattern.† What can I say, I like it, itís useful, and itís not restrictive based on a language or a framework.

Iíve long professed how I dislike convoluted controllers.† CakePHPís find method almost immediately causes this when used inside a controller.† More importantly, the code inside the find method is extremely unreadable.† This is almost more important than a large controller function!

This is where the repository pattern comes in.† At its most basic example (which some will consider overkill Ė you know who you are), I still think the repository pattern is clearer.

Here is an example using the regular find approach:


$user = $this->User->find('first', array('conditions' => array('id' => $id)));


Compared to a repository example:


$user = $this->UserRepository->GetById($id);


The code is almost identically; however, in the second example, itís clear that if I were to ďreadĒ the code I am retrieving a user by id opposed to Iím finding the first user with the conditions of id being equal to the variable $id.

So if you are sold, letís continue with a full suite exampleÖ

Read more >

Tags: CakePHP | PHP | repository | CakePHP

Implementing the Repository Pattern with CakePHP

Published on Jun 3, 2013 by Jamie Munro

I must admit, my recent articles are becoming a bit obsessed around the repository pattern.† What can I say, I like it, itís useful, and itís not restrictive based on a language or a framework.

Iíve long professed how I dislike convoluted controllers.† CakePHPís find method almost immediately causes this when used inside a controller.† More importantly, the code inside the find method is extremely unreadable.† This is almost more important than a large controller function!

This is where the repository pattern comes in.† At its most basic example (which some will consider overkill Ė you know who you are), I still think the repository pattern is clearer.

Here is an example using the regular find approach:


$user = $this->User->find('first', array('conditions' => array('id' => $id)));


Compared to a repository example:


$user = $this->UserRepository->GetById($id);


The code is almost identically; however, in the second example, itís clear that if I were to ďreadĒ the code I am retrieving a user by id opposed to Iím finding the first user with the conditions of id being equal to the variable $id.

So if you are sold, letís continue with a full suite exampleÖ

Read more >

Tags: CakePHP | PHP | repository | CakePHP

Changes to Model:find('first') in CakePHP 2.3

Published on Jan 30, 2013 by Jamie Munro

A new stable release of CakePHP has just been released a few days ago, version 2.3. †With this many great new changes have come out of it. †You can read the full change log here:
http://bakery.cakephp.org/articles/lorenzo/2013/01/28/cakephp_2_3_0_is_out

One of the things that immediately caught my mind was this great big bolded sentence:
IMPORTANT:Model::find('first')†will now return an empty array when no records are found. Make sure you update your tests!

Immediately after reading this I thought major code changes were going to be required; however, luckily my fear was unfounded. †Let me provide an example...

Read more >

Tags: CakePHP | cakephp 2.3 | CakePHP

Recent Guest Posts on PHPMaster.com

Published on Jan 7, 2013 by Jamie Munro

Recent Guest Posts on PHPMaster.com

Published on Jan 7, 2013 by Jamie Munro

CakePHP 2.x Login System

Published on Sep 18, 2012 by Jamie Munro

CakePHP 2.x Login System

Published on Sep 18, 2012 by Jamie Munro

A Short Rant About Coding Conventions

Published on Sep 13, 2012 by Jamie Munro

What I Learned This Summer

Published on Sep 7, 2012 by Jamie Munro

Officially published my CakePHP Book

Published on May 19, 2011 by Jamie Munro

Officially published my CakePHP Book

Published on May 19, 2011 by Jamie Munro

AJAX Star Rating Plugin For CakePHP

Published on Mar 2, 2011 by Jamie Munro

AJAX Star Rating Plugin For CakePHP

Published on Mar 2, 2011 by Jamie Munro

Publishing an e-book on Smashwords

Published on Feb 7, 2011 by Jamie Munro

Publishing an e-book on Smashwords

Published on Feb 7, 2011 by Jamie Munro

CakePHP 2.0 Rant Retraction

Published on Feb 1, 2011 by Jamie Munro

CakePHP 2.0 Rant

Published on Jan 31, 2011 by Jamie Munro

Using the TextHelper with CakePHP

Published on Jan 24, 2011 by Jamie Munro

Using the TextHelper with CakePHP

Published on Jan 24, 2011 by Jamie Munro

Maintaining the back button with AJAX

Published on Dec 28, 2010 by Jamie Munro

Maintaining the back button with AJAX

Published on Dec 28, 2010 by Jamie Munro

Optimizing CakePHP Websites

Published on Jan 20, 2010 by Jamie Munro

Optimizing CakePHP Websites

Published on Jan 20, 2010 by Jamie Munro

Adding SEO functionality

Published on Nov 15, 2009 by Jamie Munro

Adding SEO functionality

Published on Nov 15, 2009 by Jamie Munro

unbindModel and $this->paginate()

Published on Aug 20, 2009 by Jamie Munro

unbindModel and $this->paginate()

Published on Aug 20, 2009 by Jamie Munro

Photobucket, Photos, and You

Published on May 23, 2009 by Jamie Munro

Facebook, Photos, and You!

Published on May 18, 2009 by Jamie Munro

Caching Queries in CakePHP

Published on Apr 25, 2009 by Jamie Munro

Custom pagination query in CakePHP

Published on Apr 13, 2009 by Jamie Munro

3 Flaws to CakePHP's AuthComponent

Published on Apr 10, 2009 by Jamie Munro

A friendly framework reminder

Published on Apr 1, 2009 by Jamie Munro

A friendly framework reminder

Published on Apr 1, 2009 by Jamie Munro

Unbind Model Validation in CakePHP

Published on Mar 28, 2009 by Jamie Munro

Unbind Model Validation in CakePHP

Published on Mar 28, 2009 by Jamie Munro

Re-map key/value array data in PHP

Published on Mar 19, 2009 by Jamie Munro

Re-map key/value array data in PHP

Published on Mar 19, 2009 by Jamie Munro

How to advance our CMS in CakePHP

Published on Mar 8, 2009 by Jamie Munro

How to advance our CMS in CakePHP

Published on Mar 8, 2009 by Jamie Munro

How to create a CMS with CakePHP

Published on Mar 7, 2009 by Jamie Munro

How to create a CMS with CakePHP

Published on Mar 7, 2009 by Jamie Munro

AJAX Select box in CakePHP

Published on Mar 6, 2009 by Jamie Munro

AJAX Select box in CakePHP

Published on Mar 6, 2009 by Jamie Munro

How to setup a route in CakePHP

Published on Mar 5, 2009 by Jamie Munro

How to setup a route in CakePHP

Published on Mar 5, 2009 by Jamie Munro

Why Frameworks Are Better

Published on Feb 17, 2009 by Jamie Munro

Why Frameworks Are Better

Published on Feb 17, 2009 by Jamie Munro