Table of Contents
从CakePHP 1.3升级到2.5,cakephp1.3升级2.5
从CakePHP 1.3升级到2.5
目录
1. 为什么要升级
2. 项目概况
3. 使用的工具
4. 升级的过程
4.1 备份
4.2 更新CakePHP的核心库到2.x
4.3 准备升级工具Upgrade Shell
Home Backend Development PHP Tutorial 从CakePHP 1.3升级到2.5,cakephp1.3升级2.5_PHP教程

从CakePHP 1.3升级到2.5,cakephp1.3升级2.5_PHP教程

Jul 13, 2016 am 10:21 AM
cakephp upgrade

从CakePHP 1.3升级到2.5,cakephp1.3升级2.5

从CakePHP 1.3升级到2.5

摘要:最近把一个CakePHP 1.3的项目升级到了2.x,当然就用最新的版本2.5.3了,结果基本满意。本文记录了升级的过程,包括使用的工具,遇到的问题和相应的解决方法。

这篇文章涉及的内容要求至少有CakePHP中级水平,如果你是刚开始使用CakePHP,建议先不要作这样的尝试,否则遇到问题都不知道怎么解决。


 

目录

1. 为什么要升级

2. 项目概况

3. 使用的工具

4. 升级的过程

5. 升级之后遇到的问题及解决方法

A. 参考资料


 

1. 为什么要升级

升级到最新版本有很多好处,可以得到最新的更新和功能,可以使用DebugKit这样的调试工具,可以使用View Block方便地把CSS和JavaScript放在页面中你希望的地方,而不再痛苦地受限于旧的方式,等等。View Block一直是我最希望使用的特性。

2. 项目概况

这个项目的开发大致起始于2012年底,我从2013年中开始参与,到2014年中,所有用户要求的功能基本都完成了。我参与了大概1年左右,只是利用业余时间进行。代码一开始是抄自于一个CakePHP 1.3的项目,而没有使用当时最新的2.x版本,这也使得许多开发工作不能利用框架最新的特性和工具,延长了开发周期。可以说,这个项目从开始就做了错误的选择。先后参与的开发人员前后有6个人之多,多数是临时抓来的,大部分人做一段时间之后就会离开,有些功能甚至没有完成就走人了。而且大家对CakePHP这个框架没有深入的了解,导致这个项目的代码没有一致性,也缺乏统一的计划、架构和规范,没有单元测试。总之,项目的代码质量是不能令人满意的。这些恐怕是大部分业余项目难以避免的问题。

幸好,这个项目不算特别复杂,计有:

  • 数据库有36张表
  • 19个控制器(Controller)
  • 33个模型(Model)
  • 63个视图(View)
  • 2个插件(Plugin)
  • 当然还有其他一些东西

通过这些数据可以看出这个项目的规模,应该说是个中小型网站吧。

3. 使用的工具

升级只使用了2个工具,首先是官方的Upgrade Shell,以及DerEuroMark的Upgrade Plugin。

4. 升级的过程

真正动手升级之前我花了一些时间阅读参考资料中列出的文档,实际的升级过程前后总共花了4天时间,不过这里面相当一部分时间用于升级后的测试、以及寻找解决问题的方法。我毕竟从1年前才开始真正使用PHP和CakePHP来开发实际使用的网站,而且只是利用业余时间,所以时间有限,很多东西也都是边做边摸索学习,主要目标是要完成用户需求所要求的功能,来不及了解CakePHP框架的各个方面。如果你有相应的经验,或者有解决下面所涉及问题的这些知识,这个过程会快许多。

4.1 备份

首先,确保升级之前,应用程序运行良好,做好代码和数据的备份。如果没有备份,请就此打住!!!

我使用Git(TortoiseGit)做源码控制,这让我可以随时回到过去某一个时间点。数据库使用的是MySQL,升级之前也要做好备份。如果升级过程出了问题,进行不下去,备份让你可以恢复到开始升级之前的状态;如果没有备份,那你可就进退维谷了。

4.2 更新CakePHP的核心库到2.x

这个项目在升级前的目录结构,如下图所示,

cake为CakePHP 1.3的核心库,app是应用程序代码

图中,cake为CakePHP 1.3的核心库,app是应用程序代码。

下载最新的CakePHP,我用的是2.5.3,打开压缩包,如下图所示。

lib目录即是CakePHP 2.x的核心库

图中的lib目录就是CakePHP的核心库,把这个lib目录拷贝到根目录下,然后删除1.3的cake目录,得到如下图所示的目录结构。

lib\Cake目录就是CakePHP 2.x的核心库

图中的lib\Cake目录就是CakePHP 2.x的核心库。

4.3 准备升级工具Upgrade Shell

