![]() |
|
sfMultiTenantPlugin - 1.1.0sfMultiTenantPlugin allows creating a multi-tenant-aware application, and automatically manages inserts & fetches without any additional code in individual models. |
|
![]() |
3
users
Sign-in
to change your status |
The sfMultiTenantPlugin allows you to create a multi-tenant-aware application. The plugin lets you: * automatically add a tenant identifier column & reference the Tenant model * automatically populates the tenant identifier column when saving records * automatically adapts select queries to filter records for a tenant. Basically, it manages the multi-tenancy aspect while being transparent to the developer and without any additional code in individual models. |
The sfMultiTenantPlugin allows you to create a multi-tenant-aware application. The plugin lets you:
automatically add a tenant identifier column & reference the Tenant model
automatically populates the tenant identifier column when saving records
automatically adapts select queries to filter records for a tenant.
Basically, it manages the multi-tenancy aspect while being transparent to the developer and without any additional code in individual models.
| Name | Status | |
|---|---|---|
|
|
lead | moc.liamg <<ta>> dasarpetpug |
Copyright (c) 2010 Prasad Gupte
gupteprasad@gmail.com | www.prasadgupte.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The sfMultiTenantPlugin allows you to create a multi-tenant-aware application. The plugin lets you:
automatically add a tenant identifier column & reference the Tenant model
automatically populates the tenant identifier column when saving records
automatically adapts select queries to filter records for a tenant
Install the plugin
symfony plugin:install sfMultiTenantPlugin
Check plugin activation in config/ProjectConfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enablePlugins(array( ..., 'sfMultiTenantPlugin', ...; )); } }
If plugin_settings.yml exists config directory
Append the Activateable section to it
Else copy plugin_settings.yml sample to the config directory
cp plugins/sfMultiTenantPlugin/config/plugin_settings.yml.sample %SF_CONFIG_DIR%/config/plugin_settings.yml
plugin_settings.ymlSample configuration:
MultiTenant:
class: Tenant
foreignField: id
type: integer
length: 4
getTenant:
class_name: Utility
static_method_name: getTenantIdentifier
What it means:
getTenant
The getTenant() method is a static method in the Utility
that accepts no parameters, and returns the tenant identifier in the required format.
In this case, it returns an integer(4) which is a primary-key in the Tenant model.
Tenant Model
Tenant:
actAs:
Timestampable: ~
columns:
id:
type: integer(4)
primary: true
notnull: true
autoincrement: true
...
MultiTenant User Model
Users:
actAs:
Multitenant:
name: tenant_id
alias: null
noReference: true
options:
notnull: true
uniqueFields: [[area_code, phone], username]
foreignAliasFormat: %CLASS%_%TABLE%
Timestampable: ~
columns:
id:
type: integer(4)
primary: true
notnull: true
autoincrement: true
...
What it means:
Define array of fields in model via 'uniqueFields' to create INDEX with tenant_id
Above declaration creates 2 indexes:
