Skip to content

Instantly share code, notes, and snippets.

@williamn
Created November 27, 2014 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save williamn/bdfb6ca11eddc0db628f to your computer and use it in GitHub Desktop.
Save williamn/bdfb6ca11eddc0db628f to your computer and use it in GitHub Desktop.
CakePHP multitenant routing
<?php
// Validates tenant
switch (isset($this->request->params['tenant'])) {
case true:
// The tennant should exist
$this->loadModel('Tenant');
if ($this->Tenant->isExist($this->request->params['tenant']) == 0) {
throw new NotFoundException();
}
break;
case false:
// On-premises mode
$this->redirect(array(
'tenant' => 'manually-set-customer-name'
));
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment