1

I need structure tips before I create my personal website using Laravel 5.3.

  1. Should I use a separate Laravel install for my subdomain backend to be safer or should I only use one Laravel install and do the routes below?
  2. Which is the best practice and easier to maintain?
  3. Should I use subdomain for my Backend Admin or just use sub-folder (www.domain.com/admin)

MY CURRENT STRUCTURE BELOW

Preferred URLs:

  1. http://www.domain.com (Frontend)
  2. http://admin.domain.com (Backend)

Controllers:

app\Http\Controllers\Admin\AdminController.php (Backend)
app\Http\Controllers\HomeController.php (Frontend)

Routes File:

Route::group(array('domain' => 'domain.com'), function() {
    Route::get('/', 'HomeController@index');
});
Route::group(array('domain' => 'admin.domain.com'), function() {
   Route::get('/', 'Admin\AdminController@index');
});

VHOST:

127.0.0.1   domain.com
127.0.0.1   admin.domain.com
marknt15
  • 5,047
  • 14
  • 59
  • 67

1 Answers1

3

Should I use a separate Laravel install for my subdomain backend to be safer or should I only use one Laravel install and do the routes below?

Separate the installation only if there exists a chance that you will move the admin to some other location later. If that is not the case better keep the everything under one installation, so that the dependencies will be same and you don't need to maintain the two configs, two models for every entity etc etc. Only thing you need to keep in mind is to structure the Admin & User routes separately with controllers in different folder which you have done already.

Which is the best practice and easier to maintain?

As explained above the easier way to maintain is to keep everything under one installation.

Should I use subdomain for my Backend Admin or just use sub-folder

That's up to you. But better the admin path a not-simply-guessable one. Something like domain.com/adm1n or adm1n.domain. com or something more complex.

Jithin
  • 2,594
  • 1
  • 22
  • 42
  • Thanks for the reply bro. The subdomain approach is what I like and I think it is easier to maintain one laravel installation only. The only good thing that I can think of a separate Backend Laravel installation is you can install any open source Laravel Admin CMS. – marknt15 Nov 18 '16 at 06:08
  • But most of the Laravel Admin CMS repos contain the both the frontend and the backend in the same installation. – Jithin Nov 18 '16 at 06:24
  • I use yii2 and there 2 apps (front and back) with two subdomains. I think it the best practice, when every app has own responsibility – Adobe Sep 29 '17 at 18:44