I’m working on a large php site that currently does not use any framework. My big question would be, is it advisable to slowly try to work a framework into the application over time, such as in new parts that are created and older parts as they are updated?
For example, all pages are served directly by url, and dozens of them look like this
//monitoring_projet.php
<?php
session_start();
require_once($_SERVER['DOCUMENT_ROOT'].'/include/header.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/include/config_ats.php');
$page_link = 'monitoring_projet.php';
?>
<div id="content" style="padding-left:10px;margin:0 10px">
<br />
<?php
include($_SERVER['DOCUMENT_ROOT'].'/include/gestion_projet_entreprise.php')
?>
</div>
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/include/footer.php'); ?>
I’ve been reading up on Zend Framework as my php framework poison of choice. Would it be a good idea to try and use ZF just to bootstrap the app and get all this common code into one place? Or is adding a framework into the mix going to cause more headaches than its worth at this point?
IMHO, plugging in a framework into a project like that just spells trouble; I imagine that configuration, dependency management and such would be a real hassle.
The approach I think would work best here is to make a separate blank framework project, define the views, controllers and models according to your project specs, then plug in the code from your current pages, distributing code among controllers and view appropriately. That way, you can migrate configuration and support classes into the framework without trying to bend the framework to suit your project.