我用symfony routing.yml在frontend上做了很好的网址.在前端我可以使用例如:
url_for('@news',$news);
这为我生成:
http://mysite.com/frontend_dev.PHP/news/nice-title/1
但如果我在后端使用这个,我有:
http://mysite.com/backend_dev.PHP/news/nice-title/1
在apps / frontend / config / frontendConfiguration.class.PHP中使用如下内容:
原文链接:https://www.f2er.com/php/136376.htmlclass frontendConfiguration extends sfApplicationConfiguration { protected $backendRouting = null; public function generateBackendUrl($name,$parameters = array(),$absolute = false) { return sfConfig::get('app_site_url').$this->getBackendRouting()->generate($name,$parameters,$absolute); } public function getBackendRouting() { if (!$this->backendRouting ) { $this->backendRouting = new sfPatternRouting(new sfEventDispatcher()); $config = new sfRoutingConfigHandler(); $routes = $config->evaluate(array(sfConfig::get('sf_apps_dir').'/backend/config/routing.yml')); $this->backendRouting->setRoutes($routes); } return $this->backendRouting; } }
像这样用它:
$sf_context->getConfiguration()->generateBackendUrl('my_custom_route',array('id' => 1),true)