Reputation: 6822
I'm new to Laravel and what I want to accomplish:
One laravel installation for multiple sites
Have some functions shared amongst all my sites, for instance User handling, while other functionality will be unique to a specific site
I want to pretty much have a wide variety of different sites under one installation, so I then can build an admin view where I can manage all sites.
How would I go about doing this? I have a fresh Laravel 4.2 installation.
Upvotes: 0
Views: 2597
Reputation: 25
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Request;
class ConfigServiceProvider extends ServiceProvider {
public function register() {
$template = $_SERVER["SERVER_NAME"];
$config = app('config');
$config->set('template', $template);
}
}
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\View\FileViewFinder;
use Illuminate\View\ViewServiceProvider;
class TemplateServiceProvider extends ViewServiceProvider {
public function registerViewFinder() {
$this->app->bind('view.finder', function ($app) {
$template = $app['config']['template'];
if(file_Exists(realpath(base_path('themes/'.$template.'/views')))){
$paths = [realpath(base_path('themes/'.$template.'/views'))];
}else{
$paths = $app['config']['view.paths'];
}
return new FileViewFinder($app['files'], $paths);
});
}
}
App\Providers\ConfigServiceProvider::class,
App\Providers\TemplateServiceProvider::class,
4. Create your template forders > themes/{your_domain_name}/views
Upvotes: 1
Reputation: 8415
You can have a look at the package rbewley4/multi-app-laravel on Github. Another hint can be found at this answer on StackOverflow
Upvotes: 1