Migrating from CakePHP 1.2.7 to 1.3

I decided to migrate one of my in-progress projects to the latest release of CakePHP (1.3). My experience was quick and painless, and perhaps this writing will benefit someone.

Copy/Overwrite

Copy/overwrite app/config/core.php, in this file change the following

  • Change cipherSeed value to something other than the default
  • Change the salt value to the same value you had before

Copy/overwrite app/webroot/index.php

Lastly, completely copy over the latest cake, plugins and vendors folders. I didn’t need to do any other modifications to the app folder other than those stated above.

Add to Code

Add ‘Session’ to the helpers AND components array in app/app_controller.php like so

<?php
class AppController extends Controller {
	var $components = array( ..., 'Session');    // Components used in controllers
	var $helpers = array( ..., 'Session' );         // Helpers used in views
}
?>

Also,
If using the Cookie Component anywhere, change any reference to del() to delete()

Lastly, $session->flash() no longer auto echoes (this code is probably in your layout). I had to change it like so in my code:

<?php
echo $session->flash();
echo $session->flash('auth');
?>

Debug Information

The variable $cakeDebug no longer exists. Instead, use the following code

<?php echo $this->element('sql_dump'); ?>

That’s all I had to do! Everything I mentioned here can be found in the CakePHP migration guide.

One Response to “Migrating from CakePHP 1.2.7 to 1.3”

  1. Lapinski Says:

    I also tried to migrate to 1.3.

    I used some logic in beforeValidate() to determine if the data gonna saved should be an update or an insert, if update then set $model->id. It worked perfectly for 1.2, but not in 1.3. So I guess the 1.3 CakePHP team assumes you have to know whether it’s an update or insert before you call validate/save.

Leave a Reply