开发者

What is a good PHP framework for migrating an existing app to?

开发者 https://www.devze.com 2023-04-13 09:04 出处:网络
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'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 sl开发者_StackOverflow中文版owly 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?


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.


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).


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号