Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dawe's avatar
Level 1

Possible to include Laradock app into legacy structure?

We have kind of a special (weird) requirement. We have a legacy application, but we need to integrate a Laravel app now into this legacy application.

Here a quick overview what should work

  • foo.bar.tld is hit on (legacy) index.php on our servers. In index.php we decide if the request should be handled by the legacy code path or not
  • If legacy, all good. The request is processed as usual
  • If new path, the Laravel application should handle the request for the same domain

What we tried was just to include the public/index.php from the Laravel project in our legacy index.php at the very beginning. That gives a long error stack trace. :)

The problem I see here is that we just include the Laravel index.php file. But at the end, Laravel might expect this to be called (passed) from a web server. Not by a PHP include.

But this is just me guessing as I have not much experience with Laravel, and did not even create the Laravel application we need to integrate now.

Would this be possible at all at the application level?

Any input is welcome. :)

0 likes
4 replies
bashy's avatar

If you're just including different files based on the request, PHP will also pass all the required $_SERVER values etc. I think this should be perfectly fine, unless someone here thinks of some issue.

dawe's avatar
Level 1

Ok. At least this sounds not like we are completely off track. :)

Here's a paste of the stack trace. Maybe this could give you guys a hint of what goes wrong.

https://pastebin.com/8EcyEqzL

dawe's avatar
Level 1

Interesting par is now, that I have the same error if I just try to run the app configured through VHost. So it seems not directly related to the including of the Laravel index.php.

First I thought it might be related to the PHP version. But all seems good.

Laravel Framework 5.4.36

PHP Version 5.6.32 OpenSSL support enabled PDO support enabled Multibyte Support enabled Tokenizer Support enabled XML Support active

dawe's avatar
Level 1

Found it. Problem was that inside the Laravel app code we used PHP 7 new class that was written in some ServiceProvider.

So Laravel was happy with PHP 5.6.x but our own code wasn't.

Last problem left is how to load the resources from the correct sub folder where the Laraval application resides. Our legacy index.php includes Laravel now under foo.bar.tld and expects the resources to be located at foo.bar.tld\css, foo.bar.tld\js. But it should load it from foo.bar.tld\laravelSubFolder\public\css instead.

I hope I can configure this base path somehow. :)

Please or to participate in this conversation.