什么是用于将现有应用程序迁移到的优秀PHP框架?

问题描述:

I've recently come on board with a PHP application. There has not been much design put into the app - there is a front controller, however, view, model and controller code is usually mixed together.

I would like to slowly start refactoring the code beginning with moving all the SQL queries into appropriate models. Having looked at a few frameworks, it seems that most frameworks are setup with the assumption that an app will be developed from scratch using that framework.

Is there a good framework that I can just kind of plug-in so that I can use the model libraries and then perhaps later on, integrate more of the app into the framework? Would Doctrine be a good tool for something like this? Or should I just setup my own models without relying on third-party libraries?

我最近加入了一个PHP应用程序。 应用程序没有太多设计 - 有一个前端控制器,但视图,模型和控制器代码通常混合在一起。 p>

我想慢慢开始重构代码 从将所有SQL查询移动到适当的模型开始。 看了几个框架之后,似乎大多数框架的设置都是假设应用程序将使用该框架从头开发。 p>

是否有一个好的框架我可以善待 插件,以便我可以使用模型库,然后可能稍后,将更多的应用程序集成到框架中? Doctrine会成为这样的好工具吗? 或者我应该在不依赖第三方库的情况下设置自己的模型? p> div>

If you have an existing php application, then there is no point to migrate it to some framework. Frameworks help you to develop project faster - you already have one. At this point adding framework on top of what you have will only make your application more complex and, most likely, slower.

Instead of trying to find some magical framework, you should invest in refactoring (apply some OOP principles, like SOLID) and documenting the existing code. Maybe start incrementally add some unit-tests.


P.S. Doctrine is an ORM ( 1.x implements activerectord , 2.x - something like a datamapper ). ORMs are for people who are extremely lazy, misguided or do not understand SQL. By moving your existing SQL queries to ORMs code you will make it all only slower. Additionally, you will encounter problems when migrating complicated queries. Just dont do it.

If you want only MVC (not HMVC or more difficult) frameworks for simple adoptation with existing application you should touch CodeIgniter. ActiveRecords is very easy for refactoring from existing sql-queries. You even can use default or hand made functions or classes for building queries in its models.

But default, Codeigniter isn't enough flexible for difficult or multi-namespacing applications.

I've just started rewriting a site in Kohana, and I'm quite happy with it. It seems flexible and powerful. It's very similar to CodeIgniter, but a little more modern (more of the latest PHP features are used).

Im migrating a site using Zend and Doctrine2. The site wasn't OOP in any sense but it was divided between logic view and dal. The migration is still in process (new features are coded with framework, existing feature gets migrated only when big changes are needed).

Both frameworks are non intrusive, and the most valuable thing you get for me is to standarize things.