There's no magic wand for this kind of crappy code. Seems like a pointless exercise translating to a Laravel or any other framework. With code like above its basically starting from scratch anyway. Life is too short for this.
Episode/Series Request: Migrating legacy code to Laravel
I admit this is quite a selfish request as I'm working through this process just now**. But it occurred to me that there are quite a few projects out there sitting in a PHP4-lightly-wrapped-in-PHP5 state (if you wrap 3000 lines of procedural code in "class {}" then you're totally doing object orientated programming, am I right?) that people would like to move to a framework like Laravel.
The kind of old scripts that build an html string as they go, run SQL queries directly, are maybe hundreds (or thousands) of lines long, use globals everywhere etc. If you remember the "good old days" (ahem) of...
require_once('includes/globals.inc.php');
require_once('includes/db.inc.php');
$output = "<html><body>\n";
$output = $output . '<table width="100%">' . "\n<tr>\n";
$query = 'SELECT thing FROM table WHERE something="' . mysql_real_escape_string($_GET['name']) . '" LIMIT 1';
$result = mysql_query($query) or die(mysql_error());
$thing = mysql_fetch_array($result);
$output = $output . '<td style="color: red">' . $thing[0] . '</td>' . "\n";
...
(repeat for $n-hundred lines)
...
echo $output;
Happy days.. ;-)
Anyway - as I say, this might just be a selfish request, but it's maybe of wider interest to other PHP folk and getting them on-board Laravel.
** I can give you some truly "remarkable" code if you want to use it as a basis... ;-)
Please or to participate in this conversation.