Best practice to create absolute URLs with Zend framework?

前端 未结 5 1865
南笙
南笙 2021-02-01 23:26

Is there a best practice for creating absolute URLs using the Zend framework? I wonder if there is some helper or if this would just be concatenating the scheme, host, etc. from

5条回答
  •  孤城傲影
    2021-02-02 00:01

    I wouldnt use $_SERVER, I would use the values from Zend_Controller_Request_Http::getServer($keyName); (or the direct getters on the request object when that applies - i forget which ones are direct members of the object and which ones need to be accessed with getServer). Technically these are the exact same values, but IMO its better access it the Zend way than to use the raw PHP access. But yes catting those together should get you what you need. This is actually the way i did it for an SSL controller plugin/url helper.

    There could be a better way though...

提交回复
热议问题