(858) 586 7777 | About | Testimonials | Contact
vteams vteams vteams vteams
  • How does it work?
    • Startup Process
    • Your First Day
  • Technologies
    • Hire PHP Developer
    • Hire App Developer
    • Hire JavaScript Developer
    • Hire ROR Developer
    • Hire IOS Developer
    • Hire .NET Developer
    • Hire AI Developer
    • Hire Robotics Engineer
  • Sample Budgets
  • Meet The Team
  • Experiments
  • Captain’s Log
  • Blog
vteams vteams
  • How does it work?
    • Startup Process
    • Your First Day
  • Technologies
    • Hire PHP Developer
    • Hire App Developer
    • Hire JavaScript Developer
    • Hire ROR Developer
    • Hire IOS Developer
    • Hire .NET Developer
    • Hire AI Developer
    • Hire Robotics Engineer
  • Sample Budgets
  • Meet The Team
  • Experiments
  • Captain’s Log
  • Blog
Blog
  1. vteams
  2. Blog
  3. Extend Multi-Tenant Site Functionality using Routes in Laravel
Jan 05
vteams- blog

Extend Multi-Tenant Site Functionality using Routes in Laravel

  • January 5, 2016

Multi-tenancy is an architecture which allows a single instance of a software application to serve multiple customers. Each client is termed as a tenant. Multi-tenant sites are gaining popularity these days because while building them, maintenance and development costs are shared. Such sites are generally economical. Keeping that in mind, one of our clients wanted us to build a multi-tenant application having multiple databases for each tenant.

vteams engineer used single code base for all tenants in that multi-tenant application using Laravel, but our client had one more requirement i.e. to provide additional functionality to any tenant within the existing modules.

After extensive research, vteams engineer came up with a solution which allowed to extend the functionality of existing modules using extended controllers and routes. This functionality was implemented by following the steps mentioned below:

Step 1

Create a folder within app folder “app/extended_modules/“. This folder contains all the extended modules with their own controller, models and views. Now, create a route file in this folder “app/extended/modules/routes.php” that will load route files for the extended modules using the following code:

1
2
3
4
5
6
7
8
9
10
11
<?php
 
Route::group([],function() {
     $module = Session::get ('mynamespace');
 
        if(file_exists(__DIR__.'/'.$module.'/routes.php')) {
            include __DIR__.'/'.$module.'/routes.php';
        }
 
});
?>

Step 2

Now, include route files in the extended modules “app/extended/modules/module1/routes.php” as follows:

1
2
3
4
5
Route::group(array('before'=>'api.csrf|site.config' , 'namespace' => 'App\Modules\\'.Session::get('mynamespace').'\Controllers'), function()
{
Route::get('/','DashboardController@index');
});

This folder also contain extended controllers and views.

Step 3

Route file is included at the bottom of application’s route (which make routes available at top).

If any request comes with the extended namespace, it will be checked within the extended modules first. If route is found then that functionality will be redeemed from that extended module otherwise the application flow will follow the normal execution.

  • Facebook
  • Twitter
  • Tumblr
  • Pinterest
  • Google+
  • LinkedIn
  • E-Mail

Comments are closed.

SEARCH BLOG

Categories

  • Blog (490)
  • Captain's Log (1)
  • Closure Reports (45)
  • Experiments (7)
  • How-To (56)
  • Implementation Notes (148)
  • Learn More (156)
  • LMS (8)
  • Look Inside (10)
  • Operations Log (12)
  • Programmer Notes (20)
  • R&D (14)
  • Rescue Log (4)
  • Testimonials (25)
  • Uncategorized (4)

RECENT STORIES

  • GitHub Actions- Automate your software workflows with excellence
  • Yii Framework – Accomplish Repetitive & Iterative Projects with Ease
  • A Recipe for CRM Software Development
  • Are Agile and DevOps the same?
  • The Data Scientist’s Toolset

ARCHIVES

In Short

With the vteams model, you bypass the middleman and hire your own offshore engineers - they work exclusively for you. You pay a reasonable monthly wage and get the job done without hassles, re-negotiations, feature counts or budget overruns.

Goals for 2020

  • Open development center in Australia
  • Complete and Launch the Robot
  • Structural changes to better address Clients' needs

Contact Us

Address: NEXTWERK INC.
6790 Embarcadero Ln, Ste 100,
Carlsbad, CA 92011, USA

Tel: (858) 586 7777
Email: fahad@nextwerk.com
Web: www.vteams.com

© 2020 vteams. All Rights Reserved.

Content Protection by DMCA.com