sfMultiTenantPlugin
1.1.0stable
for and Doctrine
MIT
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.
Developers
| Name |
Status |
Email |
Prasad Gupte |
lead |
moc.liamg <<ta>> dasarpetpug
|
License
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.
Changelog for release 1.1.0 - 28/01/2012
Other releases
Release 1.1.0 - 28/01/2012
Release 1.0.1 - 12/12/2010
Release 1.0.0 - 22/09/2010
sfMultiTenantPlugin (Doctrine)
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
Installation
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
Usage
To start with you define a few settings in the plugin_settings.yml
Sample configuration:
MultiTenant:
class: Tenant
foreignField: id
type: integer
length: 4
getTenant:
class_name: Utility
static_method_name: getTenantIdentifier
What it means:
- Tenant-identifier model referred by all MultiTenant model
- Unique field in Tenant-identifier model
- Data-type of the tenant-identifier column
- Length/Size of the tenant-identifier column
- Static Method that returns the tenant identifier
- Class containing the static method
- Name of the static method that returns the tenant identifier
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.
Define a tenant model acts as the master for Multi-tenant models.
Define other models that you want to be MultiTenant
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:
Please feel free to mail me in-case you have any queries or feature requests!
This plugin is dedicated to Arundhati Purandare, who offered immense support during the development of this plugin and to whom I tried to explain listeners despite of she not being a coder.
Fin