Migrating your cakePHP 1.1 application to 1.2 - Chapter 1 Configuration Changes
Please note that this article is intended for audiences that already have a decent understanding of the cakePHP frame work and essentially know where to look to make the necessary changes to the web application that you have already coded for the 1.1 framework.
So you have decided to migrate your cakePHP site from version 1.1 stable to the latest and greatest version 1.2. There have been several changes to the frame work since 1.1 and some for the better. From what I can tell in the RC2 candidate that we have used on several projects here is that the frame work has been sped up, and a fair amount of the overhead with database queries has been optimized.
I have spent about a weeks worth of time getting a version 1.1 site to come forward to the RC2 candidate, and for the most part it was a fairly painless process. However, it can be tedious, and sometimes finding every thing in all the views, and controllers can feel at times daunting. However, with some perseverance and attention to error messages that are produced with debug turned on you can work through this.
I would recommend that you make backups of the /app and /cake directories before starting this task, and then unpack the cakePHP distribution in the same base directory as the /app and /cake directories, then do the configuration changes listed below, then slowly start bringing your controllers, models, views, etc and working through the errors.
Chapter 1 - Base configuration changes
These changes are fairly straight forward and easy to make, the only two files that need to change are core.php and routes.php in the /app/config directory where ever your base cakePHP installation lives.
Changes to core.php, I would recommend just using the default one that comes with the cakePHP distrubution and incorporate your specific changes to the file. The biggest change to the core.php file is that the php function define is used much less in favor of the Configure object. Now you can just leave your configuration file the way it is, but doing so can result in strange behaviour on down the line, so it would be recommended that you upgrade this file, and if you have some application specific things that need to be defined put them here.
Changes to routes.php, this change is MUCH simplier than the changes required for core.php, in version 1.1 the connect function was not static and therefore the frame work needed to instantiate a single Router class in order to provide the connect function. In version 1.2 the function has been made static and the only real change that needs to happen in your routes.php file is to change all instances $Route->connect to Router::connect in the file and save off.
Finally if you have the rewrite engine enabled for the web server that this is running on, ensure that the .htaccess files are set up properly in the base web directory for the application, all the way down to the webroot directory for the cakePHP application. In the web server web root directory and the /app directory make sure the following lines are in your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
finally make sure that you use .htaccess file that comes with the distrubution in the webroot directory or make sure that it has these lines in it.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
There shouldn’t be any other configuration changes that you need to make, just make sure that you have all the configuration files copied over from your old application (mainly database.php, and with the exception of the core.php and routes.php that were changed previously). If you have done everything properly, you should have the default cakePHP home page that states all is well, or you need to fix something (usually permissions changes to the /app/tmp directory). That should be it for the configuration changes, next Chapter we will discuss the changes to the model that have been made and how this will affect your controllers and views.