<?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>Magento Design and Development &#187; Zend</title>
	<atom:link href="http://inchoo.net/tag/zend/feed/" rel="self" type="application/rss+xml" />
	<link>http://inchoo.net</link>
	<description>Magento Design and Magento Development Professionals - Inchoo</description>
	<lastBuildDate>Mon, 06 Feb 2012 08:30:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Unit testing with Zend framework: Setting up environment for the first test using Netbeans IDE for php</title>
		<link>http://inchoo.net/tools-frameworks/unit-testing-with-zend-framework-setting-up-environment-for-the-first-test-using-netbeans-ide-for-php/</link>
		<comments>http://inchoo.net/tools-frameworks/unit-testing-with-zend-framework-setting-up-environment-for-the-first-test-using-netbeans-ide-for-php/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 14:49:49 +0000</pubDate>
		<dc:creator>Darko Goles</dc:creator>
				<category><![CDATA[Tools & Frameworks]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=8862</guid>
		<description><![CDATA[Assuming that you already installed PHPUnit because there are already many tutorials about that, I will write just one short tutorial about setting up test environment for Zend application. I am currently using windows 7, and NetBeans IDE for php &#8230;<p><a href="http://inchoo.net/tools-frameworks/unit-testing-with-zend-framework-setting-up-environment-for-the-first-test-using-netbeans-ide-for-php/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>Assuming that you already installed PHPUnit because there are already many tutorials about that, I will write just one short tutorial about setting up test environment for Zend application. I am currently using windows 7, and NetBeans IDE for php 6.9.1. <span id="more-8862"></span>First we have to setup some PHPUnit options in NetBeans, so go to:<br />
<strong>Tools -&gt; Options -&gt; Php -&gt; Unit Testing</strong><br />
and click on Browse and choose location of your installed PHPUnit script (phpunit.bat) which is often located in php – installation folder and click OK to confirm selection.</p>
<p><img class="alignleft size-full wp-image-8863" title="NB_PHPUnit_001" src="http://inchoo.net/wp-content/uploads/2011/03/NB_PHPUnit_001.jpg" alt="" width="600" height="446" /></p>
<p>Now we can create new Php project based on Zend framework, or open some existing Zend project in which we will write our first test. In NB I am using Zend tool integration to generate first project sources.</p>
<p>When the project is opened/created, in projects window right click on project name and choose <strong>Properties.</strong><br />
After the project properties window is opened, click on PHPUnit category on the left side, and on the right of the window we can see PHPUnit configuration options. For this tutorial, let&#8217;s select “Use bootstrap” option and click “Generate” button on the right, so new bootstrap.php file is generated inside folder “tests” of our Zend application.<img class="alignleft size-full wp-image-8864" title="NB_PHPUnit_002" src="http://inchoo.net/wp-content/uploads/2011/03/NB_PHPUnit_002.jpg" alt="" width="600" height="434" /></p>
<p>In that file we will put all basic configuration for our application testing and necessary include paths like this:</p>
<p><em>bootstrap.php</em></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
error_reporting( E_ALL | E_STRICT );
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);

define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
define('APPLICATION_ENV', 'testing');
define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library'));
define('TESTS_PATH', realpath(dirname(__FILE__)));

$_SERVER['SERVER_NAME'] = 'http://cea.local';

$includePaths = array(LIBRARY_PATH, get_include_path());
set_include_path(implode(PATH_SEPARATOR, $includePaths));

require_once &quot;Zend/Loader/Autoloader.php&quot;;

$loader = Zend_Loader_Autoloader::getInstance();
$loader-&gt;setFallbackAutoloader(true);
$loader-&gt;suppressNotFoundWarnings(false);

Zend_Session::$_unitTestEnabled = true;
Zend_Session::start();

?&gt;
</pre>
<p>When this is done, let&#8217;s write first controller test case to see if that&#8217;s working properly.<br />
(In my current configuration, when I create new controller  in project using Zend tool integration,<br />
there is also new file created inside “tests/Application/Controllers” folder named “Original_controller_nameTest.php”).</p>
<p>If controllerTest is not created , we can always create it manually.</p>
<p>Create new php class document and save it inside  “tests/application/controllers/” folder and give it a name: “IndexControllerTest.php”.<br />
Enter code inside like this:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase {

    public function setUp() {
        $this-&gt;bootstrap = new Zend_Application(
                        'testing',
                        APPLICATION_PATH . '/configs/application.ini'
        );
        parent::setUp();
    }

    public function testHomePageIsASuccessfulRequest() {
        $this-&gt;dispatch('/index');
        $this-&gt;assertFalse($this-&gt;response
                        -&gt;isException());
        $this-&gt;assertNotRedirect();
    }

    public function tearDown() {
        /* Tear Down Routine */
    }

}
</pre>
<p>Now it&#8217;s time for testing: right click on the project name in projects explorer and choose “Test” or press Alt+F6 combination to run tests.</p>
<p>If everything is set up properly, then you will see test results in “test result” window.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/unit-testing-with-zend-framework-setting-up-environment-for-the-first-test-using-netbeans-ide-for-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ZendFramework example on using Google URL Shortener service</title>
		<link>http://inchoo.net/tools-frameworks/zendframework-example-on-using-google-url-shortener-service/</link>
		<comments>http://inchoo.net/tools-frameworks/zendframework-example-on-using-google-url-shortener-service/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 00:20:52 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Tools & Frameworks]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=10033</guid>
		<description><![CDATA[Seems like URL shorteners have gain extreme popularity with web services like Twitter. Not to mention the fact that long URLs are somewhat hard to pass along. They are also harder to verbalize in a conversation, and above all in &#8230;<p><a href="http://inchoo.net/tools-frameworks/zendframework-example-on-using-google-url-shortener-service/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>Seems like URL shorteners have gain extreme popularity with web services like Twitter. Not to mention the fact that long URLs are somewhat hard to pass along. They are also harder to verbalize in a conversation, and above all in some cases they are almost impossible to remember.</p>
<p>There are quite a large number of URL shorteners out there these days, mostly free. One of the freshest is Google’s URL shortener. This article is not about outlining the features that make this shortener better then the other ones (as I am sure some offer more features at the moment). This article is merely for the purpose of showing you how easy it is to use the Google URL Shortener service via your ZendFramework libraries.<span id="more-10033"></span></p>
<p>Basically all we need is the instance of Zend_Http_Client class and preferably the API key for Google URL Shortener. For API key, just follow the instructions outlined here.</p>
<p>Here are the few actions you can with the Google URL Shortener at the moment:</p>
<ul>
<li>Shorten a long URL</li>
<li>Expand a short URL</li>
<li>Look up a short URL&#8217;s analytics</li>
<li>Look up a user&#8217;s history</li>
</ul>
<p><strong><em>Example #1</em> &#8211; Shorten a long URL</strong></p>
<pre class="brush: php; title: ; notranslate">
$client = new Zend_Http_Client();

$client-&gt;setUri('https://www.googleapis.com/urlshortener/v1/url');
$client-&gt;setHeaders(Zend_Http_Client::CONTENT_TYPE, 'application/json');
$client-&gt;setMethod(Zend_Http_Client::POST);

$payload = json_encode(array(
    'longUrl' =&gt; 'http://activecodeline.net/',
    'key' =&gt; '___YOUR_API_KEY_HERE___'
));

$client-&gt;setRawData($payload);

$response = $client-&gt;request();
</pre>
<p>Below you can see the example of response for the above request.</p>
<pre class="brush: php; title: ; notranslate">
Zend_Debug::dump($response, '$response');

/**
$response object(Zend_Http_Response)#225 (5) {
  [&quot;version&quot;:protected] =&gt; string(3) &quot;1.1&quot;
  [&quot;code&quot;:protected] =&gt; int(200)
  [&quot;message&quot;:protected] =&gt; string(2) &quot;OK&quot;
  [&quot;headers&quot;:protected] =&gt; array(11) {
    [&quot;Cache-control&quot;] =&gt; string(46) &quot;no-cache, no-store, max-age=0, must-revalidate&quot;
    [&quot;Pragma&quot;] =&gt; string(8) &quot;no-cache&quot;
    [&quot;Expires&quot;] =&gt; string(29) &quot;Fri, 01 Jan 1990 00:00:00 GMT&quot;
    [&quot;Date&quot;] =&gt; string(29) &quot;Sat, 26 Feb 2011 08:06:45 GMT&quot;
    [&quot;Content-type&quot;] =&gt; string(31) &quot;application/json; charset=UTF-8&quot;
    [&quot;X-content-type-options&quot;] =&gt; string(7) &quot;nosniff&quot;
    [&quot;X-frame-options&quot;] =&gt; string(10) &quot;SAMEORIGIN&quot;
    [&quot;X-xss-protection&quot;] =&gt; string(13) &quot;1; mode=block&quot;
    [&quot;Server&quot;] =&gt; string(3) &quot;GSE&quot;
    [&quot;Connection&quot;] =&gt; string(5) &quot;close&quot;
  }
  [&quot;body&quot;:protected] =&gt; string(104) &quot;{
 &quot;kind&quot;: &quot;urlshortener#url&quot;,
 &quot;id&quot;: &quot;http://goo.gl/7rDDa&quot;,
 &quot;longUrl&quot;: &quot;http://activecodeline.net/&quot;
}
&quot;
}

*/
</pre>
<p><strong><em>Example #2</em> &#8211; Expand a short URL</strong></p>
<pre class="brush: php; title: ; notranslate">
$client = new Zend_Http_Client();

$client-&gt;setUri('https://www.googleapis.com/urlshortener/v1/url');
$client-&gt;setMethod(Zend_Http_Client::GET);
$client-&gt;setParameterGet('shortUrl', 'http://goo.gl/7rDDa');
$client-&gt;setParameterGet('key', '___YOUR_API_KEY_HERE___');

$client-&gt;setRawData($payload);

$response = $client-&gt;request();
</pre>
<p>Below you can see the example of response for the above request.</p>
<pre class="brush: php; title: ; notranslate">
Zend_Debug::dump($response, '$response');

/**

$response object(Zend_Http_Response)#225 (5) {
  [&quot;version&quot;:protected] =&gt; string(3) &quot;1.1&quot;
  [&quot;code&quot;:protected] =&gt; int(200)
  [&quot;message&quot;:protected] =&gt; string(2) &quot;OK&quot;
  [&quot;headers&quot;:protected] =&gt; array(11) {
    [&quot;Expires&quot;] =&gt; string(29) &quot;Sat, 26 Feb 2011 08:37:13 GMT&quot;
    [&quot;Date&quot;] =&gt; string(29) &quot;Sat, 26 Feb 2011 08:32:13 GMT&quot;
    [&quot;Content-type&quot;] =&gt; string(31) &quot;application/json; charset=UTF-8&quot;
    [&quot;X-content-type-options&quot;] =&gt; string(7) &quot;nosniff&quot;
    [&quot;X-frame-options&quot;] =&gt; string(10) &quot;SAMEORIGIN&quot;
    [&quot;X-xss-protection&quot;] =&gt; string(13) &quot;1; mode=block&quot;
    [&quot;Server&quot;] =&gt; string(3) &quot;GSE&quot;
    [&quot;Cache-control&quot;] =&gt; string(50) &quot;public, max-age=300, must-revalidate, no-transform&quot;
    [&quot;Age&quot;] =&gt; string(2) &quot;48&quot;
    [&quot;Connection&quot;] =&gt; string(5) &quot;close&quot;
  }
  [&quot;body&quot;:protected] =&gt; string(121) &quot;{
 &quot;kind&quot;: &quot;urlshortener#url&quot;,
 &quot;id&quot;: &quot;http://goo.gl/7rDDa&quot;,
 &quot;longUrl&quot;: &quot;http://activecodeline.net/&quot;,
 &quot;status&quot;: &quot;OK&quot;
}
&quot;
}

*/
</pre>
<p><strong><em>Example #3</em> &#8211; Look up a short URL&#8217;s analytics</strong></p>
<pre class="brush: php; title: ; notranslate">
$client = new Zend_Http_Client();

$client-&gt;setUri('https://www.googleapis.com/urlshortener/v1/url');
$client-&gt;setMethod(Zend_Http_Client::GET);
$client-&gt;setParameterGet('shortUrl', 'http://goo.gl/7rDDa');
$client-&gt;setParameterGet('projection', 'FULL');
$client-&gt;setParameterGet('key', '___YOUR_API_KEY_HERE___');

$client-&gt;setRawData($payload);

$response = $client-&gt;request();
</pre>
<p>Below you can see the example of response for the above request.</p>
<pre class="brush: php; title: ; notranslate">
Zend_Debug::dump($response, '$response');

/**

$response object(Zend_Http_Response)#225 (5) {
  [&quot;version&quot;:protected] =&gt; string(3) &quot;1.1&quot;
  [&quot;code&quot;:protected] =&gt; int(200)
  [&quot;message&quot;:protected] =&gt; string(2) &quot;OK&quot;
  [&quot;headers&quot;:protected] =&gt; array(10) {
    [&quot;Expires&quot;] =&gt; string(29) &quot;Sat, 26 Feb 2011 08:36:40 GMT&quot;
    [&quot;Date&quot;] =&gt; string(29) &quot;Sat, 26 Feb 2011 08:36:40 GMT&quot;
    [&quot;Cache-control&quot;] =&gt; string(48) &quot;public, max-age=0, must-revalidate, no-transform&quot;
    [&quot;Content-type&quot;] =&gt; string(31) &quot;application/json; charset=UTF-8&quot;
    [&quot;X-content-type-options&quot;] =&gt; string(7) &quot;nosniff&quot;
    [&quot;X-frame-options&quot;] =&gt; string(10) &quot;SAMEORIGIN&quot;
    [&quot;X-xss-protection&quot;] =&gt; string(13) &quot;1; mode=block&quot;
    [&quot;Server&quot;] =&gt; string(3) &quot;GSE&quot;
    [&quot;Connection&quot;] =&gt; string(5) &quot;close&quot;
  }
  [&quot;body&quot;:protected] =&gt; string(2042) &quot;{
 &quot;kind&quot;: &quot;urlshortener#url&quot;,
 &quot;id&quot;: &quot;http://goo.gl/7rDDa&quot;,
 &quot;longUrl&quot;: &quot;http://activecodeline.net/&quot;,
 &quot;status&quot;: &quot;OK&quot;,
 &quot;created&quot;: &quot;2011-02-26T08:06:45.845+00:00&quot;,
 &quot;analytics&quot;: {
  &quot;allTime&quot;: {
   &quot;shortUrlClicks&quot;: &quot;1&quot;,
   &quot;longUrlClicks&quot;: &quot;1&quot;,
   &quot;referrers&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Unknown/empty&quot;
    }
   ],
   &quot;countries&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;HR&quot;
    }
   ],
   &quot;browsers&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Chrome&quot;
    }
   ],
   &quot;platforms&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Windows&quot;
    }
   ]
  },
  &quot;month&quot;: {
   &quot;shortUrlClicks&quot;: &quot;1&quot;,
   &quot;longUrlClicks&quot;: &quot;1&quot;,
   &quot;referrers&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Unknown/empty&quot;
    }
   ],
   &quot;countries&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;HR&quot;
    }
   ],
   &quot;browsers&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Chrome&quot;
    }
   ],
   &quot;platforms&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Windows&quot;
    }
   ]
  },
  &quot;week&quot;: {
   &quot;shortUrlClicks&quot;: &quot;1&quot;,
   &quot;longUrlClicks&quot;: &quot;1&quot;,
   &quot;referrers&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Unknown/empty&quot;
    }
   ],
   &quot;countries&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;HR&quot;
    }
   ],
   &quot;browsers&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Chrome&quot;
    }
   ],
   &quot;platforms&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Windows&quot;
    }
   ]
  },
  &quot;day&quot;: {
   &quot;shortUrlClicks&quot;: &quot;1&quot;,
   &quot;longUrlClicks&quot;: &quot;1&quot;,
   &quot;referrers&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Unknown/empty&quot;
    }
   ],
   &quot;countries&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;HR&quot;
    }
   ],
   &quot;browsers&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Chrome&quot;
    }
   ],
   &quot;platforms&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Windows&quot;
    }
   ]
  },
  &quot;twoHours&quot;: {
   &quot;shortUrlClicks&quot;: &quot;1&quot;,
   &quot;longUrlClicks&quot;: &quot;1&quot;,
   &quot;referrers&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Unknown/empty&quot;
    }
   ],
   &quot;countries&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;HR&quot;
    }
   ],
   &quot;browsers&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Chrome&quot;
    }
   ],
   &quot;platforms&quot;: [
    {
     &quot;count&quot;: &quot;1&quot;,
     &quot;id&quot;: &quot;Windows&quot;
    }
   ]
  }
 }
}
&quot;
}

*/
</pre>
<p>The above 3 examples are pretty easy, and straight forward. Last example, &#8220;Look up a user&#8217;s history&#8221;, requires a bit more finesse as it requires your/user authentication in order to get the proper response. There are several ways you can authenticate (OAuth, ClientLogin). OAuth is the preferred mechanism for logging in and performing actions on behalf of a Google user. </p>
<p>If Oauth is not feasible, you can use ClientLogin. With this mechanism, you give google.com an email and password in exchange for an access token.</p>
<p>In this last example &#8220;Look up a user&#8217;s history&#8221; I will show you how to do it with ClientLogin approach as it is somewhat simpler. However, this does not mean that ClientLogin approach will suite your needs, in which case you should really study the Oauth implementation.</p>
<p><strong><em>Example #4</em> &#8211; Look up a user&#8217;s history</strong></p>
<pre class="brush: php; title: ; notranslate">
$clientLogin = new Zend_Http_Client();

$clientLogin-&gt;setUri('https://www.google.com/accounts/ClientLogin');
$clientLogin-&gt;setMethod(Zend_Http_Client::POST);
$clientLogin-&gt;setHeaders(Zend_Http_Client::CONTENT_TYPE, 'application/x-www-form-urlencoded');
$clientLogin-&gt;setParameterPost('accountType', 'HOSTED_OR_GOOGLE');
$clientLogin-&gt;setParameterPost('Email', '_YOUR_GOOGLE_EMAIL_HERE_');
$clientLogin-&gt;setParameterPost('Passwd', '_YOUR_GOOGLE_PASS_HERE_');
$clientLogin-&gt;setParameterPost('service', 'urlshortener');
$clientLogin-&gt;setParameterPost('source', 'myname-testapp-1.0.1');

$responseLogin = $clientLogin-&gt;request();
$responseLoginBody = $responseLogin-&gt;getBody();

$loginTokens = explode(&quot;\n&quot;, $responseLoginBody);
$authToken = '';

foreach ($loginTokens as $r) {
    $_r = explode(&quot;=&quot;, $r);
    if (count($_r) &gt; 1) {
        if ($_r[0] == 'Auth') {
            $authToken = $_r[1];
        }
    }
}

if (!empty($authToken)) {
    $clientHistory = new Zend_Http_Client();

    $clientHistory-&gt;setUri('https://www.googleapis.com/urlshortener/v1/url/history');
    $clientHistory-&gt;setMethod(Zend_Http_Client::GET);
    $clientHistory-&gt;setHeaders(Zend_Http_Client::CONTENT_TYPE, 'application/json');
    $clientHistory-&gt;setHeaders('Authorization', 'GoogleLogin auth='.$authToken);
    $clientHistory-&gt;setParameterGet('key', '___YOUR_API_KEY_HERE___');

    $responseHistory = $clientHistory-&gt;request();
    $responseHistoryBody = $responseHistory-&gt;getBody();
    //Zend_Debug::dump($responseHistoryBody, '$responseHistoryBody');
    //Zend_Debug::dump($responseHistory, '$responseHistory');
}
</pre>
<p>Below you can see the example of response for the above request.</p>
<pre class="brush: php; title: ; notranslate">
Zend_Debug::dump($responseHistory, '$responseHistory');

/**

$responseHistory object(Zend_Http_Response)#237 (5) {
  [&quot;version&quot;:protected] =&gt; string(3) &quot;1.1&quot;
  [&quot;code&quot;:protected] =&gt; int(200)
  [&quot;message&quot;:protected] =&gt; string(2) &quot;OK&quot;
  [&quot;headers&quot;:protected] =&gt; array(10) {
    [&quot;Expires&quot;] =&gt; string(29) &quot;Sat, 26 Feb 2011 10:20:34 GMT&quot;
    [&quot;Date&quot;] =&gt; string(29) &quot;Sat, 26 Feb 2011 10:20:34 GMT&quot;
    [&quot;Cache-control&quot;] =&gt; string(49) &quot;private, max-age=0, must-revalidate, no-transform&quot;
    [&quot;Content-type&quot;] =&gt; string(31) &quot;application/json; charset=UTF-8&quot;
    [&quot;X-content-type-options&quot;] =&gt; string(7) &quot;nosniff&quot;
    [&quot;X-frame-options&quot;] =&gt; string(10) &quot;SAMEORIGIN&quot;
    [&quot;X-xss-protection&quot;] =&gt; string(13) &quot;1; mode=block&quot;
    [&quot;Server&quot;] =&gt; string(3) &quot;GSE&quot;
    [&quot;Connection&quot;] =&gt; string(5) &quot;close&quot;
  }
  [&quot;body&quot;:protected] =&gt; string(2943) &quot;{
 &quot;kind&quot;: &quot;urlshortener#urlHistory&quot;,
 &quot;totalItems&quot;: 13,
 &quot;itemsPerPage&quot;: 30,
 &quot;items&quot;: [
  {
   &quot;kind&quot;: &quot;urlshortener#url&quot;,
   &quot;id&quot;: &quot;http://goo.gl/IkFNS&quot;,
   &quot;longUrl&quot;: &quot;http://www.jetbrains.com/phpstorm/whatsnew/index.html&quot;,
   &quot;status&quot;: &quot;OK&quot;,
   &quot;created&quot;: &quot;2011-02-25T09:29:03.995+00:00&quot;
  },
  {
   &quot;kind&quot;: &quot;urlshortener#url&quot;,
   &quot;id&quot;: &quot;http://goo.gl/NpdS9&quot;,
   &quot;longUrl&quot;: &quot;http://www.eclipse.org/egit/?gclid\u003dCPfd-5L_oqcCFZMK3wodkC6_BA&quot;,
   &quot;status&quot;: &quot;OK&quot;,
   &quot;created&quot;: &quot;2011-02-25T09:28:28.545+00:00&quot;
  },
  {
   &quot;kind&quot;: &quot;urlshortener#url&quot;,
   &quot;id&quot;: &quot;http://goo.gl/RiVJH&quot;,
   &quot;longUrl&quot;: &quot;http://www.flickr.com/photos/ajzele/sets/72157626133406912/detail/&quot;,
   &quot;status&quot;: &quot;OK&quot;,
   &quot;created&quot;: &quot;2011-02-25T08:46:47.203+00:00&quot;
  },

*/
</pre>
<p>That’s it. Examples above cover the most of what you can do with the Google URL Shortener API at the moment. Hope you find the article useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zendframework-example-on-using-google-url-shortener-service/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zend framework coding style standard</title>
		<link>http://inchoo.net/tools-frameworks/zend/zend-framework-coding-style-standard/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/zend-framework-coding-style-standard/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 12:22:00 +0000</pubDate>
		<dc:creator>Mladen Lotar</dc:creator>
				<category><![CDATA[Zend]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[standard]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=7239</guid>
		<description><![CDATA[Hello again! Today I&#8217;ll discuss some of the basic coding rules if your&#8217;re using Zend framework (or even Magento, which is written over Zend framework). Some might think that this is an redundant topic, but I strongly disagree &#8211; if &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/zend-framework-coding-style-standard/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>Hello again! Today I&#8217;ll discuss some of the basic coding rules if your&#8217;re using Zend framework (or even Magento, which is written over Zend framework). Some might think that this is an redundant topic, but I strongly disagree &#8211; if you work in a team.<span id="more-7239"></span></p>
<h2>Latin introduction</h2>
<p>Well, the story about style standards is quite like goes pretty much like old Latin saying &#8220;<em>De gustibus non est disputandum</em>&#8221; which means &#8220;There is no disputing about tastes&#8221;. But same things apply to it as well, if you have a big corporate meeting, you won&#8217;t go dressed in diving suit, but in a regular one. If you take an parallel look at the coding styles, its pretty much the same. If you&#8217;re going to work with a team on new Zend project, some things must be applied. Otherwise you&#8217;ll end up in quite a mess.</p>
<h2>The main stuff</h2>
<p>There are couple of things that matter the most, and I&#8217;ll only cover those, according to Zend framework official documentation.</p>
<h3>PHP open / close tags</h3>
<p>Well, regarding Zend framework official documentation, as well as some of my personal experience, there&#8217;s one main rule:</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php
//Always and I do mean always, use full php tags, not the short ones
?&gt;
</pre>
<p>Second rule is (from my experience), although I wrote it in example above, omit the closing tag, and make sure that opening tag is starting from character one of the file. I&#8217;m saying this because it wont break the compiling, nor will it cause any errors / warnings. And by this, you&#8217;re making sure that in your included files (controllers / models) you don&#8217;t have any blank characters which would cause problems with headers most likely.</p>
<p>Of course, if you&#8217;re in phtml file, you must use closing tag as well.</p>
<h3>Working with strings</h3>
<p>When working with string literals, like this one:</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php
$string = 'My string.';
</pre>
<p>Try to make a habit of using single quotes around the string. This one is because when you use double quotes PHP will search for variable replacement inside a string, opposed to single quotes. Obviously, single quotes are faster when working with strings.</p>
<p>If you&#8217;re using much of single quotes as literals (SQL for example), or if you have a variable/s inside it, you should use double quotes, like in following example:</p>
<pre class="brush: php; title: ; notranslate">
//As for single quotes, something like in this simple example:
$sql = &quot;SELECT * FROM table WHERE name='John', date='2010-12-29'&quot;;
//And as far for variables, you can use either of these:
$greeting = &quot;Hello $name, welcome back!&quot;;
$greeting = &quot;Hello {$name}, welcome back!&quot;;
</pre>
<p>Of course, this is one that doesn&#8217;t have to be followed to the letter, but you should make a practice of it.</p>
<p>And another important thing to mention here is concatenation. In PHP it&#8217;s achieved by &#8220;.&#8221; sign. Like this:</p>
<pre class="brush: php; title: ; notranslate">
//This is the right way, with spacing
$string = 'First part' . ',and second one.';
//And this is the wrong way:
$string = 'First part'.',and second one.';
//&gt;
</pre>
<h3>A little bit about Classes</h3>
<p>First, take a look at this (Example 1.):</p>
<pre class="brush: php; title: ; notranslate">
class MyClass{
function method1(){
while(1 &lt; 1000){
for($i=0;$i &lt; 500;$i+=100){
echo&quot;Something&quot;;
}}}
$var1=5;
function method2(){
while(1 &lt; 1000){
for($i=500;$i&gt;0;$i-=100){
echo&quot;$var1&quot;;
}}}}
</pre>
<p>And the, take a look at this (Example 2.):</p>
<pre class="brush: php; title: ; notranslate">
class MyClass
{
    public $var1 = 5;
    function method1()
    {
        while(1 &lt; 1000)
        {
            for($i = 0; $i &lt; 500; $i += 100)
            {
                echo &quot;Something&quot;;
            }
        }
    }

    function method2()
    {
        while(1 &lt; 1000)
        {
            for($i = 500; $i &gt; 0; $i -= 100)
            {
                echo &quot;$var1&quot;;
            }
        }
    }
}
</pre>
<p>Now, you tell me which one is more readable? &#8220;Example 1&#8243; or &#8220;Example 2&#8243;? Joking a side, a couple of rules are applied here, as follows:</p>
<ol>
<li>Don&#8217;t mess with your indents, or the&#8217;ll mess with you</li>
<li>Put out a proper spacing in method parameters, logic conditions, etc. It really improves the readability.</li>
<li>Variables with visibility set declared at the beginning of the class (by default its set to public, but that&#8217;s just PHP&#8217;s compatability, not the right way)</li>
</ol>
<h3>And I must mention documentation as well here</h3>
<p>Well, personally I didn&#8217;t like overkill on documentation, but on the other hand, it became quite a help in Zend framework. So I changed my mind. I&#8217;ll say that you only need 6 things by order to apply to rules, and here they are:</p>
<pre class="brush: php; title: ; notranslate">
/**
* @category   Zend
* @package    Zend_Magic
* @subpackage Wand
*/
</pre>
<h2>Goodbye</h2>
<p>And that&#8217;s pretty much it. If you follow these rules, or rather guidelines, you&#8217;ll be more productive both as an individual, and as a team.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/zend-framework-coding-style-standard/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Memory management in Zend framework</title>
		<link>http://inchoo.net/tools-frameworks/zend/memory-management-in-zend-framework/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/memory-management-in-zend-framework/#comments</comments>
		<pubDate>Mon, 27 Dec 2010 09:51:37 +0000</pubDate>
		<dc:creator>Mladen Lotar</dc:creator>
				<category><![CDATA[Zend]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[memory]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=7117</guid>
		<description><![CDATA[Hello everyone! Recently I&#8217;ve noticed that some developers don&#8217;t pay much attention to memory management in Zend framework. And here I&#8217;m not talking about Zend_Cache, but rather about object sizes. And if you&#8217;re thinking that I&#8217;m writing nonsenses, let me &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/memory-management-in-zend-framework/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>Hello everyone! Recently I&#8217;ve noticed that some developers don&#8217;t pay much attention to memory management in Zend framework. And here I&#8217;m not talking about Zend_Cache, but rather about object sizes. And if you&#8217;re thinking that I&#8217;m writing nonsenses, let me show you how to reduce memory usage by more than 100 times (in my example <img src='http://inchoo.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ).<span id="more-7117"></span></p>
<p>First of all, I&#8217;m going to use PHP&#8217;s built in function <strong>memory_get_usage() </strong>to get difference. Just look at this example, and you&#8217;ll know what I&#8217;m talking about:</p>
<pre class="brush: php; title: ; notranslate">
public static function findById($collectionId,$show_all=false) {
$result = new Application_Model_Collection();
$query_result = $result-&gt;queryById($collectionId);
$var1 = memory_get_usage();
//HERE I TOOK MEMORY USAGE BEFORE POPULATING THE RESULT
$result-&gt;populateFromQuery($query_result);
$var2 = memory_get_usage();
//AND HERE AGAIN AFTER POPULATING
echo ($var2 - $var1);
//ECHO THE DIFFERENCE IN BYTES
echo ' ';
$clean_result = Application_Model_Collection_Object::parseCollection($result);
return $clean_result;
}
</pre>
<p>And another snippet:</p>
<pre class="brush: php; title: ; notranslate">
public static function parseCollection(Application_Model_Collection $obj)
{
$return = new Application_Model_Collection_Object();
$var3 = memory_get_usage();
//AND AGAIN BEFORE CLEANING THE OBJECTS
$i = 0;
foreach($obj-&gt;columns as $column)
{
$return-&gt;columns[$i]-&gt;values = $column-&gt;values;
$return-&gt;columns[$i]-&gt;old_values = $column-&gt;old_values;
$i++;
}
$i = 0;
foreach($obj-&gt;data as $data)
{
$return-&gt;data[$i]-&gt;values = $data-&gt;values;
$return-&gt;data[$i]-&gt;old_values = $data-&gt;old_values;
$i++;
}
$var4 = memory_get_usage();
//AND AFTER
echo $var4 - $var3;
//ECHO THE OUTPUT
return $return;
}
</pre>
<p><em>Note: above examples are cleaned methods from my existing Zend project</em></p>
<p>For my ~60 records in collection I got this as output: <strong>1854968 17644</strong>.</p>
<p>Now, if I&#8217;d divide those two, I&#8217;d get something like this: 1854968 / 17644 = <strong>105.1331</strong>, and that&#8217;s how many times new collection is smaller than the original one. All I did here was that I stripped unnecessary data from objects (like link to the database), and returned that back to the application to work with it. Again, this is only for cca 60 objects in collection, and on this same project, I got collections wit over 1000 records. Simple math would say that application would need around <strong>30 MB</strong> for a collection of that size, compared to less than <strong>0.5 MB</strong> when its optimized.</p>
<p>Anyway, I don&#8217;t want to say that you&#8217;re wrong if you don&#8217;t do this, but rather that you&#8217;ll get a much faster application, for exchange in small effort of optimizing the collections.</p>
<p>That&#8217;s all from me for now, and I hope you learned something today.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/memory-management-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MySQL transactions in Zend framework</title>
		<link>http://inchoo.net/tools-frameworks/mysql-transactions-in-zend-framework/</link>
		<comments>http://inchoo.net/tools-frameworks/mysql-transactions-in-zend-framework/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 12:49:23 +0000</pubDate>
		<dc:creator>Mladen Lotar</dc:creator>
				<category><![CDATA[Tools & Frameworks]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=7070</guid>
		<description><![CDATA[Hi! Today I&#8217;m going to explain a part of Zend framework DB functionality. Transactions in general are quite useful, like temporary tables, but in most of situations unnecessary. Because of that, I&#8217;m going to explain when and how to use &#8230;<p><a href="http://inchoo.net/tools-frameworks/mysql-transactions-in-zend-framework/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>Hi! Today I&#8217;m going to explain a part of Zend framework DB functionality. Transactions in general are quite useful, like temporary tables, but in most of situations unnecessary. Because of that, I&#8217;m going to explain when and how to use them through Zend framework.<span id="more-7070"></span></p>
<h2>What is transaction?</h2>
<p>A simple answer would be &#8211; a number of individual queries that are grouped together.</p>
<p>An example would be something like this:</p>
<pre class="brush: sql; title: ; notranslate">

UPDATE balance SET total = total - 100 WHERE account_id=1;
UPDATE balance SET total = total + 100 WHERE account_id=2;
</pre>
<h2>Why transactions?</h2>
<p>In general web development, transactions are unnecessary. If for some reason post in your CMS isn&#8217;t saved, you&#8217;ll write it again. It is a problem, but only annoying one, not a crucial one. But if you own a web shop, and someone create an order, pay for it, and you &#8211; owner of that store can&#8217;t see it because of database glitch, that would be a problem. Take a look at example above. I only first query in that transaction was executed, total amount of money from account would be decreased by 100, and that money would simply disappear (if we&#8217;re looking at your database). Or if only second was executed, account 2 would have 100 extra in its total sum &#8211; again virtually from nowhere.</p>
<p>This is the place where transactions are necessary. Because transactions either execute all queries assigned to it, or none of them. I hope you see the point. <img src='http://inchoo.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h2>The syntax</h2>
<p>This is a basic example from official MySQL documentation:</p>
<pre class="brush: sql; title: ; notranslate">
START TRANSACTION;
--BEGIN TRANSACTION
SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
UPDATE table2 SET summary=@A WHERE type=1;
--SET SOME QUERIES
COMMIT;
--AND COMMIT THEM
</pre>
<h2>When the Zend framework comes in</h2>
<p>Its pretty much self explained, so here&#8217;s a code snippet with comments:<strong></strong></p>
<pre class="brush: php; title: ; notranslate">
$db = self::db();
//GET DATABASE CONNECTION (DEPENDING ON YOUR SETUP)

$q =  &quot;UPDATE balance SET total = total - 100 WHERE account_id=1;UPDATE balance SET total = total + 100 WHERE account_id=2;&quot;;
//PREPARE QUERY

$db-&gt;beginTransaction();
//BEGIN TRANSACTION ON DATABASE CONNECTION
try
{
$db-&gt;exec($q);
//SET QUERY YOU WISH TO EXECUTE

$query = $db-&gt;commit();
//COMMIT QUERY TO DATABASE
}
catch(Exception $e)
{
$db-&gt;rollBack();
//ROLLBACK IF TRANSACTION FAILS

$error_result = Array();
$message = $e-&gt;getMessage();
$code = $e-&gt;getCode();
$error_result[0] = $message;
$error_result[1] = $code;
//GET ERROR INFORMATION IF SQL FAILS
}
</pre>
<h2>Conclusion</h2>
<p>Now, You&#8217;ve created a transaction in your Zend project. You&#8217;ll get a rollback on your database if any of the queries fails and you won&#8217;t have any &#8220;missing records and values&#8221; in your database. This isn&#8217;t so complicated to create for every crucial query in your application, especially when you know its going to work like a charm!</p>
<p>Feel free to comment, as I might learn something new as well. Bye!</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/mysql-transactions-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to work with SVN and Zend Framework in Eclipse PDT</title>
		<link>http://inchoo.net/tools-frameworks/how-to-work-with-svn-and-zend-framewrok-in-eclipse-pdt/</link>
		<comments>http://inchoo.net/tools-frameworks/how-to-work-with-svn-and-zend-framewrok-in-eclipse-pdt/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 16:08:51 +0000</pubDate>
		<dc:creator>Vedran Subotic</dc:creator>
				<category><![CDATA[Tools & Frameworks]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[pdt]]></category>
		<category><![CDATA[svb]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=6523</guid>
		<description><![CDATA[This post is for all those Eclipse fans. Latest version of Eclipse PDT can be found at: http://www.zend.com/community/pdt If you choose 64 bit version be sure that your jre version is also x64. On you first app launch run update. &#8230;<p><a href="http://inchoo.net/tools-frameworks/how-to-work-with-svn-and-zend-framewrok-in-eclipse-pdt/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>This post is for all those Eclipse fans.<br />
Latest version of Eclipse PDT can be found at:<br />
<a href="http://www.zend.com/community/pdt">http://www.zend.com/community/pdt</a><br />
<span id="more-6523"></span><br />
If you choose 64 bit version be sure that your jre version is also x64.</p>
<p>On you first app launch run update.<br />
So check for updates and update!<br />
Help&gt;Check for Updates</p>
<p><a href="http://inchoo.net/wp-content/uploads/2010/11/1_check_updates.png"><img class="alignleft size-medium wp-image-6530" title="1_check_updates" src="http://inchoo.net/wp-content/uploads/2010/11/1_check_updates-600x522.png" alt="" width="600" height="522" /></a></p>
<p><a href="http://inchoo.net/wp-content/uploads/2010/11/2_update_eclipse.png"><img class="alignleft size-medium wp-image-6533" title="2_update_eclipse" src="http://inchoo.net/wp-content/uploads/2010/11/2_update_eclipse-600x523.png" alt="" width="600" height="523" /></a><br />
Restart editor if needed.</p>
<p>Navigate to Help&gt;Install New Software:</p>
<p><a href="http://inchoo.net/wp-content/uploads/2010/11/3_install_new.png"><img class="alignleft size-medium wp-image-6534" title="3_install_new" src="http://inchoo.net/wp-content/uploads/2010/11/3_install_new-600x524.png" alt="" width="600" height="524" /></a><br />
Find repository for SVN &#8211; http://download.eclipse.org/technology/subversive/0.7/update-site/<br />
If it&#8217;s not in the list, then add it by clicking on &#8220;Add&#8221; button or find it among other repositories on &#8220;Avaliable Software Sites&#8221; link.</p>
<p>Select (check) Subversive SVN Team Provider Plugin (Ioncubation) and finish install process.<br />
Restart editor if needed.</p>
<p><a href="http://inchoo.net/wp-content/uploads/2010/11/subversion_install.png"><img class="alignleft size-medium wp-image-6535" title="subversion_install" src="http://inchoo.net/wp-content/uploads/2010/11/subversion_install-600x433.png" alt="" width="600" height="433" /></a><br />
Then you will need to select SVN Connector:</p>
<p><a href="http://inchoo.net/wp-content/uploads/2010/11/subversion_install_2.png"><img class="alignleft size-medium wp-image-6536" title="subversion_install_2" src="http://inchoo.net/wp-content/uploads/2010/11/subversion_install_2-600x523.png" alt="" width="600" height="523" /></a></p>
<p><a href="http://inchoo.net/wp-content/uploads/2010/11/subversion_install_3.png"><img class="alignleft size-medium wp-image-6537" title="subversion_install_3" src="http://inchoo.net/wp-content/uploads/2010/11/subversion_install_3-600x522.png" alt="" width="600" height="522" /></a><br />
Restart if needed.<br />
Now you are ready to have all your projects in eclipse syncronized with SVN.</p>
<p>If you are working with Zend Framework and wish to have Zend Framework perspective enabled for your projects you can install additional plugin for you eclipse.</p>
<p>Again navigate to Help&gt;Install New Software and add new repository with location:</p>
<p>http://downloads.zend.com/studio-eclipse/updates/8_0</p>
<p><a href="http://inchoo.net/wp-content/uploads/2010/11/zend_ce.png"><img class="alignleft size-medium wp-image-6538" title="zend_ce" src="http://inchoo.net/wp-content/uploads/2010/11/zend_ce-600x648.png" alt="" width="600" height="648" /></a><br />
Check:<br />
&#8220;Zend Studio CE Feature&#8221; (for project perspective) and<br />
&#8220;Zend Debugger Feature&#8221; (fro debugging if you like it)</p>
<p><a href="http://inchoo.net/wp-content/uploads/2010/11/zend_ce2.png"><img class="alignleft size-medium wp-image-6539" title="zend_ce2" src="http://inchoo.net/wp-content/uploads/2010/11/zend_ce2-600x652.png" alt="" width="600" height="652" /></a><br />
Finish install process, restart eclipse if needed.</p>
<p>And</p>
<p><a href="http://inchoo.net/wp-content/uploads/2010/11/zend_framework_perspective_and_project.png"><img class="alignleft size-medium wp-image-6540" title="zend_framework_perspective_and_project" src="http://inchoo.net/wp-content/uploads/2010/11/zend_framework_perspective_and_project-600x644.png" alt="" width="600" height="644" /></a><br />
you are ready for developing your zend framework projects.</p>
<p>Enjoy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/how-to-work-with-svn-and-zend-framewrok-in-eclipse-pdt/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Zend Framework navigation with breadcrumbs</title>
		<link>http://inchoo.net/tools-frameworks/zend/zend-framework-navigation-with-breadcrumbs/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/zend-framework-navigation-with-breadcrumbs/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 19:23:20 +0000</pubDate>
		<dc:creator>Vedran Subotic</dc:creator>
				<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=5984</guid>
		<description><![CDATA[It&#8217;s been a while since I last time played with beauty of Zend Framework. Each time I check new features it seems to me that the things are more simplier than the last time, I might be wrong (I wouldn&#8217;t &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/zend-framework-navigation-with-breadcrumbs/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I last time played with beauty of Zend Framework.</p>
<p>Each time I check new features it seems to me that the things are more simplier than the last time,<br />
I might be wrong (I wouldn&#8217;t bet on that) or  I&#8217;m just getting better <img src='http://inchoo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<span id="more-5984"></span><br />
Let&#8217;s check this piece of cake &#8211; how you can create navigation with breadcrumbs in Zend Framework project.<br />
As many things in Zend Framework you can get same features in different ways,<br />
so the same thing goes with the Zend_Navigation class.</p>
<p>First of all you need to decide which way you will choose:<br />
- navigation with xml setup file or<br />
- from application.ini file</p>
<p>I suggest you to try both ways and then choose the one you like most, I&#8217;ll show you the both ways.</p>
<p>In Boostrap.php class you need to initialize your navigation.<br />
- xml way tells where your <strong>navigation.xml</strong> file is:</p>
<pre class="brush: php; title: ; notranslate">
protected function _initNavigationXml()
{
$this-&gt;bootstrap('layout');
$layout = $this-&gt;getResource('layout');
$view = $layout-&gt;getView();
$config = new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml');

$navigation = new Zend_Navigation($config);
$view-&gt;navigation($navigation);
}
</pre>
<p>- or in &#8220;<em>config</em>&#8221; way from <strong>application.ini</strong> file you simply tell your Bootstrap class which part needs to be processed:</p>
<pre class="brush: php; title: ; notranslate">
protected function _initNavigationConfig()
{
$this-&gt;bootstrap('layout');
$layout = $this-&gt;getResource('layout');
$view = $layout-&gt;getView();

$navigation = new Zend_Navigation($this-&gt;getOption('navigation'));
$view-&gt;navigation($navigation);
}
</pre>
<p>Now you have setup your configuration for navigation, next thing you need to do is in your<br />
<strong>application/layouts/layout.phtml</strong> file call the data you insert into your application.ini or navigation.ini files, you do that with this line of code:</p>
<pre class="brush: php; title: ; notranslate">

&lt; ?php
echo $this-&gt;navigation()-&gt;menu();
?&gt;
</pre>
<p>For desert you can add breadcrumbs into same file like this:</p>
<pre class="brush: php; title: ; notranslate">

&lt; ?php
echo $this-&gt;navigation()-&gt;breadcrumbs()
-&gt;setLinkLast(false)-&gt;setMinDepth(0)-&gt;render();
?&gt;
</pre>
<p>At the end you get something like on picture below:<br />
<a href="http://inchoo.net/wp-content/uploads/2010/09/xml_zend_navigation.png"><img class="aligncenter size-full wp-image-5995" title="xml_zend_navigation" src="http://inchoo.net/wp-content/uploads/2010/09/xml_zend_navigation.png" alt="" width="620" height="285" /></a></p>
<p>Here is full featured project <a href="http://inchoo.net/wp-content/uploads/2010/10/zf.navigation.sample.zip">zf.navigation.sample</a> (without Zend Framework, which you need to copy in library folder) to download.</p>
<p>Enjoy coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/zend-framework-navigation-with-breadcrumbs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with multiple PHP frameworks – The best practice</title>
		<link>http://inchoo.net/tools-frameworks/working-with-multiple-php-frameworks-the-best-practice/</link>
		<comments>http://inchoo.net/tools-frameworks/working-with-multiple-php-frameworks-the-best-practice/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 05:42:46 +0000</pubDate>
		<dc:creator>Mladen Lotar</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Tools & Frameworks]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=5640</guid>
		<description><![CDATA[Hi, first of all, I&#8217;d like to explain the title of this post. I won&#8217;t go into depths of complicated examples, but rather explain the logic of it. PHP first implemented OOP (Object Orientated Programming) the right way in version &#8230;<p><a href="http://inchoo.net/tools-frameworks/working-with-multiple-php-frameworks-the-best-practice/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>Hi, first of all, I&#8217;d like to explain the title of this post. I won&#8217;t go into depths of complicated examples, but rather explain the logic of it.<span id="more-5640"></span></p>
<p>PHP first implemented OOP (<a href="http://en.wikipedia.org/wiki/Object-oriented_programming" target="_blank">Object Orientated Programming</a>) the right way in version 5. OOP is powerful tool in any programming language. But the next logic step was to create <a href="http://en.wikipedia.org/wiki/Software_framework" target="_blank">framework </a>as an &#8220;abstract layer&#8221; that will help developers in both speed and quality of their work. To conclude this brief introduction, I&#8217;ll say that there are <a href="http://www.google.com/search?channel=fs&amp;q=php+framework&amp;ie=utf-8&amp;oe=utf-8" target="_blank">many frameworks</a> written in PHP for PHP. <img src='http://inchoo.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Now to the fun part. For example I&#8217;ll use Magentos framework, that is written over Zend framework. To make stuff just a little bit more complicated. Zend framework is written on top of PHP&#8217;s built in functions.</p>
<p>Now, if you are a Magento developer (like we are <img src='http://inchoo.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  ), you need to work by rules, or there will be problems with your Magento modules, extensions, etc. I promise. The problem is if you, lets say, use Zend framework directly in Magento module, which you can (Magento is its &#8220;extenstion&#8221;, which allows you to call parent methods). Why, you ask me? Well, to answer that, I will ask you a question. What will happen if you upgrade Magento to latest version which excluded some Zend framework functionality from its libraries?</p>
<p>It will collapse your module, and you will have to rewrite it in whole new way. But if you used only Magento functionalities, it will probably work just fine. If not, you can just take Magento functionality in one place, and insert it in latest version, so all your Modules that depend on it, work with &#8220;single strike&#8221;.</p>
<p>To conclude, you (and I) should never go &#8220;one level too deep&#8221; when extending a framework written in framework. Not only you will have less problems with updates / changes in parent framework, but you&#8217;ll need much less time to fix the problems that weren&#8217;t your problem initially.</p>
<p>A small example is in order, I think.</p>
<p>A class &#8220;Mage_Payment_Block_Form&#8221; extends some &#8220;Varien_Object&#8221; classes, but on top of that all, it uses Zend_Form, and its methods, to give you most usable class for our Magento platform. But if you use some of Zend_Form&#8217;s methods directly, like &#8220;setCaptcha&#8221;, and Varien decides to rewrite it in Magento (and exclude it from Zend library), all your modules that use that mehod will no longer be functional.</p>
<p>To make a long story short. Best practice would suggest that we all use only top level framework in our projects. Yes, it takes a bit longer (usually) to develop it, but at the end, it pays of big time. If nothing, when some of your colleagues start fixing their Modules, you will have your satisfaction. <img src='http://inchoo.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I hope this helped someone, and feel free to correct me if I&#8217;m wrong.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/working-with-multiple-php-frameworks-the-best-practice/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Simple Controller Plugin in Zend Framework</title>
		<link>http://inchoo.net/tools-frameworks/zend/simple-controller-plugin-in-zend-framework/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/simple-controller-plugin-in-zend-framework/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 12:45:50 +0000</pubDate>
		<dc:creator>Vedran Subotic</dc:creator>
				<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=3900</guid>
		<description><![CDATA[This tutorial will describe how to create own Controller Plugin. How to set up environment for zend framework controller plugin. How extend the library with own class and finally how to use it. Plugin is nothing else but the class, &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/simple-controller-plugin-in-zend-framework/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>This tutorial will describe how to create own Controller Plugin.<br />
How to set up environment for zend framework controller plugin.<br />
How extend the library with own class and finally how to use it.<br />
<span id="more-3900"></span><br />
Plugin is nothing else but the class, in our case it extends Zend_Controller_Plugin_Abstract.<br />
First of all you need name for your plugin, why?<br />
Because we need to set up enviroment for plugin usage and we start with the name.</p>
<p>I called my plugin “Example_Controller_Plugin_Param”, it means that I have created file (class) called “Param.php”<br />
in “library/ Example/Controller/Plugin/”.<br />
Then in “application/Bootstrap.php” class I created method “_initAutoload” in which we need to register nampspace.</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	protected function _initAutoload()
    {
    	/*
    	 * If you don't register namespace
    	 * You will get error :
    	 * Fatal error: Class 'Example_Controller_Plugin_Param' not found in
    	 * ...\library\Zend\Application\Resource\Frontcontroller.php on line 92
    	 *
    	 */

    	$autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader-&gt;registerNamespace('Example_');
        $autoloader-&gt;suppressNotFoundWarnings(true);

        /*
         * also you will get Exception :
         * No entry is registered for key 'Zend_Request_Example'
         * called in helper ParamHelper.php
         *
         */

    }

}
</pre>
<p>Also in “application/configs/application.ini” file we need to prepare plugin ready for usage with line:<br />
resources.frontController.plugins.param = &#8220;Example_Controller_Plugin_Param&#8221;</p>
<p>When you do this steps, check your application if you got some errors or warnings before you go to coding.<br />
Now when we set up environment, we can start with coding our plugin.</p>
<p>I tried to simplyfie this example so our plugin will only create new custom request parameter,<br />
which will appear when you debug</p>
<pre class="brush: php; title: ; notranslate">Zend_Debug::dump($this-&gt;_request-&gt;getParams()); </pre>
<p>in any Controller class.<br />
And it will start the session, create session namespaces with simple logic which will check if the session params are set or not and it will throw an Exception.</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php
class Example_Controller_Plugin_Param extends Zend_Controller_Plugin_Abstract
{
	protected $_param;

	private $_userID;

	public function routeShutdown(Zend_Controller_Request_Abstract $request)
	{
		/*
		 * we start session here
		 * so we do not need to start it in each action, controller or module
		 */
		Zend_Session::start();

		/*
		 * we create session with namespace 'login'
		 */
    	$namespace = new Zend_Session_Namespace('login'); 

    	/*
    	 *
    	 */
    	$this-&gt;_userID = $namespace-&gt;user; 

			/*
			 * create some simple logic, just to see application behaviour
			 */

    		if (!isset($this-&gt;_userID) or $this-&gt;_request-&gt;getParam(&quot;user&quot;) != null) {
				$this-&gt;_userID = $this-&gt;_request-&gt;getParam(&quot;user&quot;, null);

				if ($this-&gt;_userID == null) {
					throw new Exception(&quot;user id not found&quot;);
				}

				$namespace-&gt;user = $this-&gt;_userID;
			}

		/*
		 * Just for example we also create new custom request parameter
		 *  with name and value, cannot set this in helper
		 *
		 */
		$this-&gt;_param = $this-&gt;_request-&gt;setParam('param', 'custom');

		Zend_Registry::set('Zend_Request_Example', $this-&gt;_param-&gt;param);

	}

}
</pre>
<p><a href="http://inchoo.net/wp-content/uploads/2010/01/plugin_exception.png"><img src="http://inchoo.net/wp-content/uploads/2010/01/plugin_exception.png" alt="" title="plugin_exception" width="620" height="334" class="aligncenter size-full wp-image-3909" /></a><br />
<a href="http://inchoo.net/wp-content/uploads/2010/01/plugin_user.png"><img src="http://inchoo.net/wp-content/uploads/2010/01/plugin_user.png" alt="" title="plugin_user" width="620" height="431" class="aligncenter size-full wp-image-3910" /></a></p>
<p>What is so special here?<br />
Well, in this example you do not need to create session namespaces in any action, controller or module and this is something what spares our development time and lines of code.</p>
<p>Source code link: <a href='http://inchoo.net/wp-content/uploads/2010/01/zf.plugin.example.zip'>zf.plugin.example</a><br />
Test your new plugin and enjoy in coding with Zend Framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/simple-controller-plugin-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend Framework Custom View Helper</title>
		<link>http://inchoo.net/tools-frameworks/zend/zend-framework-custom-view-helper/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/zend-framework-custom-view-helper/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 08:50:20 +0000</pubDate>
		<dc:creator>Vedran Subotic</dc:creator>
				<category><![CDATA[Zend]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=2960</guid>
		<description><![CDATA[Creating custom helper in new Zend Framework edition 1.9 in few easy steps. Let&#8217;s assume that we need to fetch some data from database but we do not need them in all view files. We need to insert this line &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/zend-framework-custom-view-helper/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>Creating custom helper in new Zend Framework edition 1.9 in few easy steps.<br />
Let&#8217;s assume that we need to fetch some data from database<br />
but we do not need them in all view files.<br />
<span id="more-2960"></span></p>
<p>We need to insert this line in <strong>application/config.ini</strong> to register path to helpers:</p>
<p><strong>application/configs/application.ini</strong><br />
resources.view.helperPath = APPLICATION_PATH &#8220;/views/helpers&#8221;</p>
<p>First create model which will give you an array,<br />
in my example it&#8217;s list of states, which you will call in you helper file:</p>
<p><strong>application/models/DbTable/States.php</strong></p>
<pre class="brush: php; title: ; notranslate">
class Model_DbTable_States extends Zend_Db_Table_Abstract
{
    protected $_name = 'state_list';

    public function getStates()
    {

        $row = $this-&gt;fetchAll();
        if (!$row) {
            throw new Exception(&quot;No States&quot;);
        }

        $row = $row-&gt;toArray();

        return $row;
    }
}
</pre>
<p>Class needs to begegins with “Zend_View_Helper_”<br />
That is why it is “view helper”  and it cannot be called in controller or model files,<br />
if you do that you will get error that “method deoesn&#8217;t exists”.</p>
<p><strong>application/view/helpers/State.php</strong></p>
<pre class="brush: php; title: ; notranslate">
class Zend_View_Helper_State
{
	protected $_list;

	public function state()
    {
    	$state = new Model_DbTable_States();
	return $this-&gt;_list-&gt;getStates();

    }
}
</pre>
<p>After that and make a list of states in:</p>
<p><strong>application/layouts/sidebar.phtml</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;ul&gt;
	&lt; ?php foreach ($this-&gt;state() as $item):?&gt;

		&lt;li&gt;&lt; ?php echo $item['state']?&gt;&lt;/li&gt;

	&lt; ?php endforeach;?&gt;
&lt;/ul&gt;
</pre>
<p>and call  it in main layout file:</p>
<p><strong>application/layouts/layout.phtml</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php
echo $this-&gt;partial('sidebar.phtml');
?&gt;
</pre>
<p>In this case you will get content from your helper file in all views which will render main layout file from <strong>application/layouts/layout.phtml</strong>.<br />
However, if you wish to call your helper in particular view all you need to do is to call the helper in view file:</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php
$this-&gt;state();
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/zend-framework-custom-view-helper/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Sending emails via Zend_Mail using Google email account</title>
		<link>http://inchoo.net/tools-frameworks/zend/sending-emails-via-zend_mail-using-google-email-account/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/sending-emails-via-zend_mail-using-google-email-account/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 02:49:59 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Zend]]></category>
		<category><![CDATA[eMail]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=10214</guid>
		<description><![CDATA[Here is a little (working) code example of how easy it is to send emails via Zend_Mail class using your existing Google email account.]]></description>
			<content:encoded><![CDATA[<p>Here is a little (working) code example of how easy it is to send emails via Zend_Mail class using your existing Google email account.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php 

$emailSmtpConf = array(
	'auth' =&gt; 'login',
	'ssl' =&gt; 'tls',
    'username' =&gt; 'email2@domain.com',
    'password' =&gt; 'mypasshere'
);

$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $emailSmtpConf);

$mail = new Zend_Mail();
$mail-&gt;addTo('email1@domain.com', 'Name 1');
$mail-&gt;setFrom('email2@domain.com', 'Name 2');
$mail-&gt;setSubject('Demo Email');
$mail-&gt;setBodyText('Email content here');
$mail-&gt;send($transport);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/sending-emails-via-zend_mail-using-google-email-account/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend framework notification system</title>
		<link>http://inchoo.net/tools-frameworks/zend/zend-framework-notification-system/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/zend-framework-notification-system/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 13:03:00 +0000</pubDate>
		<dc:creator>Vedran Subotic</dc:creator>
				<category><![CDATA[Zend]]></category>
		<category><![CDATA[notification]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=2552</guid>
		<description><![CDATA[I was playing around with admin interface for one custom project and I wanted general notification system for updating, adding, deleting records in database or any other action I could imagine. Zend framework has built in notification system where you &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/zend-framework-notification-system/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>I was playing around with admin interface for one custom project and I wanted general notification system for updating, adding, deleting records in database or any other action I could imagine. Zend framework has built in notification system where you can easily call the following helper (it&#8217;s an controller action helper). I hope this code will help somebody.</p>
<p><span id="more-2552"></span></p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;_helper-&gt;flashMessenger();
</pre>
<p>First you need to register your view variable in init() method if you want to have notifications in all view files of your controller.</p>
<pre class="brush: php; title: ; notranslate">
public function init()
{

/* Initialize action controller here*/
$this-&gt;view-&gt;messages = $this-&gt;_helper-&gt;flashMessenger-&gt;getMessages();

}
</pre>
<p>Then you simply add messages in your action methods like this:</p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;_helper-&gt;flashMessenger-&gt;addMessage(array(&quot;ok_message&quot; =&gt; 'record deleted'));
or
$this-&gt;_helper-&gt;flashMessenger-&gt;addMessage(array(&quot;err_message&quot; =&gt; 'unable to comply'));
</pre>
<p>Why wasting you code when you got all in one place, right?</p>
<p>Once you register the message notification all you need is to choose where message should appear.That&#8217;s the easy part, just need to style your div ids and classes in view files.</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php if(isset($this-&gt;messages)):?&gt;
&lt;div class=&quot;grid_12&quot;&gt;
&lt; ?php foreach($this-&gt;messages as $message):?&gt;
&lt;div id=&quot;site_info&quot;&gt;
&lt;div class=&quot;box&quot;&gt;
&lt; ?php if(isset($message[&quot;error&quot;])):?&gt;
&lt;p&gt;&lt; ?php echo $message[&quot;error&quot;]?&gt;&lt;/p&gt;
&lt; ?php elseif(isset($message[&quot;ok&quot;])):?&gt;
&lt;p&gt;&lt; ?php echo $message[&quot;ok&quot;]?&gt;&lt;/p&gt;
&lt; ?php endif?&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt; ?php endforeach?&gt;
&lt;/div&gt;
&lt; ?php endif?&gt;
</pre>
<p>One trick, if you want to show them on all view pages, edit your layout file and paste the code above at header,footer or wherever you want them to be shown<br />
(there is no need to put them in you view files, unless you want to show same notifications twice <img src='http://inchoo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<p>The easiest way to have notifications in other modules is to register it like session variable  and unset them manually.</p>
<p>Check class Zend_Controller_Action_Helper_FlashMessenger for additional purposes.<br />
Enjoy coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/zend-framework-notification-system/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Drupal Zend Framework autoloader module, ActiveCodeline_ZendFrameworkLoader</title>
		<link>http://inchoo.net/tools-frameworks/zend/drupal-zend-framework-autoloader-module-activecodeline_zendframeworkloader/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/drupal-zend-framework-autoloader-module-activecodeline_zendframeworkloader/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 00:54:14 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=10225</guid>
		<description><![CDATA[For all those poking around Drupal and Zend Framework, I wrote a little module that auto-loads Zend Framework. This module works with new Zend_Loader_Autoloader introduced in version 1.8. Therefore this Drupal module requires new 1.8 or higher version of Zend &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/drupal-zend-framework-autoloader-module-activecodeline_zendframeworkloader/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>For all those poking around Drupal and Zend Framework, I wrote a little module that auto-loads Zend Framework. This module works with new Zend_Loader_Autoloader introduced in version 1.8. Therefore this Drupal module requires new 1.8 or higher version of Zend Framework library. <span id="more-10225"></span></p>
<p>Module is really simple, not much to it. Note that Zend Framework library it self is not packed with module, you need to download is separately and copy paste to modules /library folder.</p>
<p>It has only two files, one .info file needed for Drupal to recognize it and one .module file whose content you can see below.</p>
<pre class="brush: php; title: ; notranslate">
function ZendFrameworkLoader_boot()
{
	//Get current file path, cut off the file name and use the rest as folder path
	$siteBasePath = str_replace('ZendFrameworkLoader.module', '', __FILE__);

	//Append subfolder named 'library' to the path
	$siteLibraryPath = $siteBasePath.'library';

	//Add script wide include paths
	set_include_path('.'	. PATH_SEPARATOR . $siteLibraryPath
							. PATH_SEPARATOR . $siteLibraryPath.'/Zend'
							. PATH_SEPARATOR . get_include_path());

	include_once $siteLibraryPath.'/Zend/Loader/Autoloader.php';
	Zend_Loader_Autoloader::getInstance();
}
</pre>
<p>As you can see module is using hook_boot() to handle (inject) auto-loading code. Therefore try not to call any of the Zend library components in hook_boot functions, latter is good.</p>
<p>Installing a module is done by simply copy-pasting unarchived module to /sites/all/modules/ folder. By doing so you should have /sites/all/modules/ActiveCodeline folder in place if you copy-pasted it ok.</p>
<p>Download <a href='http://activecodeline.net/wp-content/uploads/2009/06/activecodeline_zendframeworkloader.zip'>ActiveCodeline_ZendFrameworkLoader</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/drupal-zend-framework-autoloader-module-activecodeline_zendframeworkloader/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using partial helpers in Zend Framework</title>
		<link>http://inchoo.net/tools-frameworks/zend/using-partial-helpers-in-zend-framework/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/using-partial-helpers-in-zend-framework/#comments</comments>
		<pubDate>Mon, 25 May 2009 14:19:03 +0000</pubDate>
		<dc:creator>Vedran Subotic</dc:creator>
				<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=1972</guid>
		<description><![CDATA[ZendFrameworkQuickstart application is demo guestbook with Zend library files included, basic folder structure and some sample data for fetching and entering new. It is already configured for usage and always updated with the latest release of Zend Framework. The quickest &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/using-partial-helpers-in-zend-framework/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://framework.zend.com/docs/quickstart">ZendFrameworkQuickstart application</a> is demo guestbook with Zend  library files included,<br />
basic folder structure and some sample data for fetching and entering new.<br />
It is already configured for usage and always updated with the latest release of Zend Framework.<br />
<span id="more-1972"></span><br />
The quickest way to setup Zend FrameworkQuickstart app for you is next 2 steps:<br />
1.you need to download  <a href="http://framework.zend.com/demos/ZendFrameworkQuickstart-20090430.zip">ZendFrameworkQuickstart application files</a><br />
2.and setup virtual host pointing to public folder  (e.g. /var/www/zend.quickstart/public/)</p>
<p>I used <a href="http://framework.zend.com/docs/quickstart">ZendFrameworkQuickstart application</a>  for you so you can easier test the code I provided.<br />
You just need to download  and setup latest <a href="http://framework.zend.com/demos/ZendFrameworkQuickstart-20090430.zip">ZendFrameworkQuickstart</a> and replace default files  with files I posted.<br />
Here is the post:</p>
<p>In layout file (our case &#8220;layout.phtml&#8221; in application/layouts/scripts/)<br />
we just need to call helper $this->partial and correct path to partial file</p>
<pre class="brush: php; title: ; notranslate">
&lt;div id=&quot;categories&quot;&gt;
    &lt; ?php echo $this-&gt;partial('partials/categories.phtml',
				            array('categories' =&gt; $this-&gt;data)); ?&gt;
&lt;/div&gt;
</pre>
<p>with correct &#8220;keys&#8221; and &#8220;values&#8221; (our case &#8216;categories&#8217; and $this->data).<br />
Key (&#8216;categories&#8217;) will stand for entity which is iterrated in our partial file in foreach loop<br />
(our case &#8220;categories.phtml&#8221; in application/layouts/scripts/partials)</p>
<pre class="brush: php; title: ; notranslate">
&lt;ul&gt;
&lt; ?php foreach($this-&gt;categories as $item) : ?&gt;
	&lt;li class=&quot;item&quot;&gt;
	  &lt;a href=&quot;&lt;?php echo $this-&gt;url(
	  					array(
							&quot;cat&quot;=&gt;$item['key'],
                                                        &quot;action&quot;=&gt;&quot;index&quot;,
	  						&quot;controller&quot;=&gt;&quot;index&quot;,
	  						&quot;module&quot;=&gt;&quot;default&quot;
	  										))?&gt;&quot;&gt;
		&lt; ?php echo $item['value']; ?&gt;&lt;/a&gt;
    	&lt;/li&gt;
&lt; ?php endforeach; ?&gt;
&lt;/ul&gt;
</pre>
<p>and value ($this->data) must be defined in our controller class file as a view helper ($this->view->data),<br />
I defined it in init() method so it will be set for all actions in IndexController.</p>
<pre class="brush: php; title: ; notranslate">
public function init()
	{
		$this-&gt;view-&gt;data =
				array(
					array('key' =&gt; 'key_1', 'value' =&gt; 'category_1'),
					array('key' =&gt; 'key_2', 'value' =&gt; 'category_2'),
					array('key' =&gt; 'key_3', 'value' =&gt; 'category_3'),
					array('key' =&gt; 'key_4', 'value' =&gt; 'category_4'),
				);
	}
</pre>
<p>I added demoAction so you can try to set different data set or you can try to play with the code and create some data set from query result.<br />
Enjoy.</p>
<p>Link to <a href="http://inchoo.net/wp-content/uploads/files/application.rar">code files</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/using-partial-helpers-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Simple TODO application in Zend Framework and Doctrine ORM</title>
		<link>http://inchoo.net/tools-frameworks/zend/simple-todo-application-in-zend-framework-and-doctrine-orm/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/simple-todo-application-in-zend-framework-and-doctrine-orm/#comments</comments>
		<pubDate>Sat, 02 May 2009 08:57:55 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=10261</guid>
		<description><![CDATA[I wrote a little TODO application in Zend Framework (1.8) and Doctrine ORM (1.1). I&#8217;m posting it more as a sample (practice) app for Zend and Doctrine newcomers. Entire process of adding, deleting and editing TODO&#8217;s is AJAX based. I &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/simple-todo-application-in-zend-framework-and-doctrine-orm/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>I wrote a little TODO application in Zend Framework (1.8) and Doctrine ORM (1.1). I&#8217;m posting it more as a sample (practice) app for Zend and Doctrine newcomers. Entire process of adding, deleting and editing TODO&#8217;s is AJAX based. I used jQuery and Jeditable plugin for it. jQuery and Jeditable plugins are provided in this zip-ed archive. You should download Zend Framework and Doctrine ORM yourself, and place them in appropriate directory. Set the PHP include path to point to that directory.<span id="more-10261"></span></p>
<p>Important thing to keep in mind. Few days ago, Zend Framework 1.8 came out. It uses different auto loading approach. I did not had time to study it in detail so some things in /public/index.php file might look out of order. The parts where I auto-loaded Doctrine and models directory. Don&#8217;t worry, it&#8217;s working either way <img src='http://inchoo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  What you SHOULD do is CHANGE THE INCLUDE PATH line 28 of the index.php file to reflect your machine path to library folder.</p>
<p>Here are some screenshot of my final application:</p>
<p><a href="http://activecodeline.net/wp-content/uploads/2009/05/toody_example_todo_app_screenshot.jpg"><img src="http://activecodeline.net/wp-content/uploads/2009/05/toody_example_todo_app_screenshot-300x183.jpg" alt="toody_example_todo_app_screenshot" title="toody_example_todo_app_screenshot" width="300" height="183" class="alignnone size-medium wp-image-671" /></a></p>
<p><a href="http://activecodeline.net/wp-content/uploads/2009/05/toody_inline_edit.png"><img src="http://activecodeline.net/wp-content/uploads/2009/05/toody_inline_edit-300x178.png" alt="toody_inline_edit" title="toody_inline_edit" width="300" height="178" class="alignnone size-medium wp-image-672" /></a></p>
<p><a href="http://activecodeline.net/wp-content/uploads/2009/05/toody_inline_edit2.png"><img src="http://activecodeline.net/wp-content/uploads/2009/05/toody_inline_edit2-300x186.png" alt="toody_inline_edit2" title="toody_inline_edit2" width="300" height="186" class="alignnone size-medium wp-image-673" /></a></p>
<p>Here is the screenshot of my library folder</p>
<p><a href="http://activecodeline.net/wp-content/uploads/2009/05/my_library_path.png"><img src="http://activecodeline.net/wp-content/uploads/2009/05/my_library_path-300x206.png" alt="my_library_path" title="my_library_path" width="300" height="206" class="alignnone size-medium wp-image-676" /></a></p>
<p><a href='http://inchoo.net/wp-content/uploads/2009/05/toody_all.zip'>DOWNLOAD toody</a> (need to download Zend Framework and Doctrine ORM separatly).</p>
<p>Took me around 3 and a half hour to write the app, take the screenshots and write this post. Therefore, use it only in education purpose, cause there is much more to be done to use it for real.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/simple-todo-application-in-zend-framework-and-doctrine-orm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Doctrine ORM and Zend Framework, sample project to get you started (with sample database)</title>
		<link>http://inchoo.net/tools-frameworks/zend/doctrine-orm-and-zend-framework-sample-project-to-get-you-started/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/doctrine-orm-and-zend-framework-sample-project-to-get-you-started/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 09:34:25 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Zend]]></category>
		<category><![CDATA[Doctrine ORM]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=1476</guid>
		<description><![CDATA[I&#8217;ve created a sample project for those of you interested in working with Doctrine ORM and Zend Framework (my favorite toys in last few weeks). All you need to get it up n running is a download of Doctrine ORM &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/doctrine-orm-and-zend-framework-sample-project-to-get-you-started/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve created a sample project for those of you interested in working with Doctrine ORM and Zend Framework (my favorite toys in last few weeks). All you need to get it up n running is a download of <a href="http://www.doctrine-project.org/download">Doctrine ORM</a> and <a href="http://framework.zend.com/download">Zend Framework</a>.<span id="more-1476"></span></p>
<p>Project is set for auto loading both Zend and Doctrine Frameworks so all you need to do is to instantiate <img src='http://inchoo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  -Also, below you can see few screenshots of the sample code I implemented. Also, I provide you with the .sql dump (doctrinesql) file that goes with this project. Note the use of InnoDB engine in database. Since Doctrine comes with this cool hasOne, hasMany relation mappings, you can use bunch of cool stuff to easily do various actions on database once you get familiar with Doctrine. Although MyISAM engine is somewhat faster than InnoDB, without second thoughts I choose InnoDB due to foreign keys features.</p>
<p><a href="http://inchoo.net/wp-content/uploads/2009/04/example_user_entry.png"><img class="alignnone size-medium wp-image-1479" title="example_user_entry" src="http://inchoo.net/wp-content/uploads/2009/04/example_user_entry-637x457.png" alt="example_user_entry" width="637" height="457" /></a></p>
<p><a href="http://inchoo.net/wp-content/uploads/2009/04/bootstrap_setup.png"><img class="alignnone size-medium wp-image-1480" title="bootstrap_setup" src="http://inchoo.net/wp-content/uploads/2009/04/bootstrap_setup-637x338.png" alt="bootstrap_setup" width="637" height="338" /></a></p>
<p><a href="http://inchoo.net/wp-content/uploads/2009/04/user_class_autogenerated.png"><img class="alignnone size-medium wp-image-1481" title="user_class_autogenerated" src="http://inchoo.net/wp-content/uploads/2009/04/user_class_autogenerated-637x190.png" alt="user_class_autogenerated" width="637" height="190" /></a></p>
<p><a href="http://inchoo.net/wp-content/uploads/2009/04/article_class_autogenerated.png"><img class="alignnone size-medium wp-image-1482" title="article_class_autogenerated" src="http://inchoo.net/wp-content/uploads/2009/04/article_class_autogenerated-637x190.png" alt="article_class_autogenerated" width="637" height="190" /></a></p>
<p><a href="http://inchoo.net/wp-content/uploads/2009/04/create_new_user.png"><img class="alignnone size-full wp-image-1483" title="create_new_user" src="http://inchoo.net/wp-content/uploads/2009/04/create_new_user.png" alt="create_new_user" width="518" height="265" /></a></p>
<p><a href="http://inchoo.net/wp-content/uploads/2009/04/add_new_user_and_new_article.png"><img class="alignnone size-full wp-image-1484" title="add_new_user_and_new_article" src="http://inchoo.net/wp-content/uploads/2009/04/add_new_user_and_new_article.png" alt="add_new_user_and_new_article" width="595" height="333" /></a></p>
<p><a href="http://inchoo.net/wp-content/uploads/2009/04/add_article_for_existing_user.png"><img class="alignnone size-full wp-image-1485" title="add_article_for_existing_user" src="http://inchoo.net/wp-content/uploads/2009/04/add_article_for_existing_user.png" alt="add_article_for_existing_user" width="566" height="118" /></a></p>
<p>Download project files:<br />
<a href="http://inchoo.net/wp-content/uploads/2009/04/doctrinesql.zip">doctrinesql</a><br />
<a href="http://inchoo.net/wp-content/uploads/2009/04/doctrine_example_project.zip">doctrine_example_project (doctrine orm and zend framework)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/doctrine-orm-and-zend-framework-sample-project-to-get-you-started/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Latest News in Magento</title>
		<link>http://inchoo.net/ecommerce/magento/latest-news-rss-box-block/</link>
		<comments>http://inchoo.net/ecommerce/magento/latest-news-rss-box-block/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 18:40:55 +0000</pubDate>
		<dc:creator>Tomislav Bilic</dc:creator>
				<category><![CDATA[Frontend]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=1367</guid>
		<description><![CDATA[You would like to have a eCommerce power of Magento, but also have a blog to empower your business? In this case, you probably know that Magento doesn&#8217;t have some article manager in the box. Many clients seek for supplementary &#8230;<p><a href="http://inchoo.net/ecommerce/magento/latest-news-rss-box-block/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>You would like to have a eCommerce power of Magento, but also have a blog to empower your business? In this case, you probably know that Magento doesn&#8217;t have some article manager in the box. Many clients seek for supplementary solution like <a title="Wordpress as CMS" href="http://inchoo.net/category/wordpress/" target="_self">WordPress</a> to accomplish this goal. Ok, so you created a blog on same or different domain and you would like those articles to appear somewhere in Magento (probably sidebar). This article will explain how to do it.</p>
<p><span id="more-1367"></span><strong>Step 1</strong></p>
<p>Let&#8217;s create a file called <strong>latest_news.phtml</strong> in app/design/frontend/default/[your_theme]/template/callouts/latest_news.phtml<br />
Now we will create a PHP block that will display the list of articles from RSS feed. We will use <a href="http://feeds.feedburner.com/Inchoo">Inchoo RSS</a> for demonstration purposes. In your scenario, replace it with your own valid RSS URL.</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php $channel = new Zend_Feed_Rss('http://feeds.feedburner.com/Inchoo'); ?&gt;

&lt;div class=&quot;block block-latest-news&quot;&gt;
&lt;div class=&quot;block-title&quot;&gt;
&lt;h2&gt;&lt; ?php echo $this-&gt;__('Latest News') ?&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&quot;block-content&quot;&gt;
&lt;ol id=&quot;graybox-latest-news&quot;&gt;
&lt; ?php foreach ($channel as $item): ?&gt;
&lt;li&gt;&lt;a href=&quot;&lt;?php echo $item-&gt;link; ?&gt;&quot;&gt;&lt; ?php echo $item-&gt;title; ?&gt;&lt;/a&gt;&lt;/li&gt;
&lt; ?php endforeach; ?&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
</pre>
<p><strong>Step 2</strong><br />
Now, we should decide where to place it. I assume you already know how Magento blocks and references work. Let&#8217;s assume you would like to place it in right column by default for whole catalog. In this case open your app/design/frontend/default/[your_theme]/layout/catalog.xml file and under <strong>&#8220;default&#8221;</strong> tag update &#8220;right&#8221; reference with something similar.</p>
<pre class="brush: php; title: ; notranslate">
&lt;reference name=&quot;right&quot;&gt;
&lt;block type=&quot;core/template&quot; name=&quot;top.search&quot; as=&quot;topSearch&quot; template=&quot;catalogsearch/form.mini.phtml&quot;/&gt;
&lt;block type=&quot;core/template&quot; name=&quot;right.permanent.callout&quot; template=&quot;callouts/right_col.phtml&quot;/&gt;
&lt;block type=&quot;core/template&quot; name=&quot;right.latest.news&quot; template=&quot;callouts/latest_news.phtml&quot;/&gt;
&lt;/reference&gt;
</pre>
<p>That&#8217;s it. You should be able to see the list of articles from RSS feed with the URLs. Hope this will help someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/ecommerce/magento/latest-news-rss-box-block/feed/</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>Zend_Auth Database Table Authentification</title>
		<link>http://inchoo.net/tools-frameworks/zend/zend_auth-database-table-authentification/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/zend_auth-database-table-authentification/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 18:37:58 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=1122</guid>
		<description><![CDATA[Zend Framework comes with interesting and useful components when it comes to authentication and authorization of users. Zend_Auth is one such component whose task is to handle authentication. I made a little screencast on topic of Zend_Auth database table authentication. &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/zend_auth-database-table-authentification/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>Zend Framework comes with interesting and useful components when it comes to authentication and authorization of users. Zend_Auth is one such component whose task is to handle authentication.</p>
<p>I made a little screencast on topic of Zend_Auth database table authentication. Screencast is video only, plus some visual pointers, no audio. Hope some of you find it useful as starting point. <span id="more-1122"></span></p>
<p>I had to slice video onto two parts since YouTube as limit on 10 minute per video.</p>
<p><strong>Zend_Auth Database Table Authentication part 1</strong></p>
<p><object width="425" height="344" data="http://www.youtube.com/v/Mx3lNZb20r4&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/Mx3lNZb20r4&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /></object></p>
<p><strong>Zend_Auth Database Table Authentication part 2</strong></p>
<p><object width="425" height="344" data="http://www.youtube.com/v/jZyJH72Cs10&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/jZyJH72Cs10&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /></object></p>
<p><strong>Note</strong>: <em>Please consult the official <a href="http://framework.zend.com/manual/">Zend Framework API documentation</a> for detailed overview of Zend_Auth and all other componets.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/zend_auth-database-table-authentification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Core &#8211; PHP LAMP/WAMP stack overview</title>
		<link>http://inchoo.net/tools-frameworks/zend/zend-core-php-lamp-wamp-stack-overview/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/zend-core-php-lamp-wamp-stack-overview/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 16:27:04 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=1056</guid>
		<description><![CDATA[For all those in open source web application development, like myself, LAMP/WAMP is well known term, especially if your development is based on PHP. Imagine WAMP with commercial support available and you what to you get? You get Zend Core. &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/zend-core-php-lamp-wamp-stack-overview/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>For all those in open source web application development, like myself, LAMP/WAMP is well known term, especially if your development is based on PHP. Imagine WAMP with commercial support available and you what to you get? You get Zend Core. I don&#8217;t mean to be harsh neither to WAMP or Zend Core with statements like these. I&#8217;m simply trying to explain as short as possible, to those interested in Zend Core what it actually is. <span id="more-1056"></span></p>
<p>It is a simplified installation of the full PHP application stack, including web server, databases, extensions and Zend Framework. This last is really interesting if you prefer Zend Framework for development.</p>
<p>Zend Core comes with 3 subscription models (levels): Silver, Gold and Platinum. With prices ranging from $250 &#8211; $750 per dual processor-core. Subscriptions provide support for bug fixes, security patches and maintenance releases for automatic and manual downloading &amp; deployment via the Zend Network. All of this trough Web-based support &amp; phone support.</p>
<p>Below are the screen shots of entire installation process and application overview. I screen shotted entire administration interface, so if you are considering going Zend Core you might find it useful.</p>
<p><img class="alignnone size-medium wp-image-1057" title="Welcome to the ZEND Core 2.5 Installation" src="http://inchoo.net/wp-content/uploads/2009/03/1_instalation-637x514.jpg" alt="Welcome to the ZEND Core 2.5 Installation" width="637" height="514" /></p>
<p><img class="alignnone size-medium wp-image-1058" title="License Agreement" src="http://inchoo.net/wp-content/uploads/2009/03/2_instalation-637x514.jpg" alt="License Agreement" width="637" height="514" /></p>
<p><img class="alignnone size-medium wp-image-1059" title="ZEND core complete or custom setup" src="http://inchoo.net/wp-content/uploads/2009/03/3_instalation-637x514.jpg" alt="ZEND core complete or custom setup" width="637" height="514" /></p>
<p><img class="alignnone size-medium wp-image-1060" title="Installation Destination Location" src="http://inchoo.net/wp-content/uploads/2009/03/4_instalation-637x514.jpg" alt="Installation Destination Location" width="637" height="514" /><br />
<img class="alignnone size-medium wp-image-1061" title="ZEND Apache Install" src="http://inchoo.net/wp-content/uploads/2009/03/5_instalation-637x514.jpg" alt="ZEND Apache Install" width="637" height="514" /></p>
<p><img class="alignnone size-medium wp-image-1062" title="Apache Port Number" src="http://inchoo.net/wp-content/uploads/2009/03/6_instalation-637x514.jpg" alt="Apache Port Number" width="637" height="514" /></p>
<p><img class="alignnone size-medium wp-image-1063" title="zend extension association" src="http://inchoo.net/wp-content/uploads/2009/03/7_instalation-637x514.jpg" alt="zend extension association" width="637" height="514" /><br />
<img class="alignnone size-medium wp-image-1064" title="zend gui administration password" src="http://inchoo.net/wp-content/uploads/2009/03/8_instalation-637x514.jpg" alt="zend gui administration password" width="637" height="514" /></p>
<p><img class="alignnone size-medium wp-image-1065" title="ZEND Network" src="http://inchoo.net/wp-content/uploads/2009/03/9_instalation-637x514.jpg" alt="ZEND Network" width="637" height="514" /></p>
<p><img class="alignnone size-medium wp-image-1066" title="proxy configuration" src="http://inchoo.net/wp-content/uploads/2009/03/10_instalation-637x514.jpg" alt="proxy configuration" width="637" height="514" /></p>
<p><img class="alignnone size-medium wp-image-1067" title="Install ZEND core" src="http://inchoo.net/wp-content/uploads/2009/03/11_instalation-637x514.jpg" alt="Install ZEND core" width="637" height="514" /></p>
<p><img class="alignnone size-medium wp-image-1068" title="Installation progress" src="http://inchoo.net/wp-content/uploads/2009/03/12_instalation-637x514.jpg" alt="Installation progress" width="637" height="514" /></p>
<p><img class="alignnone size-full wp-image-1069" title="Downloading ZEND framework" src="http://inchoo.net/wp-content/uploads/2009/03/13_instalation.jpg" alt="Downloading ZEND framework" width="539" height="437" /></p>
<p><img class="alignnone size-full wp-image-1070" title="ZEND core has downloaded a compressed file" src="http://inchoo.net/wp-content/uploads/2009/03/14_instalation.jpg" alt="ZEND core has downloaded a compressed file" width="471" height="212" /></p>
<p><img class="alignnone size-full wp-image-1071" title="Location of ZEND Core's administration GUI" src="http://inchoo.net/wp-content/uploads/2009/03/15_instalation.jpg" alt="Location of ZEND Core's administration GUI" width="447" height="212" /></p>
<p><img class="alignnone size-medium wp-image-1072" title="zend core v2.5 installed" src="http://inchoo.net/wp-content/uploads/2009/03/16_instalation-637x514.jpg" alt="zend core v2.5 installed" width="637" height="514" /></p>
<p><img class="alignnone size-medium wp-image-1073" title="zend core admin login" src="http://inchoo.net/wp-content/uploads/2009/03/17_core-637x477.jpg" alt="zend core admin login" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1074" title="zend core system overview" src="http://inchoo.net/wp-content/uploads/2009/03/18_core-637x477.jpg" alt="zend core system overview" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1075" title="zend core phpinfo" src="http://inchoo.net/wp-content/uploads/2009/03/19_core-637x477.jpg" alt="zend core phpinfo" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1076" title="benchmark" src="http://inchoo.net/wp-content/uploads/2009/03/20_core-637x477.jpg" alt="benchmark" width="637" height="477" /><br />
<img class="alignnone size-medium wp-image-1077" title="zend core support" src="http://inchoo.net/wp-content/uploads/2009/03/21_core-637x477.jpg" alt="zend core support" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1078" title="zend core update" src="http://inchoo.net/wp-content/uploads/2009/03/22_core-637x477.jpg" alt="zend core update" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1079" title="php configuration" src="http://inchoo.net/wp-content/uploads/2009/03/23_core-637x477.jpg" alt="php configuration" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1080" title="zend core configuration php" src="http://inchoo.net/wp-content/uploads/2009/03/24_core-637x477.jpg" alt="zend core configuration php" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1081" title="zend core extensions" src="http://inchoo.net/wp-content/uploads/2009/03/25_core-637x477.jpg" alt="zend core extensions" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1082" title="zend products configuration" src="http://inchoo.net/wp-content/uploads/2009/03/26_core-637x477.jpg" alt="zend products configuration" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1083" title="zend configuration directives" src="http://inchoo.net/wp-content/uploads/2009/03/27_core-637x477.jpg" alt="zend configuration directives" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1084" title="zend debugger" src="http://inchoo.net/wp-content/uploads/2009/03/28_core-637x477.jpg" alt="zend debugger" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1085" title="zend core php documentation" src="http://inchoo.net/wp-content/uploads/2009/03/29_core-637x477.jpg" alt="zend core php documentation" width="637" height="477" /></p>
<p><img class="alignnone size-medium wp-image-1086" title="search zend core documentation" src="http://inchoo.net/wp-content/uploads/2009/03/30_core-637x477.jpg" alt="search zend core documentation" width="637" height="477" /></p>
<p><img class="alignnone size-full wp-image-1087" title="about zend core" src="http://inchoo.net/wp-content/uploads/2009/03/31_core.jpg" alt="about zend core" width="416" height="465" /></p>
<p><img class="alignnone size-medium wp-image-1088" title="It works!" src="http://inchoo.net/wp-content/uploads/2009/03/32_core-637x477.jpg" alt="It works!" width="637" height="477" /></p>
<p>And that&#8217;s it. Complete screen shot tour of Zend Core.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/zend-core-php-lamp-wamp-stack-overview/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zend authentication component (Zend_Auth), database storage class</title>
		<link>http://inchoo.net/tools-frameworks/zend/zend-authentication-component-zend_auth-database-storage-class/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/zend-authentication-component-zend_auth-database-storage-class/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 19:16:23 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=1045</guid>
		<description><![CDATA[I love Zend Framework. Sometimes it can really be overhead but most of the time it&#8217;s really nice working in well organized, documented framework. One of the components I use relatively often iz Zend_Auth component. Zend Framework documentation is quite &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/zend-authentication-component-zend_auth-database-storage-class/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>I love Zend Framework. Sometimes it can really be overhead but most of the time it&#8217;s really nice working in well organized, documented framework. One of the components I use relatively often iz Zend_Auth component. Zend Framework documentation is quite rich so I wont get into explaining how to use Zend_Auth. There is one thing that bothered me in Zend_Auth, and that&#8217;s persistent storage. Zend_Auth (in the latest version 1.7.6, as of time of this writing) supports only Session state as it&#8217;s storage. What I needed is full database session storage.<br />
<span id="more-1045"></span>Great thing about Zend Framework components is that they come with Interface declaration. So all you need (for the most of the time) in order to replace some part (class) is to write your own class according to provided interface. Below is a working class for saving Zend_Auth state infromation in database.</p>
<p>In order for this to work, you need to call the setStorage method on Zend_Auth prior to calling authenticate method. In my example, I placed following code inside the bootstrap.php file</p>
<pre class="brush: php; title: ; notranslate">
// Setup database connection
$params = array(
'host' =&gt; 'server', // localhost
'dbname' =&gt; 'user',
'username' =&gt; 'root',
'password' =&gt; 'somedbpass',
);

$database = Zend_Db::factory('Mysqli', $params);

// Set new session storage mechanizam
$newStore = new AuthDbStorage($database, 'MyCookie', 'user', 'email', 20);
Zend_Auth::getInstance()-&gt;setStorage($newStore);
</pre>
<p>Notice the definition of AuthDbStorage method. It needs 4 parameters to work (5th is optional). First parameter is database adapter, second is cookie name (you need cookie on client side, this is the only info on client side), third parameter is the name of the Zend_Auth table name (the one you set via setTableName), fourth parameter is Zend_Auth identity column name (the one you set via setIdentityColumn), and fifth optional parameter is time to expire a session (in seconds).</p>
<p>If you look at the write method in the class below, you will see it uses two parameters. By default, whatever you write to Zend_Auth default storage (the Session one) it gets overwritten. Here we have somewhat different situation. Here it set it up to accept optional parameter to write some info to additional database column named &#8220;extra&#8221;.</p>
<p>For writting values to current identity, use expression like</p>
<pre class="brush: php; title: ; notranslate">
if(Zend_Auth::getInstance()-&gt;hasIdentity())
{
Zend_Auth::getInstance()-&gt;getStorage()-&gt;write(
Zend_Auth::getInstance()-&gt;getStorage()-&gt;read(),
array('someKeyName' =&gt; 'Some val', 'someKeyName2' =&gt; 'Some val2')
);
}
</pre>
<p>And here is the full class for Zend_Auth database storage.</p>
<pre class="brush: php; title: ; notranslate">
&lt; ?php

class AuthDbStorage implements Zend_Auth_Storage_Interface
{
private static $_session = 'session';

private static $_requiredFieldUserId = 'uid';
private static $_requiredFieldSessionId = 'sid';
private static $_requiredFieldHostname = 'hostname';
private static $_requiredFieldAccessed = 'accessed';
// Extra field to store some info (use serialize)
private static $_requiredFieldExtra = 'extra';

// Zend_Auth Adapter fields
private static $_authAdapterIdentityColumn;
private static $_authAdapterTableName;
private static $_timeToExpire = 600; //in seconds

private static $_cookieName;

private $_db;

public function __construct(Zend_Db_Adapter_Abstract $adapter, $cookieName, $authAdapterTableName, $authAdapterIdentityColumn, $timeToExpire = null)
{
$this-&gt;_db = $adapter;
self::$_cookieName = $cookieName;
self::$_authAdapterTableName = $authAdapterTableName;
self::$_authAdapterIdentityColumn = $authAdapterIdentityColumn;
self::$_timeToExpire = $timeToExpire;
}

/**
* Returns true if and only if storage is empty
*
* @throws Zend_Auth_Storage_Exception If it is impossible to determine whether storage is empty
* @return boolean
*/
public function isEmpty()
{
$result = $this-&gt;_db-&gt;fetchRow('SELECT * FROM '.self::$_session.' WHERE '.self::$_requiredFieldSessionId.' = ?', array($_COOKIE[self::$_cookieName]));

if(empty($result)) { return true; }
return false;
}

/**
* Returns the contents of storage
*
* Behavior is undefined when storage is empty.
*
* @throws Zend_Auth_Storage_Exception If reading contents from storage is impossible
* @return mixed
*/
public function read()
{
$result = $this-&gt;_db-&gt;fetchRow('SELECT * FROM '.self::$_session.' WHERE '.self::$_requiredFieldSessionId.' = ?', array($_COOKIE[self::$_cookieName]));

if(time() - $result[self::$_requiredFieldAccessed] &gt; self::$_timeToExpire)
{
$this-&gt;clear();
return null;
}
//if (is_null($result)) { throw new Zend_Auth_Storage_Exception(); }
return $result;
}

/**
* Writes $contents to storage
*
* @param mixed $contents
* @throws Zend_Auth_Storage_Exception If writing $contents to storage is impossible
* @return void
*/
public function write($contents, $extraContents = array())
{
if(is_array($contents))
{
$userId = $contents[self::$_requiredFieldUserId];
}

else
{
$userId = $this-&gt;_db-&gt;fetchOne('SELECT * FROM '.self::$_authAdapterTableName.' WHERE '.self::$_authAdapterIdentityColumn.' = ?', array($contents));
}

$fields = array(
self::$_requiredFieldUserId =&gt; $userId,
self::$_requiredFieldSessionId =&gt; $_COOKIE[self::$_cookieName],
self::$_requiredFieldHostname =&gt; $_SERVER['REMOTE_ADDR'],
self::$_requiredFieldAccessed =&gt; time()
);

if(!empty($extraContents))
{
$fields[self::$_requiredFieldExtra] = serialize($extraContents);
}

// Before write, delete all session info
$this-&gt;clear();

// Check to see if session has expired

// Now write new one
$result = $this-&gt;_db-&gt;insert(self::$_session, $fields);

if($result == 0) { throw new Zend_Auth_Storage_Exception(); }

}

/**
* Clears contents from storage
*
* @throws Zend_Auth_Storage_Exception If clearing contents from storage is impossible
* @return void
*/
public function clear()
{
try
{
$this-&gt;_db-&gt;query('DELETE FROM '.self::$_session.' WHERE '.self::$_requiredFieldSessionId.' = ?', array($_COOKIE[self::$_cookieName]));
}
catch (Exception $ex)
{
throw new Zend_Auth_Storage_Exception();
}
}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/zend-authentication-component-zend_auth-database-storage-class/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

