<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web 2.0 &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/web-2-0/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>POST with Zend_Http_Client</title>
		<link>/2011/04/13/post-with-zend_http_client/</link>
		<comments>/2011/04/13/post-with-zend_http_client/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 13:26:47 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Computer networking]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Hypertext Transfer Protocol]]></category>
		<category><![CDATA[Internet protocols]]></category>
		<category><![CDATA[Network protocols]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[Zend Technologies]]></category>

		<guid isPermaLink="false">/?p=2299</guid>
		<description><![CDATA[CURL and Zend_Http It&#8217;s a well know fact that you can preform HTTP requests with CURL. Zend Framework does the same job with Zend_Http. Especially Zend_Http_Client can be used to &#8220;replace&#8221; the usual client &#8211; the browser, and to perform some basic requests. I&#8217;ve seen mostly GET requests, although Zend_Http_Client can perform various requests such &#8230; <a href="/2011/04/13/post-with-zend_http_client/" class="more-link">Continue reading <span class="screen-reader-text">POST with Zend_Http_Client</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
<li><a href="/2010/04/14/zend_http_client-and-case-sensitivity/" rel="bookmark" title="Zend_Http_Client and Case Sensitivity">Zend_Http_Client and Case Sensitivity </a></li>
<li><a href="/2010/03/23/read-remote-file-content-type-with-zend_http_client/" rel="bookmark" title="Read Remote File Content-Type with Zend_Http_Client">Read Remote File Content-Type with Zend_Http_Client </a></li>
<li><a href="/2011/04/07/use-fopen-to-check-file-availability/" rel="bookmark" title="Use fopen() to Check File Availability?">Use fopen() to Check File Availability? </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>CURL and Zend_Http</h2>
<p>It&#8217;s a well know fact that you can preform <a title="Http Requests - the Hypertext Transfer Protocol" href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol" target="_blank">HTTP requests</a> with <a href="http://en.wikipedia.org/wiki/CURL" title="CURL" target="_blank">CURL</a>. <a title="Zend Framework" href="http://framework.zend.com/" target="_blank">Zend Framework</a> does the same job with <a title="Zend_Http" href="http://framework.zend.com/manual/en/zend.http.html" target="_blank">Zend_Http</a>. Especially <a title="Http on Stoimen.com" href="/tag/http/">Zend_Http_Client</a> can be used to &#8220;replace&#8221; the usual client &#8211; the browser, and to perform some basic requests.</p>
<figure id="attachment_2308" style="width: 450px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2011/04/http.jpg"><img class="size-full wp-image-2308" title="HTTP requests can be performed with Zend_Http_Client" src="/wp-content/uploads/2011/04/http.jpg" alt="HTTP requests can be performed with Zend_Http_Client" width="450" height="337" srcset="/wp-content/uploads/2011/04/http.jpg 450w, /wp-content/uploads/2011/04/http-300x224.jpg 300w" sizes="(max-width: 450px) 100vw, 450px" /></a><figcaption class="wp-caption-text">Zend_Http_Client is mostly used to perform GET requests, but it can be also very helpful for POST HTTP requests.</figcaption></figure>
<p>I&#8217;ve seen mostly GET requests, although Zend_Http_Client can perform various requests such as <a title="POST Requests on Stoimen.com" href="/tag/post/">POST</a> as well.</p>
<pre lang="php">
// new HTTP request to some HTTP address
$httpClient = new Zend_Http_Client('http://www.example.com/');
// GET the response
$response = $httpClient->request(Zend_Http_Client::GET);
</pre>
<p>Here&#8217;s a little snippet showing how to POST some data to a server.</p>
<pre lang="php">
// new HTTP request to some HTTP address
$client = new Zend_Http_Client('http://www.example.com/');
// set some parameters
$client->setParameterPost('name', 'value');
// POST request
$response = $client->request(Zend_Http_Client::POST);
</pre>
<p>Note that the request method returns a response. Thus if you are simulating a form submit action you can &#8220;redirect&#8221; to the desired page just like the form.</p>
<pre lang="php">
// new HTTP request to some HTTP address
$client = new Zend_Http_Client('http://www.example.com/');
// set some parameters
$client->setParameterPost('name', 'value');
// POST request
$response = $client->request(Zend_Http_Client::POST);
echo $response->location;
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
<li><a href="/2010/04/14/zend_http_client-and-case-sensitivity/" rel="bookmark" title="Zend_Http_Client and Case Sensitivity">Zend_Http_Client and Case Sensitivity </a></li>
<li><a href="/2010/03/23/read-remote-file-content-type-with-zend_http_client/" rel="bookmark" title="Read Remote File Content-Type with Zend_Http_Client">Read Remote File Content-Type with Zend_Http_Client </a></li>
<li><a href="/2011/04/07/use-fopen-to-check-file-availability/" rel="bookmark" title="Use fopen() to Check File Availability?">Use fopen() to Check File Availability? </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2011/04/13/post-with-zend_http_client/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Collect the Images and Meta Tags from a Webpage with PHP</title>
		<link>/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/</link>
		<comments>/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 09:23:50 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Facebook Inc]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[LinkedIn Corporation]]></category>
		<category><![CDATA[Meta element]]></category>
		<category><![CDATA[Meta Tags]]></category>
		<category><![CDATA[Online social networking]]></category>
		<category><![CDATA[Search engine optimization]]></category>
		<category><![CDATA[search engines]]></category>
		<category><![CDATA[social services]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[Technical communication]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web page]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=2216</guid>
		<description><![CDATA[Meta Tags and the Facebook Example You&#8217;ve definitely seen the &#8220;share a link&#8221; screen in Facebook. When you paste a link into the box (fig. 1) and press the &#8220;Attach&#8221; button you&#8217;ll get the prompted cite parsed with a title, description and possibly thumb (fig. 2). This functionality is well known in Facebook, but it &#8230; <a href="/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/" class="more-link">Continue reading <span class="screen-reader-text">How to Collect the Images and Meta Tags from a Webpage with PHP</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/04/20/how-to-sanitize-user-input-in-php/" rel="bookmark" title="How to Sanitize User Input in PHP?">How to Sanitize User Input in PHP? </a></li>
<li><a href="/2010/08/03/html-tags/" rel="bookmark" title="HTML Tags: &lt;base&gt;">HTML Tags: &lt;base&gt; </a></li>
<li><a href="/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/" rel="bookmark" title="Automatically Upload Images with PHP Directly from the URI">Automatically Upload Images with PHP Directly from the URI </a></li>
<li><a href="/2011/01/18/download-images-with-php/" rel="bookmark" title="Download Images with PHP">Download Images with PHP </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Meta Tags and the Facebook Example</h2>
<p>You&#8217;ve definitely seen the &#8220;share a link&#8221; screen in <a title="Facebook Homepage" href="http://www.facebook.com/" target="_blank">Facebook</a>. When you paste a link into the box (fig. 1) and press the &#8220;Attach&#8221; button you&#8217;ll get the prompted cite parsed with a title, description and possibly thumb (fig. 2). This functionality is well known in Facebook, but it appears to be well known also in various social services. In fact <a title="LinkedIn Homepage" href="http://www.linkedin.com/" target="_blank">Linkedin</a>, <a title="Reddit Homepage" href="http://www.reddit.com/" target="_blank">Reddit</a>, <a title="DZone Homepage" href="http://www.dzone.com/" target="_blank">Dzone</a>&#8216;s <a title="DZone Bookmarklet" href="http://www.dzone.com/links/add.html" target="_blank">bookmarklet</a> use it.</p>
<figure id="attachment_2222" style="width: 518px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2011/02/facebook_attach_prompt_screen.png"><img class="size-full wp-image-2222" title="facebook_attach_prompt_screen" src="/wp-content/uploads/2011/02/facebook_attach_prompt_screen.png" alt="Facebook Attach a Link Prompt Screen" width="518" height="155" srcset="/wp-content/uploads/2011/02/facebook_attach_prompt_screen.png 518w, /wp-content/uploads/2011/02/facebook_attach_prompt_screen-300x89.png 300w" sizes="(max-width: 518px) 100vw, 518px" /></a><figcaption class="wp-caption-text">fig. 1 - Facebook Attach a Link Prompt Screen</figcaption></figure>
<p>Fist thing to notice is that this information, prompted by Facebook, is the same as the meta tag information. However there is a slight difference.</p>
<figure id="attachment_2224" style="width: 526px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2011/02/facebook_attached_link_screen.png"><img class="size-full wp-image-2224" title="facebook_attached_link_screen" src="/wp-content/uploads/2011/02/facebook_attached_link_screen.png" alt="Facebook Attached Link Screen" width="526" height="362" srcset="/wp-content/uploads/2011/02/facebook_attached_link_screen.png 526w, /wp-content/uploads/2011/02/facebook_attached_link_screen-300x206.png 300w" sizes="(max-width: 526px) 100vw, 526px" /></a><figcaption class="wp-caption-text">fig. 2 - Facebook Attached Link Screen</figcaption></figure>
<p>Facebook prefers for the thumb the image set into the &lt;meta property=&#8221;og:image&#8221; &#8230; /&gt;. In the case above this tag appears to be:</p>
<pre lang="html4strict" escaped="true">
<meta property="og:image" content="http://b.vimeocdn.com/ts/572/975/57297584_200.jpg" />
</pre>
<p>And the image pointed in the SRC attribute is exactly the same as the one prompted by Facebook (fig. 3).</p>
<figure id="attachment_2229" style="width: 200px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2011/02/vimeo_thumb.jpg"><img class="size-full wp-image-2229" title="vimeo_thumb" src="/wp-content/uploads/2011/02/vimeo_thumb.jpg" alt="Vimeo Thumb" width="200" height="150" /></a><figcaption class="wp-caption-text">fig. 3 - Vimeo Thumb</figcaption></figure>
<p>First thing to note is that the real thumb is bigger than the thumb shown in Facebook, so Facebook resizes it and the second thing to note is that there are more meta tags of the og:&#8230; format.<span id="more-2216"></span></p>
<h2>Meta Tags and The Open Graph Protocol</h2>
<p>By default meta tags contain various information about the web page. They are not visible in the webpage, but contain some info about it. The most common meta tags are the title, description and keywords tags. They of course contain the title of the page, not that this can be different from the &lt;title&gt; tag, a short description of the page and some keywords describing the content of the page. They are well known also because the search engines make use of them when trying to collect information about the page and the process of SEO passes through it.</p>
<p>However the <a title="Default HTML Meta Tags Specification" href="http://www.w3schools.com/tags/tag_meta.asp" target="_blank">default HTML meta tags</a> cannot contain everything. Thus for example you cannot point the preferable thumbnail for a webpage. The solution is the <a title="The Open Graph Protocol Homepage" href="http://ogp.me/" target="_blank">Open Graph Protocol</a>. It comes with meta tags that can contain more and more valuable info. Such a tag is the og:image meta tag. Note that all the Open Graph (og) meta tags are defined by the og: prefix before the entity name. Thus og:image comes for images, while og:longitude for geo positioning.</p>
<p>That&#8217;s really useful, but how you can read them?</p>
<h2>PHP, Meta Tags and Regexps</h2>
<p>When you try to read information from a webpage source the first possible path is by using <a title="Regular Expressions Explained on Wikipedia" href="http://en.wikipedia.org/wiki/Regular_expression" target="_blank">regular expressions</a>. However PHP is smart enough to offer you some useful functions. Such a function is <a title="PHP get_meta_tags Function Documentation" href="http://php.net/manual/en/function.get-meta-tags.php" target="_blank">get_meta_tags()</a>. As you may guess this method reads the meta tags by given URL.</p>
<pre lang="php" escaped="true">
$a = get_meta_tags('http://vimeo.com/10758212');
var_dump($a);
</pre>
<p>However this method can&#8217;t read Open Graph tags. So finally you&#8217;ve to use some regexps.</p>
<pre lang="php" escaped="true">
preg_match('/<meta property="og:image" content="(.*?)" \/>/', $source, $matches);
</pre>
<p>Now you can grab the og:image tag. And even more &#8211; grab every image (&lt;img&gt;) from that page.</p>
<pre lang="php" escaped="true">
preg_match_all('/<img src="(.*?)"/', $source, $m);
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/04/20/how-to-sanitize-user-input-in-php/" rel="bookmark" title="How to Sanitize User Input in PHP?">How to Sanitize User Input in PHP? </a></li>
<li><a href="/2010/08/03/html-tags/" rel="bookmark" title="HTML Tags: &lt;base&gt;">HTML Tags: &lt;base&gt; </a></li>
<li><a href="/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/" rel="bookmark" title="Automatically Upload Images with PHP Directly from the URI">Automatically Upload Images with PHP Directly from the URI </a></li>
<li><a href="/2011/01/18/download-images-with-php/" rel="bookmark" title="Download Images with PHP">Download Images with PHP </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A Memcached Zend_Cache</title>
		<link>/2011/01/17/a-memcached-zend_cache/</link>
		<comments>/2011/01/17/a-memcached-zend_cache/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 13:42:48 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[Computer memory]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[Memcached]]></category>
		<category><![CDATA[MMCache]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Zend_Cache]]></category>

		<guid isPermaLink="false">/?p=2121</guid>
		<description><![CDATA[Zend_Cache Usually Zend_Cache is used to store cache files on the file system, which can be really fast and useful in most of the cases. However there&#8217;s a faster cache mechanism and hopefully it&#8217;s supported by Zend_Cache as well. This is the Memcached backend. A Faster Cache Memcached is a really powerful tool to cache &#8230; <a href="/2011/01/17/a-memcached-zend_cache/" class="more-link">Continue reading <span class="screen-reader-text">A Memcached Zend_Cache</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/01/27/theory-of-caching-zend_cache-zend-optimizer/" rel="bookmark" title="Theory of caching. Zend_Cache &#038; Zend Optimizer.">Theory of caching. Zend_Cache &#038; Zend Optimizer. </a></li>
<li><a href="/2010/11/03/how-to-overcome-zend_cache_frontend_pages-problem-with-cookies/" rel="bookmark" title="How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies">How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies </a></li>
<li><a href="/2010/07/21/setting-up-global-cache-in-zend-framework/" rel="bookmark" title="Setting Up Global Cache in Zend Framework">Setting Up Global Cache in Zend Framework </a></li>
<li><a href="/2010/04/26/mysql-expressions-in-zend-framework/" rel="bookmark" title="MySQL Expressions in Zend Framework">MySQL Expressions in Zend Framework </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Zend_Cache</h2>
<p>Usually <a title="Zend_Cache" href="http://framework.zend.com/manual/en/zend.cache.html" target="_blank">Zend_Cache</a> is used to store cache files on the file system, which can be really fast and useful in most of the cases. However there&#8217;s a faster cache mechanism and hopefully it&#8217;s supported by Zend_Cache as well. This is the <a title="Memcached" href="http://memcached.org/" target="_blank">Memcached</a> backend.</p>
<h2>A Faster Cache</h2>
<p>Memcached is a really powerful tool to cache directly into the RAM. First, this tool has nothing to do primary with Zend Framework. It&#8217;s a server, usually started on some port, that can be called to store and get things from the memory. This of course is very fast, way faster than the cache in the hard drives.</p>
<h2>Zend_Cache and Memcached</h2>
<p>Zend_Cache has an interface to work with Memcached which is great as usual. The PHP example of Memcache (note that there are two things <a title="Memcache" href="http://php.net/manual/en/book.memcache.php" target="_blank">Memcache</a> and <a title="Memcached" href="http://memcached.org/" target="_blank">Memcached</a>, which are slight different) can be found here and as it says:</p>
<pre lang="php" escaped="true">
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");

$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";

$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;

$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";

$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";

var_dump($get_result);
</pre>
<p>However this can be coded into a Zend Framework style like that:</p>
<pre lang="php">
$frontend = array('caching' => true, 'lifetime' => 1800, 'automatic_serialization' => true);

$backend = array(
    'servers' =>array(
        array('host' => '127.0.0.1', 'port' => 11211)
    ),
    'compression' => false
);

$cache = Zend_Cache::factory('Core', 'Memcached', $frontend, $backend);
</pre>
<p>Note that you don&#8217;t have the typical &#8220;cache_dir&#8221;, just because everything&#8217;s cached into the memory.</p>
<p>Now you can call the cache as it&#8217;s called with the &#8220;File&#8221; backend interface:</p>
<pre lang="php">
$key = 'mykey';

if (($result = $cache->load($key)) === false) {
	// call the slow database query here ...
	// save in $result
	
	$cache->save($result, $key);	
}

echo $result
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/01/27/theory-of-caching-zend_cache-zend-optimizer/" rel="bookmark" title="Theory of caching. Zend_Cache &#038; Zend Optimizer.">Theory of caching. Zend_Cache &#038; Zend Optimizer. </a></li>
<li><a href="/2010/11/03/how-to-overcome-zend_cache_frontend_pages-problem-with-cookies/" rel="bookmark" title="How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies">How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies </a></li>
<li><a href="/2010/07/21/setting-up-global-cache-in-zend-framework/" rel="bookmark" title="Setting Up Global Cache in Zend Framework">Setting Up Global Cache in Zend Framework </a></li>
<li><a href="/2010/04/26/mysql-expressions-in-zend-framework/" rel="bookmark" title="MySQL Expressions in Zend Framework">MySQL Expressions in Zend Framework </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2011/01/17/a-memcached-zend_cache/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Can Twitter Replace the RSS Feed Readers</title>
		<link>/2010/08/23/can-twitter-replace-the-rss-feed-readers/</link>
		<comments>/2010/08/23/can-twitter-replace-the-rss-feed-readers/#respond</comments>
		<pubDate>Mon, 23 Aug 2010 18:07:19 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[favorite social site]]></category>
		<category><![CDATA[Online social networking]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1910</guid>
		<description><![CDATA[I&#8217;m sure this is not the first time you&#8217;ve been asked this question. However there&#8217;s nobody today that doesn&#8217;t wonder the answer. For me &#8211; yes, twitter can replace the RSS feed readers, and NO &#8211; feed readers are awsome! Yes First of all why do I use a feed reader? I&#8217;m simply seeing what&#8217;s &#8230; <a href="/2010/08/23/can-twitter-replace-the-rss-feed-readers/" class="more-link">Continue reading <span class="screen-reader-text">Can Twitter Replace the RSS Feed Readers</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/07/01/replace-the-broken-images-with-a-default-image-with-javascript/" rel="bookmark" title="Replace the Broken Images with a Default Image with JavaScript">Replace the Broken Images with a Default Image with JavaScript </a></li>
<li><a href="/2010/07/14/media-rss-and-zf-part-2/" rel="bookmark" title="Media RSS and ZF &#8211; Part 2">Media RSS and ZF &#8211; Part 2 </a></li>
<li><a href="/2010/07/13/zend-framework-and-media-rss/" rel="bookmark" title="Zend Framework and Media RSS">Zend Framework and Media RSS </a></li>
<li><a href="/2010/04/30/burn-feeds-in-zend-framework/" rel="bookmark" title="Burn Feeds in Zend Framework">Burn Feeds in Zend Framework </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p><a href="/wp-content/uploads/2010/08/rss.jpg"><img class="aligncenter size-full wp-image-1919" title="rss" src="/wp-content/uploads/2010/08/rss.jpg" alt="RSS" width="200" height="200" srcset="/wp-content/uploads/2010/08/rss.jpg 200w, /wp-content/uploads/2010/08/rss-150x150.jpg 150w" sizes="(max-width: 200px) 100vw, 200px" /></a></p>
<p>I&#8217;m sure this is not the first time you&#8217;ve been asked this question. However there&#8217;s nobody today that doesn&#8217;t wonder the answer. For me &#8211; yes, <a title="Twitter" href="http://twitter.com/" target="_blank">twitter</a> can replace the RSS feed readers, and NO &#8211; feed readers are awsome!</p>
<h2>Yes</h2>
<p>First of all why do I use a feed reader? I&#8217;m simply seeing what&#8217;s in it and barely read the article from the reader, but rather I jump to the site, and what&#8217;s happening often in twitter is the same scenario, I just see what&#8217;s in the tweet and if it seems to be interesting to me I jump to the link (if there&#8217;s a link). The good thing is that the tweets are limited and I&#8217;m focused. That&#8217;s why twitter is my favorite social site. I can follow all of the interesting people I know from their blogs. So perhaps twitter is becoming more useful than the feed readers.</p>
<h2>No</h2>
<p>In other hand in twitter you&#8217;ve to stay all the day long to get all the tweets you need. The timeline is quickly changing and sometimes you get lots of &#8220;junk&#8221;. While in the feed reader you&#8217;ve all the &#8220;important&#8221; posts as an incoming mail. You cannot miss anything! That&#8217;s why I cannot forget the feed readers they are doing a great job!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/07/01/replace-the-broken-images-with-a-default-image-with-javascript/" rel="bookmark" title="Replace the Broken Images with a Default Image with JavaScript">Replace the Broken Images with a Default Image with JavaScript </a></li>
<li><a href="/2010/07/14/media-rss-and-zf-part-2/" rel="bookmark" title="Media RSS and ZF &#8211; Part 2">Media RSS and ZF &#8211; Part 2 </a></li>
<li><a href="/2010/07/13/zend-framework-and-media-rss/" rel="bookmark" title="Zend Framework and Media RSS">Zend Framework and Media RSS </a></li>
<li><a href="/2010/04/30/burn-feeds-in-zend-framework/" rel="bookmark" title="Burn Feeds in Zend Framework">Burn Feeds in Zend Framework </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/08/23/can-twitter-replace-the-rss-feed-readers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Models in Zend Framework &#8211; Initialize All Methods with init()</title>
		<link>/2010/08/09/models-in-zend-framework-initialize-all-methods-with-init/</link>
		<comments>/2010/08/09/models-in-zend-framework-initialize-all-methods-with-init/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 19:05:05 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[given controller]]></category>
		<category><![CDATA[Init]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>

		<guid isPermaLink="false">/?p=1890</guid>
		<description><![CDATA[In the Zend Framework&#8217;s documentation there are lots of examples how you can initialize all the actions in a given controller &#8211; by simply adding the init() public method in the controller&#8217;s code:<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/08/06/setting-up-zend-framework-with-modules/" rel="bookmark" title="Setting Up Zend Framework with Modules">Setting Up Zend Framework with Modules </a></li>
<li><a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" rel="bookmark" title="Bind Zend Action with Non-Default View &#8211; Part 2">Bind Zend Action with Non-Default View &#8211; Part 2 </a></li>
<li><a href="/2010/07/07/default-error-handling-in-zend-framework/" rel="bookmark" title="Default Error Handling in Zend Framework">Default Error Handling in Zend Framework </a></li>
<li><a href="/2010/07/06/zend-framework-simple-acl-front-controller-plugin/" rel="bookmark" title="Zend Framework: Simple Acl Front Controller Plugin">Zend Framework: Simple Acl Front Controller Plugin </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>In the Zend Framework&#8217;s documentation there are lots of examples how you can initialize all the actions in a given controller &#8211; by simply adding the init() public method in the controller&#8217;s code:</p>
<pre lang="php">
<?php

class IndexController extends Zend_Controller_Action
{
	public function init()
	{
		echo 'foo';	
	}	
	
	public function indexAction()
	{
		// first the 'foo' string will be printed
		echo 'bar';	
	}
}
</pre>
<p>But did you know that you can do the same thing with any model in ZF? However you can setup a cache for every method or something else, but definitely it will execute for every method:</p>
<pre lang="php">
<?php

class MyModel
{
	public function init()
	{
		// prepare the cache setup
	}	
	
	public function readAll()
	{
		// the cache is already setup
		$sql = '...';
		// ...
	}
}
</pre>
<p>Of course that means that directly calling the readAll() function the init() method is called also - automatically.</p>
<h2>Conclusion</h2>
<p>There are good and bad parts about this. You'll have this code executed for every method and if you have twenty of them and the init() method is practically used for only a couple of the member functions - than this will be useless.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/08/06/setting-up-zend-framework-with-modules/" rel="bookmark" title="Setting Up Zend Framework with Modules">Setting Up Zend Framework with Modules </a></li>
<li><a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" rel="bookmark" title="Bind Zend Action with Non-Default View &#8211; Part 2">Bind Zend Action with Non-Default View &#8211; Part 2 </a></li>
<li><a href="/2010/07/07/default-error-handling-in-zend-framework/" rel="bookmark" title="Default Error Handling in Zend Framework">Default Error Handling in Zend Framework </a></li>
<li><a href="/2010/07/06/zend-framework-simple-acl-front-controller-plugin/" rel="bookmark" title="Zend Framework: Simple Acl Front Controller Plugin">Zend Framework: Simple Acl Front Controller Plugin </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/08/09/models-in-zend-framework-initialize-all-methods-with-init/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zend_Validate_Db_RecordExists in Zend Framework 1.10+</title>
		<link>/2010/07/22/zend_validate_db_recordexists-in-zend-framework-1-10/</link>
		<comments>/2010/07/22/zend_validate_db_recordexists-in-zend-framework-1-10/#respond</comments>
		<pubDate>Thu, 22 Jul 2010 11:24:46 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Column]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Data modeling]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Row]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>

		<guid isPermaLink="false">/?p=1809</guid>
		<description><![CDATA[Zend_Validate_Db_RecodExists is an extremely useful validator in Zend Framework when you&#8217;d like to be sure that a give row exists. Now it seems to be even better. Before you could check for a specific row by only comparing a value to the specified column: $validator = new Zend_Validate_Db_RecordExists('db_table_name', 'column_name'); if ($validator->isValid(122)) { ... } which &#8230; <a href="/2010/07/22/zend_validate_db_recordexists-in-zend-framework-1-10/" class="more-link">Continue reading <span class="screen-reader-text">Zend_Validate_Db_RecordExists in Zend Framework 1.10+</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/01/25/using-zend-framework-validators-zend_validate_db_recordexists/" rel="bookmark" title="Using Zend Framework validators &#8211; Zend_Validate_Db_RecordExists">Using Zend Framework validators &#8211; Zend_Validate_Db_RecordExists </a></li>
<li><a href="/2010/04/26/mysql-expressions-in-zend-framework/" rel="bookmark" title="MySQL Expressions in Zend Framework">MySQL Expressions in Zend Framework </a></li>
<li><a href="/2010/06/10/json-and-zend-framework-zend_json/" rel="bookmark" title="JSON and Zend Framework? &#8211; Zend_Json">JSON and Zend Framework? &#8211; Zend_Json </a></li>
<li><a href="/2010/07/06/zend-framework-simple-acl-front-controller-plugin/" rel="bookmark" title="Zend Framework: Simple Acl Front Controller Plugin">Zend Framework: Simple Acl Front Controller Plugin </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Zend_Validate_Db_RecodExists is an extremely useful validator in Zend Framework when you&#8217;d like to be sure that a give row exists. Now it seems to be even better. Before you could check for a specific row by only comparing a value to the specified column:</p>
<pre lang="php">
$validator = new Zend_Validate_Db_RecordExists('db_table_name', 'column_name');
if ($validator->isValid(122)) {
   ...
}
</pre>
<p>which made it useless when you&#8217;d like to compare by more than one column. Now this is changed and you can even exclude given rows by adding an exclude clause. </p>
<pre lang="php">
$validator = new Zend_Validate_Db_NoRecordExists(
    array(
        'table' => 'users',
        'field' => 'username',
        'exclude' => array(
            'field' => 'id',
            'value' => $user_id
        )
    )
);
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/01/25/using-zend-framework-validators-zend_validate_db_recordexists/" rel="bookmark" title="Using Zend Framework validators &#8211; Zend_Validate_Db_RecordExists">Using Zend Framework validators &#8211; Zend_Validate_Db_RecordExists </a></li>
<li><a href="/2010/04/26/mysql-expressions-in-zend-framework/" rel="bookmark" title="MySQL Expressions in Zend Framework">MySQL Expressions in Zend Framework </a></li>
<li><a href="/2010/06/10/json-and-zend-framework-zend_json/" rel="bookmark" title="JSON and Zend Framework? &#8211; Zend_Json">JSON and Zend Framework? &#8211; Zend_Json </a></li>
<li><a href="/2010/07/06/zend-framework-simple-acl-front-controller-plugin/" rel="bookmark" title="Zend Framework: Simple Acl Front Controller Plugin">Zend Framework: Simple Acl Front Controller Plugin </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/07/22/zend_validate_db_recordexists-in-zend-framework-1-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Mail with GMail</title>
		<link>/2010/07/18/zend_mail-with-gmail/</link>
		<comments>/2010/07/18/zend_mail-with-gmail/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 11:39:20 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Computer-mediated communication]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[E-mail]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[Gmail interface]]></category>
		<category><![CDATA[Human Interest]]></category>
		<category><![CDATA[Simple Mail Transfer Protocol]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1817</guid>
		<description><![CDATA[You know how to setup Zend_Mail with SMTP, but you don&#8217;t know how to set it up with GMail! Here&#8217;s how to do it. Just follow the instructions 😉 $mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', array( 'auth' => 'login', 'username' => 'xxxxxx@gmail.com', 'password' => 'passxxxxx', 'port' => '587', 'ssl' => 'tls', )); Zend_Mail::setDefaultTransport($mailTransport);<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/03/25/send-mail-with-zend-framework/" rel="bookmark" title="Send Mail with Zend Framework">Send Mail with Zend Framework </a></li>
<li><a href="/2010/07/17/send-html-mails-with-zend_mail/" rel="bookmark" title="Send Html Mails with Zend_Mail">Send Html Mails with Zend_Mail </a></li>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
<li><a href="/2010/07/20/zend-framework-connect-mysql/" rel="bookmark" title="Zend Framework: Connect MySQL">Zend Framework: Connect MySQL </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p><a href="/wp-content/uploads/2010/07/zend_mail_gmail.jpg"><img src="/wp-content/uploads/2010/07/zend_mail_gmail.jpg" alt="Zend_Mail and GMail" title="zend_mail_gmail" width="250" height="370" class="aligncenter size-full wp-image-1821" srcset="/wp-content/uploads/2010/07/zend_mail_gmail.jpg 250w, /wp-content/uploads/2010/07/zend_mail_gmail-202x300.jpg 202w" sizes="(max-width: 250px) 100vw, 250px" /></a><br />
You know how to setup Zend_Mail with SMTP, but you don&#8217;t know how to set it up with GMail! Here&#8217;s how to do it. Just follow the instructions <img src="https://s.w.org/images/core/emoji/11/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<pre lang="php">
$mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', array(
    'auth'     => 'login',
    'username' => 'xxxxxx@gmail.com',
    'password' => 'passxxxxx',
    'port'     => '587',
    'ssl'      => 'tls',
));
Zend_Mail::setDefaultTransport($mailTransport);
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/03/25/send-mail-with-zend-framework/" rel="bookmark" title="Send Mail with Zend Framework">Send Mail with Zend Framework </a></li>
<li><a href="/2010/07/17/send-html-mails-with-zend_mail/" rel="bookmark" title="Send Html Mails with Zend_Mail">Send Html Mails with Zend_Mail </a></li>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
<li><a href="/2010/07/20/zend-framework-connect-mysql/" rel="bookmark" title="Zend Framework: Connect MySQL">Zend Framework: Connect MySQL </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/07/18/zend_mail-with-gmail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Media RSS and ZF &#8211; Part 2</title>
		<link>/2010/07/14/media-rss-and-zf-part-2/</link>
		<comments>/2010/07/14/media-rss-and-zf-part-2/#respond</comments>
		<pubDate>Wed, 14 Jul 2010 19:05:15 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Computer file formats]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Software architecture]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Software framework]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">/?p=1803</guid>
		<description><![CDATA[Here&#8217;s the promised chunk of code making the most simple bridge between Zend Framework and Media RSS. Step 1 Just add a simple action in a controller: class IndexController extends Zend_Controller_Action { public function indexAction() { $this->getResponse()->setHeader('Content-Type', 'application/xml'); $this->view->somevar = 'some value'; echo $this->view->render('index/index.xml'); $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); } } Step 2 After you&#8217;ve setup the xml &#8230; <a href="/2010/07/14/media-rss-and-zf-part-2/" class="more-link">Continue reading <span class="screen-reader-text">Media RSS and ZF &#8211; Part 2</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/07/13/zend-framework-and-media-rss/" rel="bookmark" title="Zend Framework and Media RSS">Zend Framework and Media RSS </a></li>
<li><a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" rel="bookmark" title="Bind Zend Action with Non-Default View &#8211; Part 2">Bind Zend Action with Non-Default View &#8211; Part 2 </a></li>
<li><a href="/2010/05/25/download-files-with-zend-framework/" rel="bookmark" title="Download Files with Zend Framework">Download Files with Zend Framework </a></li>
<li><a href="/2010/08/06/setting-up-zend-framework-with-modules/" rel="bookmark" title="Setting Up Zend Framework with Modules">Setting Up Zend Framework with Modules </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s the promised chunk of code making the most simple bridge between Zend Framework and Media RSS.</p>
<h2>Step 1</h2>
<p>Just add a simple action in a controller:</p>
<pre lang="php">
class IndexController extends Zend_Controller_Action
{
	public function indexAction()
	{
	    $this->getResponse()->setHeader('Content-Type', 'application/xml');
	    $this->view->somevar = 'some value';
	
	    echo $this->view->render('index/index.xml');
	
	    $this->_helper->layout()->disableLayout();
	    $this->_helper->viewRenderer->setNoRender(true);
	}
}
</pre>
<h2>Step 2</h2>
<p>After you&#8217;ve setup the xml file as a view script &#8211; you can simply access it as a normal Zend Framework view:</p>
<pre lang="xml">
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:av="http://www.searchvideo.com/schemas/av/1.0">
  <channel>
   <title><?php echo $this->somevar ?></title>
   ...
   other media rss elements
   ...
</channel>
</rss>
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/07/13/zend-framework-and-media-rss/" rel="bookmark" title="Zend Framework and Media RSS">Zend Framework and Media RSS </a></li>
<li><a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" rel="bookmark" title="Bind Zend Action with Non-Default View &#8211; Part 2">Bind Zend Action with Non-Default View &#8211; Part 2 </a></li>
<li><a href="/2010/05/25/download-files-with-zend-framework/" rel="bookmark" title="Download Files with Zend Framework">Download Files with Zend Framework </a></li>
<li><a href="/2010/08/06/setting-up-zend-framework-with-modules/" rel="bookmark" title="Setting Up Zend Framework with Modules">Setting Up Zend Framework with Modules </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/07/14/media-rss-and-zf-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework: Simple Acl Front Controller Plugin</title>
		<link>/2010/07/06/zend-framework-simple-acl-front-controller-plugin/</link>
		<comments>/2010/07/06/zend-framework-simple-acl-front-controller-plugin/#respond</comments>
		<pubDate>Tue, 06 Jul 2010 19:00:59 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[access control list]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[Front Controller pattern]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Software design patterns]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>

		<guid isPermaLink="false">/?p=1771</guid>
		<description><![CDATA[Almost every web site need some abstraction over the access control list (ACL) to grant access of its users. As usual Zend Framework has quite good mechanism to deal with this &#8211; Zend_Acl. Out in the web there are a lot of resources about Zend_Acl&#8217;s usage, so I ain&#8217;t going to cover it one more &#8230; <a href="/2010/07/06/zend-framework-simple-acl-front-controller-plugin/" class="more-link">Continue reading <span class="screen-reader-text">Zend Framework: Simple Acl Front Controller Plugin</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/06/19/zend-framework-quick-tutorial-part-3-front-controller-plugins/" rel="bookmark" title="Zend Framework &#8211; quick tutorial (part 3) &#8211; front controller plugins">Zend Framework &#8211; quick tutorial (part 3) &#8211; front controller plugins </a></li>
<li><a href="/2010/08/06/setting-up-zend-framework-with-modules/" rel="bookmark" title="Setting Up Zend Framework with Modules">Setting Up Zend Framework with Modules </a></li>
<li><a href="/2010/07/21/setting-up-global-cache-in-zend-framework/" rel="bookmark" title="Setting Up Global Cache in Zend Framework">Setting Up Global Cache in Zend Framework </a></li>
<li><a href="/2010/06/10/json-and-zend-framework-zend_json/" rel="bookmark" title="JSON and Zend Framework? &#8211; Zend_Json">JSON and Zend Framework? &#8211; Zend_Json </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p><a href="/wp-content/uploads/2010/07/access.jpg"><img class="aligncenter size-full wp-image-1776" title="access" src="/wp-content/uploads/2010/07/access.jpg" alt="access with Zend_Acl" width="430" height="286" srcset="/wp-content/uploads/2010/07/access.jpg 430w, /wp-content/uploads/2010/07/access-300x199.jpg 300w" sizes="(max-width: 430px) 100vw, 430px" /></a></p>
<p>Almost every web site need some abstraction over the access control list (ACL) to grant access of its users. As usual Zend Framework has quite good mechanism to deal with this &#8211; <a title="Zend_Acl" href="http://framework.zend.com/manual/en/zend.acl.html" target="_blank">Zend_Acl</a>.</p>
<p>Out in the web there are a lot of resources about Zend_Acl&#8217;s usage, so I ain&#8217;t going to cover it one more time, but simply copy/paste a very small front controller plugin implementing the basic usage of Zend_Acl.</p>
<p>Note that instead of defining the __construct() here is called preDispatch where the request is passed as a parameter. However only by copy pasting not every answer will be given. That&#8217;s why I&#8217;m going to write more about Zend_Acl in my future posts, for now only the source code:</p>
<pre lang="php">
<?php

class AclInit extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        // create new acl object
        $acl = new Zend_Acl();

        // define resources. typically there are
        // only four resources from the CRUD functionality
        // but there can be added more resources
        $acl->add(new Zend_Acl_Resource('index'))
            ->add(new Zend_Acl_Resource('create'))
            ->add(new Zend_Acl_Resource('read'))
            ->add(new Zend_Acl_Resource('update'))
            ->add(new Zend_Acl_Resource('delete'));

        // define roles
        $acl->addRole(new Zend_Acl_Role('guest'))
            ->addRole(new Zend_Acl_Role('admin'));

        // define privileges
        $acl->allow('guest', array('index', 'read'))
            ->allow('admin');

        // setup acl in the registry for more
        Zend_Registry::set('acl', $acl);

        // check permissions
        if (!$acl->isAllowed('guest', $request->getActionName())) {
            $request->setControllerName('error');
            $request->setActionName('error');
        }
    }
}
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/06/19/zend-framework-quick-tutorial-part-3-front-controller-plugins/" rel="bookmark" title="Zend Framework &#8211; quick tutorial (part 3) &#8211; front controller plugins">Zend Framework &#8211; quick tutorial (part 3) &#8211; front controller plugins </a></li>
<li><a href="/2010/08/06/setting-up-zend-framework-with-modules/" rel="bookmark" title="Setting Up Zend Framework with Modules">Setting Up Zend Framework with Modules </a></li>
<li><a href="/2010/07/21/setting-up-global-cache-in-zend-framework/" rel="bookmark" title="Setting Up Global Cache in Zend Framework">Setting Up Global Cache in Zend Framework </a></li>
<li><a href="/2010/06/10/json-and-zend-framework-zend_json/" rel="bookmark" title="JSON and Zend Framework? &#8211; Zend_Json">JSON and Zend Framework? &#8211; Zend_Json </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/07/06/zend-framework-simple-acl-front-controller-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bind Zend Action with Non-Default View &#8211; Part 2</title>
		<link>/2010/06/23/bind-zend-action-with-non-default-view-part-2/</link>
		<comments>/2010/06/23/bind-zend-action-with-non-default-view-part-2/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 14:26:41 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend view renderer]]></category>

		<guid isPermaLink="false">/?p=1664</guid>
		<description><![CDATA[Typical Setup Typically Zend Framework is setup to bind every controller&#8217;s action to a specific view. The names of the action and the view script must be the same, or at least must be similar &#8211; following the ZF&#8217;s convention. Thus if you name an action, let&#8217;s say, indexAction(), you&#8217;ve to create an index.phtml file &#8230; <a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" class="more-link">Continue reading <span class="screen-reader-text">Bind Zend Action with Non-Default View &#8211; Part 2</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/06/07/bind-zend-action-with-non-default-view/" rel="bookmark" title="Bind Zend Action with Non-Default View">Bind Zend Action with Non-Default View </a></li>
<li><a href="/2010/06/24/zend-framework-inject-javascript-code-in-a-actionview/" rel="bookmark" title="Zend Framework: Inject JavaScript Code in a Action/View">Zend Framework: Inject JavaScript Code in a Action/View </a></li>
<li><a href="/2010/01/29/escaping-strings-in-a-zend-framework-view-prevent-unclosed-tags/" rel="bookmark" title="Escaping strings in a Zend Framework view. Prevent unclosed tags!">Escaping strings in a Zend Framework view. Prevent unclosed tags! </a></li>
<li><a href="/2010/04/27/inline-scripts-with-zend_view_helper_inlinescript/" rel="bookmark" title="Inline Scripts with Zend_View_Helper_InlineScript">Inline Scripts with Zend_View_Helper_InlineScript </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Typical Setup</h2>
<p>Typically <a href="http://framework.zend.com/">Zend Framework</a> is setup to bind every controller&#8217;s action to a specific view. The names of the action and the view script must be the same, or at least must be similar &#8211; following the ZF&#8217;s convention.</p>
<p>Thus if you name an action, let&#8217;s say, indexAction(), you&#8217;ve to create an index.phtml file into the views/scripts/index/ folder. Let me remind you that this is what is called a typical setup, but this may vary from one installation to another.</p>
<p>Thus everything&#8217;s fine and the MVC does its best. After the user requests a specific uri, the framework parses it and finds the controller, than the action and than the view script &#8211; and there is a view script for every single action.</p>
<p><a href="/wp-content/uploads/2010/06/typical-zend-framework-setup.jpg"><img class="alignleft size-medium wp-image-1675" title="typical-zend-framework-setup" src="/wp-content/uploads/2010/06/typical-zend-framework-setup-300x162.jpg" alt="typical zend framework setup" width="300" height="162" srcset="/wp-content/uploads/2010/06/typical-zend-framework-setup-300x162.jpg 300w, /wp-content/uploads/2010/06/typical-zend-framework-setup.jpg 545w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>When there are two or more actions &#8211; there are two or more .phtml (view scripts) files.</p>
<p><a href="/wp-content/uploads/2010/06/typical-zend-framework-setup2.jpg"><img class="alignleft size-medium wp-image-1676" title="typical-zend-framework-setup2" src="/wp-content/uploads/2010/06/typical-zend-framework-setup2-300x203.jpg" alt="typical zend framework setup for two or more actions" width="300" height="203" srcset="/wp-content/uploads/2010/06/typical-zend-framework-setup2-300x203.jpg 300w, /wp-content/uploads/2010/06/typical-zend-framework-setup2.jpg 630w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<h2>Some Exceptions</h2>
<p>Sometimes you have very similar logic, but very different markup between two actions. As the logic goes to the controller/action and the markup into the view, the question is can you simply have one action in the controller, but with two different .phtml file as a view scripts?  Of course switching between those two (or more) with some conditionals.</p>
<h3>Solution No. 1</h3>
<p>However once I posted a simple, and working, <a href="/2010/06/07/bind-zend-action-with-non-default-view/">solution</a>. There you have again two actions and two scripts:</p>
<pre lang="php">
<?php

class IndexController extends Zend_Controller_Action
{	
	public function firstAction()
	{
		// place all the logic you need here
		// and every view placeholder assignment
		$this->view->title = "My Title";
		
		// if the logic requires a different markup
		// simply redirect to another view
		if (some_expression) {
			$this->_forward('second');	
		}	
	}
	
	public function secondAction()
	{}
}

// in the application/views/scripts/index
// 1. first.phtml
<h1><?php echo $this->title ?></h1>

// 2. second.phtml
<h2><?php echo $this->title ?></h2>
</pre>
<p>As you can see in the second action there&#8217;s no logic &#8211; it&#8217;s only serving the role of a bridge between the views. Everything is setup into the first action, but the second action is doing the relation with the second.phtml view script.</p>
<h3>Solution No. 2</h3>
<p>However there&#8217;s another solution with only one action and two scripts which makes something like that shown on the diagram bellow:</p>
<p><a href="/wp-content/uploads/2010/06/zend-framework-one-action-multiple-views.jpg"><img class="alignleft size-medium wp-image-1677" title="zend-framework-one-action-multiple-views" src="/wp-content/uploads/2010/06/zend-framework-one-action-multiple-views-300x203.jpg" alt="zend framework one action multiple=" height="203" srcset="/wp-content/uploads/2010/06/zend-framework-one-action-multiple-views-300x203.jpg 300w, /wp-content/uploads/2010/06/zend-framework-one-action-multiple-views.jpg 630w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>The only thing to do is to add some code to your action:</p>
<pre lang="php">
<?php

class IndexController extends Zend_Controller_Action
{	
	public function firstAction()
	{
		// place all the logic you need here
		// and every view placeholder assignment
		$this->view->title = "My Title";
		
		// if the logic requires a different markup
		// simply redirect to another view
		if (some_expression) {
			echo $this->view->render('index/second.phtml');
			$this->_helper->viewRenderer->setNoRender(true);
		}	
	}
}

// in the application/views/scripts/index
// 1. first.phtml
<h1><?php echo $this->title ?></h1>

// 2. second.phtml
<h2><?php echo $this->title ?></h2>
</pre>
<p>Note that you&#8217;ve to setNoRender on the view renderer once you render the other script!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/06/07/bind-zend-action-with-non-default-view/" rel="bookmark" title="Bind Zend Action with Non-Default View">Bind Zend Action with Non-Default View </a></li>
<li><a href="/2010/06/24/zend-framework-inject-javascript-code-in-a-actionview/" rel="bookmark" title="Zend Framework: Inject JavaScript Code in a Action/View">Zend Framework: Inject JavaScript Code in a Action/View </a></li>
<li><a href="/2010/01/29/escaping-strings-in-a-zend-framework-view-prevent-unclosed-tags/" rel="bookmark" title="Escaping strings in a Zend Framework view. Prevent unclosed tags!">Escaping strings in a Zend Framework view. Prevent unclosed tags! </a></li>
<li><a href="/2010/04/27/inline-scripts-with-zend_view_helper_inlinescript/" rel="bookmark" title="Inline Scripts with Zend_View_Helper_InlineScript">Inline Scripts with Zend_View_Helper_InlineScript </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/06/23/bind-zend-action-with-non-default-view-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
