<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Zend Framework base url</title>
	<atom:link href="http://blog.motane.lu/2009/01/31/zend-framework-base-url/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/</link>
	<description>Ramblings about software development</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:38:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jesse Bullard</title>
		<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/comment-page-1/#comment-2617</link>
		<dc:creator>Jesse Bullard</dc:creator>
		<pubDate>Thu, 22 Sep 2011 21:01:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=344#comment-2617</guid>
		<description>I am just starting out with Zend Framework. My boss wants me to learn everything about it. That is why I came across your site. I will bookmark your site in case I need more help. I know I still have to read a lot from your site.</description>
		<content:encoded><![CDATA[<p>I am just starting out with Zend Framework. My boss wants me to learn everything about it. That is why I came across your site. I will bookmark your site in case I need more help. I know I still have to read a lot from your site.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Denny</title>
		<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/comment-page-1/#comment-926</link>
		<dc:creator>Denny</dc:creator>
		<pubDate>Mon, 07 Dec 2009 18:46:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=344#comment-926</guid>
		<description>The Zend helper should work out of the box with a simple one liner --

 baseUrl(&#039;blah&#039;) ?&gt;

Assuming you&#039;ve set the baseUrl up in your config file of course --

resources.frontController.baseUrl = &quot;http://example.com:7000/&quot;</description>
		<content:encoded><![CDATA[<p>The Zend helper should work out of the box with a simple one liner &#8211;</p>
<p> baseUrl(&#8216;blah&#8217;) ?&gt;</p>
<p>Assuming you&#8217;ve set the baseUrl up in your config file of course &#8211;</p>
<p>resources.frontController.baseUrl = &#8220;http://example.com:7000/&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/comment-page-1/#comment-695</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Wed, 30 Sep 2009 20:04:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=344#comment-695</guid>
		<description>Since I&#039;ve used my helper without any problems in several projects that are now live and Zend Framework&#039;s components are thoroughly tested prior to their release, I&#039;m inclined to believe that you&#039;ve made a mistake somewhere in your application.

They may not work in the way that you want them to work - returning the whole URL with the domain name. With this, I agree. But again, they shouldn&#039;t. An application should be domain independent.

Best of luck in finding a component suitable for you. And,.after you do, perhaps you&#039;ll find the time to post it here, so it will be helpful to others...</description>
		<content:encoded><![CDATA[<p>Since I&#8217;ve used my helper without any problems in several projects that are now live and Zend Framework&#8217;s components are thoroughly tested prior to their release, I&#8217;m inclined to believe that you&#8217;ve made a mistake somewhere in your application.</p>
<p>They may not work in the way that you want them to work &#8211; returning the whole URL with the domain name. With this, I agree. But again, they shouldn&#8217;t. An application should be domain independent.</p>
<p>Best of luck in finding a component suitable for you. And,.after you do, perhaps you&#8217;ll find the time to post it here, so it will be helpful to others&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luciano</title>
		<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/comment-page-1/#comment-694</link>
		<dc:creator>Luciano</dc:creator>
		<pubDate>Wed, 30 Sep 2009 19:22:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=344#comment-694</guid>
		<description>thanks for the tips about the path.

anyway the helpers (neither yours or the zend one) seems to work, this can be helpfull for other people looking for it.

thanks again</description>
		<content:encoded><![CDATA[<p>thanks for the tips about the path.</p>
<p>anyway the helpers (neither yours or the zend one) seems to work, this can be helpfull for other people looking for it.</p>
<p>thanks again</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/comment-page-1/#comment-693</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Wed, 30 Sep 2009 18:48:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=344#comment-693</guid>
		<description>I took the liberty of altering your comment and adding the proper markup. You can use &lt;pre lang=&quot;php&quot;&gt; code &lt;/pre&gt; . I don&#039;t know why the default helper doesn&#039;t work, as I haven&#039;t used the 1.9.2 version of the framework yet. 

My helper was posted here on the 31st of January  2009, so it&#039;s fairly old. It simply returns the base url as it&#039;s encapsulated in the FrontController object.

You must understand that the front controller doesn&#039;t keep any record about the domain your site is running on. For instance, my baseUrl() will return the &lt;strong&gt;&lt;em&gt;path&lt;/em&gt;&lt;/strong&gt; part of the url (see this &lt;a href=&quot;http://www.php.net/manual/en/function.parse-url.php&quot; title=&quot;parse_url() in PHP&#039;s manual&quot; class=&quot;outgoing&quot; rel=&quot;nofollow&quot;&gt;page&lt;/a&gt; for details). 

The domain the application is running at a given time shouldn&#039;t be relevant to the application itself. But if really want your domain to be returned by the baseUrl() helper, you have to parse the data from the $_SERVER superglobal. You can find an useful example &lt;a href=&quot;http://www.webcheatsheet.com/PHP/get_current_page_url.php&quot; title=&quot;Get current page URL&quot; class=&quot;outgoing&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.

Was this useful?</description>
		<content:encoded><![CDATA[<p>I took the liberty of altering your comment and adding the proper markup. You can use &lt;pre lang=&#8221;php&#8221;&gt; code &lt;/pre&gt; . I don&#8217;t know why the default helper doesn&#8217;t work, as I haven&#8217;t used the 1.9.2 version of the framework yet. </p>
<p>My helper was posted here on the 31st of January  2009, so it&#8217;s fairly old. It simply returns the base url as it&#8217;s encapsulated in the FrontController object.</p>
<p>You must understand that the front controller doesn&#8217;t keep any record about the domain your site is running on. For instance, my baseUrl() will return the <strong><em>path</em></strong> part of the url (see this <a href="http://www.php.net/manual/en/function.parse-url.php" title="parse_url() in PHP's manual" class="outgoing" rel="nofollow">page</a> for details). </p>
<p>The domain the application is running at a given time shouldn&#8217;t be relevant to the application itself. But if really want your domain to be returned by the baseUrl() helper, you have to parse the data from the $_SERVER superglobal. You can find an useful example <a href="http://www.webcheatsheet.com/PHP/get_current_page_url.php" title="Get current page URL" class="outgoing" rel="nofollow">here</a>.</p>
<p>Was this useful?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luciano</title>
		<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/comment-page-1/#comment-691</link>
		<dc:creator>Luciano</dc:creator>
		<pubDate>Wed, 30 Sep 2009 15:37:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=344#comment-691</guid>
		<description>I see a BaseUrl helper in ZF, but it doesn&#039;t work.
So I googled the web finding this and other post talking about a BaseUrl helper.
My question is why the default helper doesn&#039;t work.

I ask this question here because Your post almost recent.

Your Helper too doesn&#039;t work if I don&#039;t use &#039;/beta&#039; subdir (see belowe)
the Lensselink&#039;s one work in my case. (but not as I like)

My bootstrap:

[code lang=&quot;php&quot;]
$request = new Zend_Controller_Request_Http();
$request-&gt;setBaseUrl( $request-&gt;getBaseUrl().’/&#039;); // dispatch($request);
[/code]

My helper:

[code lang=&quot;php&quot;]
function baseUrl($file = null)
{
$base_url = Zend_Controller_Front::getInstance()-&gt;getBaseUrl();
//$base_url = substr($_SERVER[&#039;PHP_SELF&#039;], 0, -9);

if (null !== $file) $file = ltrim($file, ‘/\\’);

return $base_url . $file;
}
[/code]

My View calls to the helper:

[code lang=&quot;php&quot;]
&lt;a href=&quot;baseUrl(); ? rel=&quot;nofollow&quot;&gt;” title=”Home”&gt;

&lt;a href=&quot;baseUrl(’page’); ? rel=&quot;nofollow&quot;&gt;” title=”a page”&gt;a page

&lt;link href=&quot;baseUrl(’style.css’); ?&gt;” /&gt; 
[/code]

looking at my helper you see two vars: $base_url and $file.
only $file is returned, $base_url return always empty if I use &#039;/&#039; in setBaseUrl().

If I try &#039;/subdir&#039; in setBaseUrl() it works!

If I use &#039;/&#039; the output is: 
on a page like  http://localhost/resource
[code lang=&quot;php&quot;]
baseUrl(); // render &#039;&#039; that become the link &#039;http://localhost/resource&#039;
baseUrl(&#039;page&#039;); // render &#039;page&#039; that become the link http://localhost/page
baseUrl(&#039;style.css&#039;); // render style.css
[/code]

on a page like  http://localhost/resource/
[code lang=&quot;php&quot;]
baseUrl(); // render &#039;&#039; that become the link &#039;http://localhost/resource/&#039;
baseUrl(&#039;page&#039;); // render &#039;page&#039; that become the link &#039;http://localhost/resource/page&#039;
baseUrl(&#039;style.css&#039;); // render style.css
[/code]

the Lensselink&#039;s one render as belowe:

[code lang=&quot;php&quot;]
baseUrl(); // render &#039;/&#039; that become the link &#039;http://localhost/&#039;
baseUrl(&#039;page&#039;); // render &#039;/page&#039; that become the link &#039;http://localhost/page&#039;
baseUrl(&#039;style.css&#039;); // render /style.css
[/code]

no one render &#039;http://localhost/&#039; as I wish</description>
		<content:encoded><![CDATA[<p>I see a BaseUrl helper in ZF, but it doesn&#8217;t work.<br />
So I googled the web finding this and other post talking about a BaseUrl helper.<br />
My question is why the default helper doesn&#8217;t work.</p>
<p>I ask this question here because Your post almost recent.</p>
<p>Your Helper too doesn&#8217;t work if I don&#8217;t use &#8216;/beta&#8217; subdir (see belowe)<br />
the Lensselink&#8217;s one work in my case. (but not as I like)</p>
<p>My bootstrap:</p>
<pre class="brush: php; title: ; notranslate">
$request = new Zend_Controller_Request_Http();
$request-&gt;setBaseUrl( $request-&gt;getBaseUrl().’/'); // dispatch($request);
</pre>
<p>My helper:</p>
<pre class="brush: php; title: ; notranslate">
function baseUrl($file = null)
{
$base_url = Zend_Controller_Front::getInstance()-&gt;getBaseUrl();
//$base_url = substr($_SERVER['PHP_SELF'], 0, -9);

if (null !== $file) $file = ltrim($file, ‘/\\’);

return $base_url . $file;
}
</pre>
<p>My View calls to the helper:</p>
<pre class="brush: php; title: ; notranslate">
&lt;a href=&quot;baseUrl(); ? rel=&quot;nofollow&quot;&gt;” title=”Home”&gt;

&lt;a href=&quot;baseUrl(’page’); ? rel=&quot;nofollow&quot;&gt;” title=”a page”&gt;a page

&lt;link href=&quot;baseUrl(’style.css’); ?&gt;” /&gt;
</pre>
<p>looking at my helper you see two vars: $base_url and $file.<br />
only $file is returned, $base_url return always empty if I use &#8216;/&#8217; in setBaseUrl().</p>
<p>If I try &#8216;/subdir&#8217; in setBaseUrl() it works!</p>
<p>If I use &#8216;/&#8217; the output is:<br />
on a page like  <a href="http://localhost/resource" rel="nofollow">http://localhost/resource</a></p>
<pre class="brush: php; title: ; notranslate">
baseUrl(); // render '' that become the link '<a href="http://localhost/resource" rel="nofollow">http://localhost/resource</a>'
baseUrl('page'); // render 'page' that become the link <a href="http://localhost/page" rel="nofollow">http://localhost/page</a>
baseUrl('style.css'); // render style.css
</pre>
<p>on a page like  <a href="http://localhost/resource/" rel="nofollow">http://localhost/resource/</a></p>
<pre class="brush: php; title: ; notranslate">
baseUrl(); // render '' that become the link '<a href="http://localhost/resource/" rel="nofollow">http://localhost/resource/</a>'
baseUrl('page'); // render 'page' that become the link '<a href="http://localhost/resource/page" rel="nofollow">http://localhost/resource/page</a>'
baseUrl('style.css'); // render style.css
</pre>
<p>the Lensselink&#8217;s one render as belowe:</p>
<pre class="brush: php; title: ; notranslate">
baseUrl(); // render '/' that become the link '<a href="http://localhost/" rel="nofollow">http://localhost/</a>'
baseUrl('page'); // render '/page' that become the link '<a href="http://localhost/page" rel="nofollow">http://localhost/page</a>'
baseUrl('style.css'); // render /style.css
</pre>
<p>no one render &#8216;<a href="http://localhost/" rel="nofollow">http://localhost/</a>&#8216; as I wish</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/comment-page-1/#comment-689</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Wed, 30 Sep 2009 11:50:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=344#comment-689</guid>
		<description>Can you rephrase that? Did you try my helper and it didn&#039;t work? I didn&#039;t tested it in ZF 1.9.2, but it should work...</description>
		<content:encoded><![CDATA[<p>Can you rephrase that? Did you try my helper and it didn&#8217;t work? I didn&#8217;t tested it in ZF 1.9.2, but it should work&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luciano</title>
		<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/comment-page-1/#comment-688</link>
		<dc:creator>Luciano</dc:creator>
		<pubDate>Wed, 30 Sep 2009 11:45:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=344#comment-688</guid>
		<description>ZF 1.9.2 have Zend_View_Helper_BaseUrl

but it doesn&#039;t work, why?</description>
		<content:encoded><![CDATA[<p>ZF 1.9.2 have Zend_View_Helper_BaseUrl</p>
<p>but it doesn&#8217;t work, why?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/comment-page-1/#comment-575</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Tue, 28 Jul 2009 13:04:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=344#comment-575</guid>
		<description>You don&#039;t need to...The helper works out the box :P</description>
		<content:encoded><![CDATA[<p>You don&#8217;t need to&#8230;The helper works out the box <img src='http://blog.motane.lu/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brutuscat</title>
		<link>http://blog.motane.lu/2009/01/31/zend-framework-base-url/comment-page-1/#comment-574</link>
		<dc:creator>Brutuscat</dc:creator>
		<pubDate>Tue, 28 Jul 2009 12:28:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=344#comment-574</guid>
		<description>I can&#039;t make the setBaseUrl to work, so I improved the baseurl method like this:
[code lang=&quot;php&quot;]
    function baseUrl()
    {
        $s = $_SERVER[&#039;PHP_SELF&#039;];
        $base_url = substr($s, 0, -(strlen($s) - strpos($s, &#039;index.php&#039;)));
        return $base_url;
    }
[/code]
This will find the first occurrence of the &#039;index.php&#039; and remove everything after it leaving the baseurl only.

Regards!</description>
		<content:encoded><![CDATA[<p>I can&#8217;t make the setBaseUrl to work, so I improved the baseurl method like this:</p>
<pre class="brush: php; title: ; notranslate">
    function baseUrl()
    {
        $s = $_SERVER['PHP_SELF'];
        $base_url = substr($s, 0, -(strlen($s) - strpos($s, 'index.php')));
        return $base_url;
    }
</pre>
<p>This will find the first occurrence of the &#8216;index.php&#8217; and remove everything after it leaving the baseurl only.</p>
<p>Regards!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

