title: How to use orchestral/tenanti in Laravel 5 to build a multi tenant application with multiple databases?
body: <p>I am trying to build and application using Laravel 5. It is supposed to be a multi tenant database architecture using multiple databases. My employer requires this for security purposes.</p>
  
  <p>I have tried manually managing the main DB migrations and the Tenant migrations but failed. So I decided to take the help of a Laravel specific package which is supposedly what I require.</p>
  
  <p><a href="https://github.com/orchestral/tenanti">Tenanti</a> provides a way to have my purpose solved but the problem is that me being a novice developer, am not able to fully understand how to use it in my application.</p>
  
  <p>I have installed it correctly I believe doing:</p>
  
  <pre><code>composer require "orchestra/tenanti=~3.0"
  </code></pre>
  
  <p>Adding these providers and aliases in the config app file:</p>
  
  <pre><code>'providers' =&gt; [
  
      // ...
      Orchestra\Tenanti\TenantiServiceProvider::class,
      Orchestra\Tenanti\CommandServiceProvider::class,
  ],
  
  'aliases' =&gt; [
  
      'Tenanti' =&gt; Orchestra\Support\Facades\Tenanti::class,
  
  ],
  </code></pre>
  
  <p>Finally publishing the config and tweaking it according to the documentation for multiple databases:</p>
  
  <pre><code>php artisan vendor:publish
  </code></pre>
  
  <p>
  
  <pre><code>return [
      'drivers' =&gt; [
          'user' =&gt; [
              'model'     =&gt; App\User::class,
              'migration' =&gt; 'tenant_migrations',
              'path'      =&gt; database_path('tenanti/user'),
          ],
      ],
  ];
  </code></pre>
  
  <p>At this point I am still blurry what to do next?</p>
  
  <p>My doubts are as follows:</p>
  
  <ol>
  <li>Where will the migration files be generated and stored? I mean there are two kinds of databases in my application obviously. One set of files  is for the main DB which will store all the tenant information and the other files will be for the tenant DB. So how and where will these be stored?</li>
  <li>I see the word 'driver' a lot in the documentation but I am not sure what driver is exactly.</li>
  <li>How will I handle the authentication for the application? I mean whenever a tenant logs in, I will have to make sure the connection to the database changes dynamically. How will I accomplish this?</li>
  <li>I tried to go through the repository of the package itself and make sense of the code inside but in vain. I am not very good when it comes to design patters like facades, command bus, service provider and so on, which is why I am not able to understand the flow of the package or make sense of it.</li>
  </ol>
  
  <p>I tried to run some of the artisan commands which come with the package like:</p>
  
  <pre><code>php artisan tenanti:install {driver}
  php artisan tenanti:make {driver} {name}
  </code></pre>
  
  <p>But I am getting an error like so:</p>
  
  <blockquote>
    <p>[InvalidArgumentException]                        Database connection
    [tenants] is not available.</p>
  </blockquote>
  
  <p>Where can I find the resources to understand how to proceed with this?</p>