看看sfDomainRoutePlugin - 它做你想做的。但是,在當前版本中,您不會獲得Propel或DoctrineRoute功能,這意味着您必須根據插件返回的子域參數手動查找客戶。例如:
應用程序/前端/配置/ routing.yml中
# pick up the homepage
homepage:
url: /
class: sfDomainRoute
param: { module: homepage, action: index }
requirements:
sf_host: [www.example.com, example.com]
# catch subdomains for customers
customer_subdomain:
url: /
class: sfDomainRoute
param: { module: customer, action: index }
應用程序/前端/模塊/客戶/的actions.class.php
public function executeIndex(sfWebRequest $request)
{
// get the subdomain parameter
$this->subdomain = $request->getParameter('subdomain');
// retrieve customer (you have to create the retrieveBySubdomain method)
$this->customer = CustomerPeer::retrieveBySubdomain($this->subdomain);
}
這僅僅是一個例子,但是我我自己使用一種類似的方法,插件做廣告。祝你好運。
如果您喜歡冒險,yuo可以參考「更多與symfony書籍」中的第2章。這會幫助你理解sfDomainRoutePlugin中的代碼。
+1好問題:-) – richsage 2010-06-07 13:16:12
謝謝!希望有人知道答案! :-) – Flukey 2010-06-07 14:45:14