Jump to content

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.

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. 

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 by Christian F.
  • 1 month later...
  • 4 weeks later...

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

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?

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 by jazzman1

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. 

 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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.