您如何将旧的OOP PHP项目转换为Yii Framework? [英] How do you convert an old OOP PHP project into the Yii Framework?

查看:77
本文介绍了您如何将旧的OOP PHP项目转换为Yii Framework?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一个有效的OOP网站.大部分php与html分开.我想知道是否有人对如何将该网站应用于Yii框架有任何提示.

I already have a working OOP website. Most of the php is separated from the html. I was wondering if anyone had any tips on how to apply that site into the Yii Framework.

修改

该网站使用jquery,html,css,php,javascript.它还由我从代码峡谷购买的许多库和类组成.像地理位置库一样,phpthumb(图像缩略图)也很喜欢和不喜欢系统.如何将这些库导入Yii?

The website uses jquery, html, css, php, javascript. It also consists of a lot of libraries and classes I bought of code canyon. Like a geolocation library, phpthumb (image thumbnails), like and dislike system. How does one go about importing these libraries into Yii?

推荐答案

一年前,我完成了类似的任务,但是代码根本不是面向对象的.我创建了一个新的Yii项目,并将旧站点作为lib放置在该项目中.然后,我在Yii中设置了数据库访问之类的基础知识,在两个项目中都需要会话值等等.然后,我逐个路线,逐个特征地移植了路线.花了一些时间,但是效果很好.我只是有一个引导脚本,该脚本基于"ported_routes"路由请求.

I had a similar task a year ago, but the code wasn't really OO at all. I created a new Yii project and placed the old site as a lib in the that project. I then set up the basics in Yii like database access, whichever session values were needed in both projects etc. I then ported route by route, feature by feature. It took some time, but it worked out really well. I just had a bootstrap script which routed requests based on "ported_routes".

在重用类时,如果它们的结构合理且不依赖于旧代码,那应该不是问题. Yii对这些东西没有任何限制,因此只需将它们添加为lib或浏览Yii文档,看看是否有必要将它们重构为Yii组件或在其中子类化.

When it comes to reusing classes that should not be a problem if they are well structured without dependencies on the old code. Yii places no restrictions on that stuff, so just add them as libs or browse through the Yii docs and see if it makes sense to refactor them into Yii components or subclass something in there.

对于使用LESS和较新的JS库从skratch重做的CSS和JS.自编写原始代码以来,JS世界发生了很多事情. Yii也不要求您遵循任何预定的标记结构,因此从理论上讲,除非您想更改标记的基础知识,否则您应该可以使用旧的CSS.

As for CSS and JS that was redone from skratch, using LESS and newer JS libs. A lot had happened in the JS world since the original code was written. Yii does not require you to follow any predetermined structure for markup either, so in theory you should be able to use the old CSS unless you want to change markup fundamentals.

如果您的旧代码具有类似MVC的结构,则动作和视图的移植会更加顺畅,但是无论如何,我想都应该采用类似的方法.

If your old code has a MVC-like structure the porting of actions and views will go smoother, but regardless you are pretty much left with a similar approach I think.

这篇关于您如何将旧的OOP PHP项目转换为Yii Framework?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