问题
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