Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What php framework to use on top of spaghetti codebase?

Tags:

php

frameworks

My team have to maintain a large php application that was very poorly written. It is a mix of html, javascript and SQL on top of a large poorly designed database (ex. it has a table with few hundreds of columns). The only advantage of the codebase is that it works.

We are constantly bug fixing and rewriting parts of it.

I would like to give a structure to the rewrites we do, so I've though about integrating an mvc framework in to the codebase. Could you suggest any good framework for environment?

Here is a list of things that the I would expect from such framework:

  • The API must be very stable. We can't afford to rewrite the code on each release.
  • Custom session management or at least working on standard $_SESSION[] (To be able to talk with old code).
  • Custom authentication.
  • Using the raw SQL should be well supported (The database is hard to represent in terms of objects).
  • It shouldn't assume that I will have a table per controller.
like image 405
Piotr Czapla Avatar asked Jan 26 '10 14:01

Piotr Czapla


People also ask

Which is the easiest PHP framework to learn?

CodeIgniter is the top choice for a beginner-friendly PHP framework that is easy to use and quick to learn. It works on the MVC architecture, is easy to install, offers several guides and is easy to understand for beginners to get started with developing web applications on PHP.

How do I select a PHP framework?

A good documented framework, communicates all the workflow and hidden anomaly. It outcast the dos and don'ts well before the actual development is undertaken. Picking a framework with a good documentation will make it easier for the programmers to understand the source-code and develop applications.

Should I use a PHP framework?

Why use a PHP framework? A PHP framework provides a basic structure for streamlining the development of web apps. We use them because they speed up the development process. Above all, the responsiveness of websites and applications built using PHP frameworks helps businesses fulfill their performance needs.


2 Answers

I suggest Zend Framework for this purpose because it is a glue framework. With ZF you are not forced into the harness of how the framework expects you to work with it. You can pick what you want and gradually replace your legacy code with code from ZF. It also supports all the things you mentioned.

In addition, I suggest to run the various QA Tools found at phpqatools.org to support you in debugging and refactoring.

Framework comparisons

  • http://www.phpframeworks.com/
  • http://php-frameworks.net/
like image 136
Gordon Avatar answered Sep 17 '22 11:09

Gordon


I'm echoing Zend just to list how it fits your specific requirements:

  • The API must be very stable. We can't afford to rewrite the code on each release.

As mentioned, the API tends to be stable between minor releases. Major releases with changes shouldn't be hard to integrate.

  • Custom session management or at least working on standard $_SESSION[] (To be able to talk with old code).

Zend_Session does exactly what you want. The default session store is $_SESSION to which Zend adds a namespace concept. Your existing code should be fine, and any new code can use the Zend object to ensure there are no variable name overlaps.

  • Custom authentication.

Zend_Auth has a few authentication backends, but it is designed to allow you to implement your own auth.

  • Using the raw SQL should be well supported (The database is hard to represent in terms of objects).

Zend_DB implements the table gateway pattern which will allow you to access the data via object; however, you can also just use SQL directly and get the results as arrays.

  • It shouldn't assume that I will have a table per controller.

Zend_Controller and the rest of Zend's MVC implementation make no assumptions about the Model, leaving that completely up to you. I'm sure some people don't like that, but it is the one area of MVC design that varies greatly from project to project - so that's left completely to the developer. You could extend some of the DB classes, or just use the existing DB access code.

That's an example of the pick-and-choose mentality of the Zend Framework. You really can use any of the library by itself. That should work well with your project. For example, you could use Zend_View without the rest of the MVC classes just to move your presentation into templates. Or just use Zend_Auth to replace the existing Auth system. With Zend you can slowly move your project into a more structured state, little by little.

like image 30
Tim Lytle Avatar answered Sep 17 '22 11:09

Tim Lytle