将php项目移动到codeigniter或更新现有框架 [英] Moving a php project to codeigniter or updating the existing framework

查看:164
本文介绍了将php项目移动到codeigniter或更新现有框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出最好的办法来处理一个php项目。它是几年前建立在一个自定义框架 - 框架是不严格的MVC ...它只是有控制器和视图和库。



在附加的功能,它开始感觉非常像一个完整的混乱,旧代码和新的代码混在一起,没有体面的数据库管理。



我在努力决定我最好的选择是什么。一方面,我可以继续修补现有的代码库,希望我可以使它更有用和未来保护,或移动到codeigniter(注意:我说codeigniter,因为我有相当多的经验)。



Codeigniter选项显然意味着我必须通过一切,毫无疑问将是一个相当大的重新编码,但是从长远来看,它可能是值得。



还有另一个选择,我正在考虑,这是Laravel框架。我没有直接的经验,但我听说Laravel 4(尚未发布)应该是优秀的。



所以,把这三个选项放在桌子上,你会选择和为什么?我正在寻找一个令人信服的理由选择一个在另一个,坦率地说,我没有一个线索我最好的目前采取的路线。

解决方案

简短答案:





我得到的印象是,你很困惑,哪些问题框架旨在解决。当您使用框架时,您所获得的是简化应用程序的开发较短。你总是松散的是性能,通常是可维护性。



框架旨在为您提供解决简单问题的工具。这意味着有很多事情,你不需要。还有一些问题,框架不能解决,或者甚至积极阻碍你的努力在解决方案。



你应该做什么..



重构你的代码。



如果你一直在项目上工作很长时间,你会有很多的教训,从这个经验中学习。




  • 如果您的架构存在缺陷:重组损坏的部件 li>
  • 如果您不确定是否有效:添加unittests


  • 如果您不知道有什么事情,请进行代码编写和优化 ul>

    这样,你将提高你的项目和你的技能。


    PS

    即使您正在开始新项目,我也建议避免使用这两个框架。他们都充满了坏的做法和更糟糕的代码:全球状态无处不在,程序性程序设计,误解MVC,无视OOP原则和法律。



    I'm trying to figure out the best way to handle a php project going forward. It was built a few years ago on a custom framework - the framework wasnt strict MVC...it simply had controllers and views, and libraries.

    I've since added in additional functionality and it's starting to feel very much like a complete mess, with old code and new code mixed up, and no decent database management.

    I'm struggling to decide what my best option is. On the one hand, I could keep patching the existing codebase in the hope that I can make it somewhat more usable and futureproof, or move to codeigniter (note: I say codeigniter as I've got a fair amount of experience with it).

    The Codeigniter option would obviously mean I'd have to go through everything, and there will no doubt be a fair amount of recoding, however in the long term it may be worth it.

    There was another option I was considering, and that was the Laravel framework. I have no direct experience with it, however I hear that Laravel 4 (not released yet) is supposed to be excellent.

    So, putting those three options on the table, which would you pick and why? I'm looking for a compelling reason to choose one over the other, as quite frankly I dont have a clue which route I'm best taking at the moment!

    解决方案

    Short answer: neither.

    Now a bit longer version..

    I get the impression, that you are confused about, which problems frameworks aim to solve. When you use a framework, what you gain is shorter development for simple applications. What you always loose is performance and, usually, maintainability.

    Frameworks are made to provide you with tools for solving simple problems. Which means that there is a lot of thing's, that you do not need. And there is also problems, that frameworks do not solve or even actively hinder your efforts in making a solution.

    What you should do instead..

    Refactor your code.

    If you have been working on the project for long time, you will have a lot of lessons, that you learned from this experience. Utilize them by improving the existing codebase.

    • if there are flaws in your architecture: restructure broken parts
    • if you are not sure, whether something works: add unittests
    • if something seems to be slow: profile you code and optimize
    • if you do not know what something does: find out and add comments

    This way you will enhance both you project and your skills.

    P.S
    Even if you were starting new project, I would recommend to avoid both frameworks. They both are filled with bad practices and worse code: global state everywhere, procedural programming, misinterpretation of MVC, disregard for OOP principles and laws.

    这篇关于将php项目移动到codeigniter或更新现有框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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