12
12/07
9:31 pm
The easiest way to upgrade CodeIgniter
One of the biggest problems with developing websites using CodeIgniter is having to upgrade the framework. It’s always a pain when you have to remember to overwrite this and modify that…
I’ve been using an extremely simple technique for quite some time. I’m not sure if this has been posted elsewhere, but I figure it could be useful for many other developers out there.
To start, it’s always very important to read the CI upgrading document. In most cases, you won’t need to follow their upgrading procedure, but it’s always best to check first.
In order for this to work, you have to make sure all your custom files are in the application directory. If you created a custom Benchmark.php and placed it in system/libraries/, then you’ll need to move it into application/libraries/. Ideally you want to keep all the files you create/modify within the same application directory. This makes upgrading a lot easier.
Let’s assume your directory structure looks like this:
/myapp/system/
/myapp/system/application/
/myapp/user_guide/
1. Move the application directory into /myapp/ and name it something like app_myapp
2. Create a directory called codeigniter and place it in /myapp/
3. Move the system and user_guide directories into /myapp/codeigniter/
4. Modify /myapp/index.php and set the following variables:
$system_folder = "codeigniter/system";
$application_folder = "app_myapp";
5. Test your app, you shouldn’t notice a difference.
What we did was simply move the application directory outside codeigniter, giving us the freedom to change framework versions on the fly. Now, when a new version of CodeIgniter is released, you simply have to extract the new version into /myapp/, delete the codeigniter directory, and rename the extracted directory (i.e: CodeIgniter_1.5.4) to codeigniter.
No need to modify any files.
This procedure might not work for everyone, so please post any questions/problems in the comments and i’ll gladly help. I can’t take the blame if you screw up your app, but i’ll take all the credit if this saves you some time/frustration/headaches :D
PS: Derek just released an awesome new version of BambooInvoice. Check it out!
Cheers!