Migrating a CakePHP 1.3 app to CakePHP 2 – a few gotchas

Firstly, make sure you read the 2.0 Migration Guide.

Then follow the instructions for using the Upgrade shell.

Having done this I found there were a few things that the shell hadn’t done:

  1. The app/Controller directory should contain AppController.php and PagesController.php (in addition to your newly renamed controllers). In my case these files weren’t copied across so I had to do this manually from the source tarball.
  2. The app/Model directory should contain AppModel.php but I had to copy this myself.
  3. Similarly, the shell didn’t replace my old copies of app/webroot/index.php or app/webroot/test.php so I had to do this by hand.
  4. I needed to merge changes in:
    • app/Config/core.php
    • app/Config/database.php
    • app/Config/routes.php
  5. The shell doesn’t rename the test directories to conform to the new naming conventions although this doesn’t seem to be a problem (although it’s worth doing anyway).
  6. The shell doesn’t warn you if you use anything that has been removed in version 2. For example, I used the JavaScript helper in my 1.3 app but this isn’t present (has been merged with the HTML helper) in v2

Also, if you get an error that looks like:

Notice: Undefined index: Error in /lib/Cake/Core/Configure.php on line 100

then it’s likely that you haven’t updated your app/Config/core.php file (diff the file with the one in the new tarball to find things that are new or updated).