PHP code example of waldemarnt / cake-multi-tenant
1. Go to this page and download the library: Download waldemarnt/cake-multi-tenant library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
waldemarnt / cake-multi-tenant example snippets
Configure::write('Config.current_tenant', 'example');
Configure::write('Config.multi_tenant_config', [
'example' => [
'name' => 'Example Tenant',
'connection_name' => 'my_custom_db_connection'
],
'waldemar' => [
'name' => 'Waldemar',
'connection_name' => 'my_other_db_connection'
]
]
);
public $my_custom_db_connection = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => '172.17.0.3',
'login' => 'root',
'password' => 'root',
'database' => 'db_one',
'prefix' => '',
//'encoding' => 'utf8',
);
public $my_other_db_connection = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => '172.17.0.3',
'login' => 'root',
'password' => 'root',
'database' => 'db_two',
'prefix' => '',
//'encoding' => 'utf8',
);
App::uses('MultiTenantAppModel', 'CakeMultiTenant.Model');
class AppModel extends MultiTenantAppModel {
}
public $helpers = array(
'Html' => array('className' => 'CakeMultiTenant.MultiTenantHtml'),
);
public $components = array(
'Auth' => [
'className' => 'CakeMultiTenant.MultiTenantAuth'
);
sh
CakePlugin::load('CakeMultiTenant', array('routes' => true, 'bootstrap' => true));