3

We want to switch to using Laravel, but we already have a full single entry point custom application. Our first step of refactoring is to put the entire legacy application in a top-level root folder called 'legacy'. The legacy app can easily be initialized and ran with few lines of code, we've tested this inside laravel already and it worked fine.

The issue is that for a start Laravel will do nothing but be the single entry point and have nothing to route to until further refactorings are done. So on the main index.php file we want Laravel to have some kind of logic that says,

"If I don't have anything to route to, load and run the legacy application to complete the request.". This way as we refactor pieces and provide routing Laravel can handle new pieces we add accordingly and always fall back on our legacy application to do any remaining work Laravel has not been set up to do as we refactor new components in. We'll also be including our library code in Laravel as well.

Any suggestions on how to achieve this? Is there a way to check the Laravel framework to see if it can successfully route the request anywhere or check for a 404 then call our application? We need to run both until we perform a full refactoring and it can take a while.

Our application is a single entry point and can easily be put inside other applications or frameworks.

3
  • 2
    I would do the refactoring completely separate from your legacy app in an development environment. If anything goes wrong no users are affected so can can refactor with much less headache. Commented Dec 21, 2015 at 15:45
  • 2
    Setup 2 servers(or subdomains), a dev and a production. Get a git going on both of them. Work only on dev and merge to production when you're confident the code is ok. Small incremental steps. Commented Dec 21, 2015 at 15:50
  • How are you going to work with Sessions on such a double-core application? Commented Dec 21, 2015 at 19:15

1 Answer 1

1

Definitely agree with the commenters, you need a test environment and production environment for this. Off the top of my head I imagine you would do something like this:

 $request = Illuminate\Http\Request::capture();
 $routes = [
     'route',
     'route2',
     'route3',
     'route4',
 ];
 if (in_array($request->url(), $routes) {
      // do whatever you are doing to route to your legacy project
 } else {
      $response = $kernel->handle(
           $request = Illuminate\Http\Request::capture()
      );

      $response->send();

      $kernel->terminate($request, $response);
 }

And then as you add routes to your routes.php you would add them here. It is limiting in that you can't have a post request and get request with the same URL in laravel and your legacy app.

Also, I did not test this. Just a theory.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.