How to embed a Laravel application within another web application?

不想你离开。 提交于 2019-12-11 09:37:01

问题


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).


回答1:


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

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.

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.



来源:https://stackoverflow.com/questions/28354734/how-to-embed-a-laravel-application-within-another-web-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!