Jump to content

Archived

This topic is now archived and is closed to further replies.

johnsmith153

Best framework for integrating rubbish code?

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

I am agreed with Hall of Famer, Codeigniter works perfectly for our requirements.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Really ???

 

What could be happened if your web root is different or the index is inside the project folder?

Whaaaa?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

 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)

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.