Upgrade Shell是CakePHP核心的一部分,位于lib\Cake\Console\目录下,只需确保能够运行CakePHP Console可执行文件就可以了,这可以参考CakePHP Console的文档。如下图所示,

cake是*nix下的可执行文件,cake.bat是Windows下的可执行文件

图中的cake是*nix下的可执行文件,cake.bat是Windows下的可执行文件。我采用的做法,是参考了Upgrade Shell的文档,把lib\Cake\Console\目录拷贝到app目录下,这样只是执行的命令行路径有所不同,结果是一样的,如下图所示。

从CakePHP 1.3升级到2.5,cakephp1.3升级2.5_PHP教程

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Several methods for upgrading Python version in Conda Several methods for upgrading Python version in Conda Feb 18, 2024 pm 08:56 PM

Several methods for Conda to upgrade the Python version require specific code examples. Overview: Conda is an open source package manager and environment management system for managing Python packages and environments. During development using Python, in order to use a new version of Python, we may need to upgrade from an older Python version. This article will introduce several methods of using Conda to upgrade the Python version and provide specific code examples. Method 1: Use the condainstall command

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

Upgrading numpy versions: a detailed and easy-to-follow guide Upgrading numpy versions: a detailed and easy-to-follow guide Feb 25, 2024 pm 11:39 PM

How to upgrade numpy version: Easy-to-follow tutorial, requires concrete code examples Introduction: NumPy is an important Python library used for scientific computing. It provides a powerful multidimensional array object and a series of related functions that can be used to perform efficient numerical operations. As new versions are released, newer features and bug fixes are constantly available to us. This article will describe how to upgrade your installed NumPy library to get the latest features and resolve known issues. Step 1: Check the current NumPy version at the beginning

Tutorial on how to solve the problem of being unable to access the Internet after upgrading win10 system Tutorial on how to solve the problem of being unable to access the Internet after upgrading win10 system Mar 27, 2024 pm 02:26 PM

1. Use the win+x shortcut key to open the menu and select [Command Prompt (Administrator) (A)], as shown below: 2. After entering the command prompt interface, enter the [ipconfig/flushdns] command and press Enter , as shown in the figure below: 3. Then enter the [netshwinsockresetcatalog] command and press Enter, as shown in the figure below: 4. Finally enter the [netshintipreset] command and press Enter, restart the computer and you can access the Internet, as shown in the figure below:

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

Detailed explanation of how to upgrade Honor mobile phones to Hongmeng system Detailed explanation of how to upgrade Honor mobile phones to Hongmeng system Mar 25, 2024 am 11:51 AM

In a new technological field, new operating systems always attract much attention. Recently, Honor mobile phones announced that they will be upgraded to Hongmeng OS, a new operating system developed by Huawei. This is undoubtedly good news for many Honor mobile phone users. However, many users may still have doubts about how to upgrade to Hongmeng system. This article will explain in detail how to upgrade Honor mobile phones to Hongmeng system to help users better understand and operate it. First of all, to upgrade an Honor phone to the Hongmeng system, users need to ensure that the phone is connected to the network and has sufficient power. this

How to upgrade wps version? How to update the version of wps office? How to upgrade wps version? How to update the version of wps office? Mar 14, 2024 am 08:43 AM

WPS is a must-have computer software for many users. Regular updates to new versions can allow users to get a better user experience and more features. So how to upgrade the wps version? There are three main methods for upgrading wpsoffice. Let’s take a look below. Method 1: Download the new version from the official website You can download the latest version of the installation package from the WPSOffice official website. After entering the WPSOffice official website (https://www.wps.cn/), click the "Download" button, select the version you need to download, and then follow the prompts to install it. Note: When installing a new version, you need to uninstall the old version, otherwise it will cause software conflicts and prevent normal use. Method 2: In WPSOf

Xiaoyi upgraded to an intelligent agent! HarmonyOS NEXT Hongmeng native intelligence opens a new AI era Xiaoyi upgraded to an intelligent agent! HarmonyOS NEXT Hongmeng native intelligence opens a new AI era Jun 22, 2024 am 01:56 AM

On June 21, Huawei Developer Conference 2024 (HDC2024) gathered again in Songshan Lake, Dongguan. At this conference, the most eye-catching thing is that HarmonyOSNEXT officially launched Beta for developers and pioneer users, and comprehensively demonstrated the three "king-breaking" innovative features of HarmonyOSNEXT in all scenarios, native intelligence and native security. HarmonyOSNEXT native intelligence: Opening a new AI era After abandoning the Android framework, HarmonyOSNEXT has become a truly independent operating system independent of Android and iOS, which can be called an unprecedented rebirth. Among its many new features, native intelligence is undoubtedly the new feature that can best bring users intuitive feelings and experience upgrades.

See all articles