如何在另一个Web应用程序中嵌入Laravel应用程序?

如何在另一个Web应用程序中嵌入Laravel应用程序?

问题描述:

因此,我有一个Web应用程序,例如www.randomwebapp.com,我希望www.randomwebapp.com/laravelapp指向我编写的laravel应用程序.我已经想出了如何将laravel应用程序作为一个单独的包包含在内,以及如何在laravel应用程序中访问类,但是我想知道如何实际渲染视图/路由等.我主要关心如何实际 start 运行应用程序(可能与bootstrap/app.php或bootstrap/autoload.php有关).

So I have a web application, say www.randomwebapp.com, and I want www.randomwebapp.com/laravelapp to point to a laravel app I have written. I've already figured out how to include my laravel app as a separate package and access classes within my laravel app, but I'm wondering how to actually go about rendering views/routing etc. I'm mainly concerned with how to actually start running the app (perhaps something to do with bootstrap/app.php or bootstrap/autoload.php).

我假设您使用的是 https://github.com/laravel/laravel ,您的两个应用程序是真正独立的,彼此之间没有依赖关系.

I'm assuming you're using the boilerplate laravel installation folder structure provided by https://github.com/laravel/laravel, and your two apps are truly separate and have no dependencies on each other.

我还假设文件夹结构看起来像这样:

I'm also assuming folder structure looks something like this:

+ /webroot
  + /app
  + ( other laravel folders )
  + /public
  + /vendor
  + index.php
  + /other-site-dir

我只需将public重命名为laravelapp.您可能需要编辑laravelapp/.htaccess(以前为public/.htaccess)文件,以不重定向到域根目录,而是直接重定向到laravelapp/index.php.

I would simply rename public to laravelapp. You may have to edit your laravelapp/.htaccess (formerly public/.htaccess) file to not redirect to your domain root and direct to laravelapp/index.php instead.

您可能还需要将我们所有的路线改写为Route::group('/laravelapp'...);

You may also have to rewrite our group all your routes into a Route::group('/laravelapp'...);

这些只是现成的想法...如果您有文件夹结构的示例,则可能会有所帮助.

These are just off-the-cuff thoughts... If you have an example of your folder structure, it could help.