johnsmith153 Posted March 7, 2013 Share Posted March 7, 2013 I have a site written in bad code. Everything is all thrown onto one page. The PHP is at the top (above HTML output) and the rest is at the bottom, but that's as good as it gets. Which framework would allow integration of this site the best (or any advice as to doing this)? Of course the whole lot could be re-written and of course I could just decide not integrate it, but I'm looking to improve all the client side stuff, but maybe just drop the PHP into one 'processing' file. The benefit to this I see is that I can gradually add improvements to the site and make use of the framework as I do it (and save time now). Over time the rubbish code would no doubt be reduced. Also, I may re-do all database interaction. So the idea would be to start as though creating a completely new site (using the framework), but when it gets to writing PHP I would save a lot of time by just calling the flat-PHP code already produced, maybe changing one or two things though (e.g. DB interaction). I'm sort of looking at learning Symfony2, so I suppose the question also is could I learn Symfony2 and then integrate this rubbish site later and kill two birds with one stone, or is Symfony2 not very good for integrating rubbish flat-PHP code (and maybe another framework is a better idea)? The idea is to modernise it, but not re-do it - if possible. Thanks for any advice. Quote Link to comment Share on other sites More sharing options...
Hall of Famer Posted March 8, 2013 Share Posted March 8, 2013 Id strongly recommend you to overhaul your script before applying them into frameworks, since its difficult to convert a spaghetti code into a neatly designed structure of script in one step. But anyway if you want to do it fast, Codeigniter seems to be the framework that integrates with non MVC script the best. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted March 8, 2013 Share Posted March 8, 2013 (edited) No, no and no. CI is one of the worst frameworks to use, especially for learning purposes. What I would recommend you do to, John, is to find a small and light-weight framework. One which you feel comfortable with, and then work to rewrite your logic to it. Laravel or Symfony 2 are some of the most commonly recommended frameworks, and Yii is another candidate. You can find a list of others at Wikipedia. Edited March 8, 2013 by Christian F. Quote Link to comment Share on other sites More sharing options...
johnsmith153 Posted March 8, 2013 Author Share Posted March 8, 2013 Thanks for the advice. I still think Symfony 2 is a good choice, although I was under the impression Symfony2 wasn't considered light-weight. Regardless, I like what I see so far. John Quote Link to comment Share on other sites More sharing options...
annaharris Posted May 1, 2013 Share Posted May 1, 2013 I am agreed with Hall of Famer, Codeigniter works perfectly for our requirements. Quote Link to comment Share on other sites More sharing options...
jeapie Posted May 27, 2013 Share Posted May 27, 2013 I recommend you to use micro-framework if you want to deploy your old code fast. Silex or Slim. They both have good and easy routing engines. Your application for start will be like that. require_once __DIR__.'/../vendor/autoload.php'; $app = new Silex\Application(); $app->get('/', function () { ... YOUR BAD CODE .... }) $app->run(); And then you will rebuild it by adding new handlers for other routes Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 27, 2013 Share Posted May 27, 2013 I recommend you to use micro-framework if you want to deploy your old code fast. Silex or Slim. They both have good and easy routing engines. Your application for start will be like that. require_once __DIR__.'/../vendor/autoload.php'; $app = new Silex\Application(); $app->get('/', function () { ... YOUR BAD CODE .... }) $app->run(); And then you will rebuild it by adding new handlers for other routes Really ??? What could be happened if your web root is different or the index is inside the project folder? Quote Link to comment Share on other sites More sharing options...
salathe Posted May 27, 2013 Share Posted May 27, 2013 Really ??? What could be happened if your web root is different or the index is inside the project folder? Whaaaa? Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 27, 2013 Share Posted May 27, 2013 Seriously. If your directory structure is different, then you simply update the code to work with it, or update your directory structure. It's not rocket surgery. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 27, 2013 Share Posted May 27, 2013 (edited) Seriously. If your directory structure is different, then you simply update the code to work with it, or update your directory structure. It's not rocket surgery. Not only the paths and the base web structure, this is a default routing provided by Silex and it's also related to Apache conf (if apache is your web server) So....the best way is to start reading the documentaion of this library. Edited May 27, 2013 by jazzman1 Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 27, 2013 Share Posted May 27, 2013 Have you ever tried it? Because I have. I installed slim on my localhost in a non-root directory, and I didn't have to change a thing. It worked fine. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 27, 2013 Share Posted May 27, 2013 Have you ever tried it? Because I have. I installed slim on my localhost in a non-root directory, and I didn't have to change a thing. It worked fine. Yes, Jessi. The first time when I run Silex was about a month I think, so the default routing did work at all and I've created my own Apache rewrite rule. Quote Link to comment Share on other sites More sharing options...
jeapie Posted May 28, 2013 Share Posted May 28, 2013 jazzman, but still its a good way to solve current situation: I have a site written in bad code. Everything is all thrown onto one page. The PHP is at the top (above HTML output) and the rest is at the bottom, but that's as good as it gets. Topic starter can easily use twig for templates (separate HTML output), Doctrine DBAL for secure database integration and his php bad code will be in silex handlers.I personally had such experience. It's much easier than rewrite it with full-featured framework with directory structure (Yii, CodeIgniter or ZF) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.