centralapps/application-context
Composer 安装命令:
composer require centralapps/application-context
包简介
Useful set of tools for working with subdomain based web applications
README 文档
README
This component is designed for use in application which make use of subdomains to segregate data / accounts.
For example, if you have the domain mydomain.com and one of your customers logs in and uses the application via customername.mydomain.com, this component makes it easy to lookup those customers details, and to determine what "context" the application is running in (account context or not). This lets you route and manage the application correctly.
Installation
Add the project to your composer.json file
{
"require": {
"centralapps/application-context": "dev-master"
}
}
Install the project
php composer.phar update
Usage
-
Create an account factory, which implements LookupInterface, this is used to take an account reference and create an account object. Application specific code.
-
Create an account context object, pass the server name, the domain name and the account factory
-
The context will then setup, and store a reference for the account
$account_context = new \CentralApps\ApplicationContext\Context($_SERVER['SERVER_NAME'], 'mydomain.com', $account_factory);
-
You can check to see if the application is being ran as an 'account context'
$account_context->isAccountContext(); // returns true or false
-
You can also check to see if the account context is valid (that the subdomain matches a real account)
$account_context->isValidReference();
-
Finally, you can get the account object, which is retrieved via your pre-defined account factory
$account = $account_context->getAccount(); // null if not valid
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2013-01-29