Upgrade from CakePHP 1.3 to 2.5,cakephp1.3 upgrade 2.5_php tutorial

Source: Internet
Author: User

Upgrade from CakePHP 1.3 to 2.5,cakephp1.3 upgrade 2.5


Upgrade from CakePHP 1.3 to 2.5

Absrtact: Recently upgraded a cakephp 1.3 project to 2.x, of course, with the latest version 2.5.3, the results are basically satisfactory. This document documents the process of upgrading, including the tools used, the problems encountered, and the corresponding workarounds.

This article involves at least the level of cakephp intermediate, if you are just beginning to use cakephp, it is recommended not to make such an attempt, or encounter problems do not know how to solve.

Directory

1. Why upgrade

2. Project Overview

3. Tools to use

4. The process of upgrading

5. Problems encountered after upgrade and how to resolve them

A. References

1. Why upgrade

Upgrading to the latest version has many benefits, you can get the latest updates and features, you can use the debugging tools such as Debugkit, you can use the view block to conveniently put CSS and JavaScript in the page where you want, rather than painfully limited by the old way, and so on. View block has always been the feature I want to use most.

2. Project Overview

The development of this project started roughly at the end of 2012, and I began to participate in the middle of 2013, and in 2014 years all the user-requested functionality was basically complete. I've been involved for about 1 years, just using my spare time. The code was initially copied from a cakephp 1.3 project without the use of the latest 2.x version, which also allowed many development efforts to extend the development cycle with the latest features and tools of the framework. It can be said that the project has made the wrong choice from the start. has participated in the development of 6 people before and after, most of them temporarily caught, most people do a period of time will leave, and some functions have not even finished to leave. And there is no deep understanding of cakephp's framework, resulting in no consistency in the code of the project, and a lack of unified planning, architecture and specification, and no unit testing. In summary, the code quality of the project is unsatisfactory. These are probably some of the problems that most amateur projects are hard to avoid.

Fortunately, this project is not particularly complex, with the following:

    • There are 36 tables in the database
    • 19 Controllers (Controller)
    • (model) of 33 models
    • 63 Views (view)
    • 2 Plugins (Plugin)
    • Of course, there's something else.

This data shows the size of the project, it should be said to be a small and medium-sized website.

3. Tools to use

The upgrade uses only 2 tools, first the official upgrade Shell, and the Dereuromark upgrade Plugin.

4. The process of upgrading

I spent some time reading the documentation listed in the resources before I actually upgraded it, and it took a total of 4 days before and after the actual upgrade process, but a considerable amount of time was spent on post-upgrade testing and finding ways to solve the problem. After all, I began to use PHP and cakephp to develop the actual use of the site from 1 years ago, and only use spare time, so time is limited, a lot of things are doing while groping learning, the main goal is to complete the requirements of user requirements of the function, too late to understand the various aspects of cakephp framework. This process can be much faster if you have experience, or if you have the knowledge to address the issues covered below.

4.1 Backup

First, make sure that your application runs well before you upgrade, and that you do a good job of backing up your code and data. If there is no backup, please stop!!!

I use Git (tortoisegit) to do source control, which allows me to go back to a certain point in time. The database uses MySQL, and the backup should be done before the upgrade. If the upgrade process is out of the question and does not go down, the backup allows you to revert to the state before you started the upgrade, and if there is no backup, you are in a dilemma.

4.2 Updating CakePHP's core library to 2.x

This project is in the directory structure before the upgrade, as shown in

In the diagram, cake is the core library of CakePHP 1.3, and the app is the application code.

To download the latest cakephp, I'm using 2.5.3, which opens the zipped package as shown in.

The Lib directory in the diagram is the core repository of cakephp, copy this lib directory to the root directory, then delete the 1.3 cake directory, and get the directory structure as shown.

The Lib\cake directory in the figure is the core library of CakePHP 2.x.

4.3 Preparing the Upgrade tool upgrade Shell

The Upgrade shell is part of CakePHP's core, and in the lib\cake\console\ directory, just make sure that you can run the cakephp console executable, which you can refer to from the CakePHP console documentation. As shown,

The cake in the figure is the executable file under *nix, Cake.bat is the executable file under Windows. My practice is to refer to the Upgrade Shell document, copy the Lib\cake\console\ directory to the app directory, so that only the command line path is executed differently, the result is the same as shown.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.