#LaravelLegacy
Explore tagged Tumblr posts
Text
Further integration with Laravel
A few weeks ago I wrote a short blog post outlining some of the early success and challenges I had had integrating Laravel with a large legacy application. It is not possible to start again from scratch, so I am using Laravel to provide the application development process with a modern platform while continuing to allow the legacy code to run unhindered.
Since then i have continued to integrate the code and have come upon and successfully solved several integration issues.
Laravel must be loaded in a function.
Laravel Takes over all Error Processing
Sometimes you think Laravel is causing a bug but its not.
Sometimes you can use both
Integration
At the begining I was unsure exactly how integrated I would make the Laravel Code and the Legacy Non Laravel Code. I began by only loading the Laravel Codebase when I needed it, but quickly realise that having laravel functions available provided a huge advantage to the legacy codebase, so now I just load laravel in the config load file for the legacy codebase, ensuring I have access to all functions at all times.
Together but seperate.
One obvious area for seperation is in views. My legacy code base uses smarty, which I have always liked, and have been using since V1. If laravel had an option to use Smarty I would have continued with it, but thats not possible, so I use Blade with my new Laravel code.
This was a simple decision. Old code would continue to use Smarty, new code would use Blade.
Then...
Then I decided to provide information about a new feature (Subscriptions) to an old feature (Booking) so I pulled in the new Subscription Eloquent model into my view_booking page and passed it to a new Smarty template to use as a partial in the main Smarty Template? But why write a new template in Smarty, if I'm slowly going to be moving to Blade? So instead I called
$SubscriptionsHTML = View::make('bcs.booking.tab_subscriptions',['Subscriptions' => $Subscriptions]);
This runs my new Blade Partial through the blade engine and returns my HTML which I can pass to Smarty as part of its content.
This may seem like I'm mixing up lots of things and heading for making myself very confused, however I see it differntly. i have decided to embrace (Laravel)[https://laravel.com/] and use it moving forward. The more I integrate it with the old codebase the more I will be willing to write ALL new code in any part of the codebase using the Laravel Framework.
I have been amazed at how well I have been able to integrate an existing project with Laravel.
0 notes