Angga Ari Wijaya Angga Ari Wijaya - 1 year ago 78
PHP Question

Managing subdomain as part of website

I want build a website with separating domain like this for main website for help menu for logged user for admin some classroom online for blog

my question is, do I need to copy each core of application into each subdomain folder? or I can share the module of my framework (laravel) for each subdomain, let's say admin user and student user share the same functionality, if there are changes of the featured then I have to change the both of program? or there is a way to mapping the route as if subdomain but inside the program is single application? I hope my question understandable.. thanks and before you vote me down please give me chance to refine my question (because my English so terrible).

Answer Source

As per the docs, you can achieve this with sub-domain routing.

You just need to set up a group for each sub-domain of your application.

E.g routes.php:

Route::group(array('domain' => ''), function(){
    Route::get('/', 'HomeController@helpHome');

Route::group(array('domain' => ''), function(){
    Route::get('/', 'HomeController@accountHome');

Route::group(array('domain' => ''), function(){
    Route::get('/', 'HomeController@adminHome');

This will allow you to keep all of your code inside one application, simplifying your code base and meaning you don't need to worry about session sharing between laravel applications etc.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download