2017 © Pedro Peláez
 

library multi-tenant

A simple and lightweight package to craft multi-tenant applications with Laravel.

image

marciojcoelho/multi-tenant

A simple and lightweight package to craft multi-tenant applications with Laravel.

  • Thursday, February 16, 2017
  • by marciojcoelho
  • Repository
  • 1 Watchers
  • 0 Stars
  • 93 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 13 Versions
  • 1 % Grown

The README.md

multi-tenant

A simple and lightweight package to craft multi-tenant applications with Laravel., (*1)

Installation

This package relies on composer as dependency manger. Run the composer require marciojcoelho/multi-tenant to install this package. Next add the service provider within config/app.php: Mjc\MultiTenant\MultiTenantServiceProvider::class in order to be bootstrapped., (*2)

Defining tenants

Tenants are defined in config/tenant.php. Make sure to run the php artisan vendor:publish command to have this file created. By default, the tenant directories are located at storage/tenants/{tenantID}. If you want to use a different base path, override the path array key., (*3)

return [
    'path' => storage_path('tenants'),

    'hosts' => [
        'mysite.com' => [
            'id'    => 'mysite',
            'name'  => 'MySite',
            'https' => true,
        ],
        'anothersite.com' => [
            'id'    => 'anothersite',
            'name'  => 'AnotherSite',
            'https' => false,
            'foo' => 'bar',
        ]
    ]
]

In some cases you might want to add custom tenant-specific parameters, like an API key, for instance. Simply use the helper function to retrieve a tenant-specific key value: tenant('foo')., (*4)

Eloquent models

In order for your models to deal with multiple connections, simply extend the TenantModel class or implement the HasTenancy trait. Both classes do exactly the same. Choose the approach you prefer., (*5)

Migrating and seeding

Each tenant has it's own database, which you will want to migrate and seed every once in a while. Define your tenant connections within config/database.php and simply add the --database parameter to tell artisan which database to choose, for example:, (*6)

php artisan migrate:refresh  --database {tenantConnection} --seed

Managing assets

Each tenant has it's own assets which are, by default, stored at storage/tenants/{tenantID}/assets. Use the helper function tasset('foo.svg') to retrieve a tenant asset. This function will use the route asset/{path} to retrieve assets outside the public directory., (*7)

The Versions

16/02 2017

dev-master

9999999-dev

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

16/02 2017

1.3.7

1.3.7.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

16/02 2017

1.3.6

1.3.6.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

23/01 2017

1.3.5

1.3.5.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

23/01 2017

1.3.4

1.3.4.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

28/10 2016

1.3.3

1.3.3.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

28/10 2016

1.3.2

1.3.2.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

28/10 2016

1.3.1

1.3.1.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

28/10 2016

1.3

1.3.0.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

28/10 2016

1.2.1

1.2.1.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

28/10 2016

1.2

1.2.0.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

28/10 2016

1.1

1.1.0.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Jason Koolman
by Márcio Coelho

multisite laravel domains

13/05 2016

v1.0

1.0.0.0

A simple and lightweight package to craft multi-tenant applications with Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Jason Koolman