<?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; framework</title>
	<atom:link href="http://inchoo.net/tag/framework/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>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>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>Getting started with REST using Zend Framework</title>
		<link>http://inchoo.net/tools-frameworks/zend/getting-started-with-rest-using-zend-framework/</link>
		<comments>http://inchoo.net/tools-frameworks/zend/getting-started-with-rest-using-zend-framework/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 16:04:24 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Zend]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=644</guid>
		<description><![CDATA[I was playing with SOAP for the last few days. I must say, it looks somewhat complicated in some areas. After some google-ing on SOAP vs REST stuff I decided to write this simple ZendFramework REST how to. Actualy this &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend/getting-started-with-rest-using-zend-framework/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>I was playing with SOAP for the last few days. I must say, it looks somewhat complicated in some areas. After some google-ing on SOAP vs REST stuff I decided to write this simple ZendFramework REST how to. Actualy this is a PHP part of tutorial since I was working on a PHP and C# solution using Mono framework for C# part can be found on my <a href="http://activecodeline.com/consuming-rest-service-in-mono-with-csharp">site</a>. My desire was to create a web service in PHP environment and consume that service in C# environment.Getting started with REST using ZendFramework. Here&#8217;s the PHP REST server part.</p>
<p>Basic example is really, really simple. Aren&#8217;t they always. Seriously, it&#8217;s not my intention to go into outermost details.<span id="more-644"></span></p>
<p>Creating a REST server in ZendFramework can be simple as 3 lines of code. For the sake of simplicity, let&#8217;s suppose we&#8217;ll place all of our code logic in one file, the IndexController.php. The basic building block of each and every Zend Framework application. Code for creating a REST server looks like</p>
<p><strong><em>public function restAction()<br />
{<br />
$server = new Zend_Rest_Server();<br />
$server-&gt;setClass(&#8216;CustomTestClass&#8217;);<br />
$server-&gt;handle();<br />
exit;<br />
}</em></strong></p>
<p>Notice the <strong>CustomTestClass</strong>? This is the name of the class we wish to make availabe trough REST server. For the sake of simplicity, this class is placed in same file as our IndexController class. Below is the sample of class body</p>
<p><strong><em>class CustomTestClass<br />
{<br />
/**<br />
* Write to a file<br />
*<br />
* @param string $string<br />
* @return string Some return message<br />
*/<br />
public function sayHello($name)<br />
{<br />
$message = &#8216;Hello &#8216;.$name;<br />
return $message;<br />
}<br />
}</em></strong></p>
<p>Now all that&#8217;s left is to make a call to our REST server using GET method. Since our REST server code is placed inside restAction function in IndexController, it can be accessed using url like</p>
<p><strong><em>http://localhost/myzendapp/index.php/index/rest</em></strong></p>
<p>And the result should look like</p>
<p><strong><em>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;rest generator=&#8221;zend&#8221; version=&#8221;1.0&#8243;&gt;<br />
&lt;response&gt;<br />
&lt;message&gt;No Method Specified.&lt;/message&gt;<br />
&lt;/response&gt;<br />
&lt;status&gt;failed&lt;/status&gt;<br />
&lt;/rest&gt;</em></strong></p>
<p><a href="http://inchoo.net/wp-content/uploads/2009/01/direct_link_to_rest_with_no_params.jpeg"><img class="alignnone size-thumbnail wp-image-645" title="direct_link_to_rest_with_no_params" src="http://inchoo.net/wp-content/uploads/2009/01/direct_link_to_rest_with_no_params-150x104.jpg" alt="direct_link_to_rest_with_no_params" width="150" height="104" /></a></p>
<p>Although these are error messages, it&#8217;s ok, it means our REST server is working. Now if we were to enter url like</p>
<p><strong><em>http://localhost/myzendapp/index.php/index/rest?method=sayHello</em></strong></p>
<p>we would get response error  message like<br />
<strong><em>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;CustomTestClass generator=&#8221;zend&#8221; version=&#8221;1.0&#8243;&gt;<br />
&lt;sayHello&gt;<br />
&lt;response&gt;<br />
&lt;message&gt;Invalid Method Call to sayHello. Requires 1, 0 given.&lt;/message&gt;<br />
&lt;/response&gt;<br />
&lt;status&gt;failed&lt;/status&gt;<br />
&lt;/sayHello&gt;<br />
&lt;/CustomTestClass&gt;</em></strong></p>
<p><a href="http://inchoo.net/wp-content/uploads/2009/01/direct_link_to_rest_with_method_assigned_but_no_params.jpeg"><img class="alignnone size-thumbnail wp-image-646" title="direct_link_to_rest_with_method_assigned_but_no_params" src="http://inchoo.net/wp-content/uploads/2009/01/direct_link_to_rest_with_method_assigned_but_no_params-150x75.jpg" alt="direct_link_to_rest_with_method_assigned_but_no_params" width="150" height="75" /></a></p>
<p>This too is ok. It simply means we omited the parametars we were supose to pass to function. Remember, our sayHello function has signature like</p>
<p><em>public function sayHello($name)</em></p>
<p>meaning we should pass it a parametar $name. Now if we were to type into our browser url like</p>
<p><strong><em>http://localhost/myzendapp/index.php/index/rest?method=sayHello&amp;name=Branko</em></strong></p>
<p>We would get response like</p>
<p><strong><em>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;CustomTestClass generator=&#8221;zend&#8221; version=&#8221;1.0&#8243;&gt;<br />
&lt;sayHello&gt;<br />
&lt;response&gt;Hello Branko&lt;/response&gt;<br />
&lt;status&gt;success&lt;/status&gt;<br />
&lt;/sayHello&gt;<br />
&lt;/CustomTestClass&gt;</em></strong></p>
<p>As I said, simple example, more like proof of concept. Hope you find it usefull as a entry point to REST-full Zend development.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend/getting-started-with-rest-using-zend-framework/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Review of Zend Studio for Eclipse Professional Edition 6.1</title>
		<link>http://inchoo.net/tools-frameworks/zend-studio-for-eclipse-professional-edition-6-1/</link>
		<comments>http://inchoo.net/tools-frameworks/zend-studio-for-eclipse-professional-edition-6-1/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 11:01:21 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Tools & Frameworks]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[framework]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=544</guid>
		<description><![CDATA[For the last 3 months, all of my Web development has been done in NetBeans 6.5. I got hooked on it ever since the beta version brought PHP support to it. NetBeans has several great advantages and even greater features &#8230;<p><a href="http://inchoo.net/tools-frameworks/zend-studio-for-eclipse-professional-edition-6-1/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>For the last 3 months, all of my Web development has been done in NetBeans 6.5. I got hooked on it ever since the beta version brought PHP support to it. NetBeans has several great advantages and even greater features to shadow out most of the commercial, freeware, or open source IDE solutions.</p>
<p>One of the best things about NetBeans is a excellent support for HTML code and added support for jQuery, Prototype, and general JavaScript. However, one thing I simply hate about NetBeans is its speed. Since most of my development is in Magento and WordPress platforms (and Magento itself comes with more than 7000 files), this can really slow down NetBeans. So I decided to look for another solutions, if any <img src='http://inchoo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Today I decided to download and try out the latest Zend Studio release, Zend Studio for Eclipse Professional Edition.<br />
<span id="more-544"></span><br />
You can download the trial version of Zend Studio for Eclipse from http://www.zend.com/en/products/studio/. Zend Studio is not free, it&#8217;s a commercial platform, and although the price might seem high at first, ask yourself what made you even look for Zend Studio as a development IDE solution—and how much time are you wasting right now?<br />
I make my living with PHP and my everyday job evolves around Magento (which is based on Zend Framework platform). My question is: If buying $999 for Zend Studio can make my life a lot easier and speed up my development by some percent, wouldn&#8217;t it be worth the investment? My answer is: Yes, it would. Time saved means more time for new projects.<br />
Enough blabbering, let&#8217;s checkout some Zend Studio features.</p>
<div>After the installation, you are presented with the following screen:</div>
<div>
<div id="rg13"><a href="http://docs.google.com/File?id=ddk3pgmk_110gc4m6ph6_b"><img src="http://docs.google.com/File?id=ddk3pgmk_110gc4m6ph6_b" alt="" width="383" height="295" /></a></div>
</div>
<div>At this point, most of us would jump to File &gt; New section. However, let&#8217;s pause here and get a detailed overview of what this screen offers. Notice the <strong>Browse the Cheat Sheets</strong> section. If you click on it, you get a window like the one below:</div>
<div>
<div id="zwdk"><a href="http://docs.google.com/File?id=ddk3pgmk_111d73sswdz_b"><img src="http://docs.google.com/File?id=ddk3pgmk_111d73sswdz_b" alt="" width="203" height="351" /></a></div>
<div>Now, if you click on the<strong> Creating a PHPDoc</strong>, you get something like the image below:</div>
<div id="zwdk">
<div id="lym8"><a href="http://docs.google.com/File?id=ddk3pgmk_113cp3hp65x_b"><img src="http://docs.google.com/File?id=ddk3pgmk_113cp3hp65x_b" alt="" width="485" height="341" /></a></div>
<div>This might not seem like much to an experienced developer, but it sure helps.</div>
<div>If you go back to the Welcome page of Zend Studio, you will notice a few more useful things, like <strong>Create a Zend Framework Example Project</strong> and <strong>Watch a demo on Event debugging</strong>. I give them 5 out of 5 for this getting started section.</div>
<div>Then, on the right side of the screen there are few intro-level tutorials on essential development topics like Code Assist, Debugging, Profiler, Refactoring, PHPUnit testing, CVS, and SVN. (Unfortunately, most &#8220;wannabe&#8221; developers skip these topics, even though they are essential to healthy application life cycle.)</div>
<div>Now let&#8217;s create our first project. As you know, one of the most annoying things is the time required to manually configure when setting up Zend Framework project. Some of you might say, &#8220;So what, I only have to do it once and paste it every time after.&#8221; Well, this is exactly the scenario I dislike with PHP-related development, everyone seems to have his or her own solution to reinventing the wheel. I love standards; I adore them. This is why I like solutions like this and why I like frameworks—they make you stick to some standard.</div>
<div>Upon creating our new project via File &gt; New &gt; Zend Framework Project, we get a working Zend app that echoes simple Hello, world! to browser. Actually, we still need to copy/paste Zend Framework library to the /library directory and we are done. This is simply beautiful; I love it.</div>
<div>Below is the example of the bootsrap.php file it generated for us:</div>
<div id="lym8">
<div id="gp_."><a href="http://docs.google.com/File?id=ddk3pgmk_114cddq8h2g_b"><img src="http://docs.google.com/File?id=ddk3pgmk_114cddq8h2g_b" alt="" width="485" height="341" /></a></div>
</div>
</div>
</div>
<div>And below is a screenshot of auto-generated IndexController.php file with <strong>Code Assistant</strong> in action:</div>
<div>
<div id="mxx4"><a href="http://docs.google.com/File?id=ddk3pgmk_115dhffhjck_b"><img src="http://docs.google.com/File?id=ddk3pgmk_115dhffhjck_b" alt="" width="485" height="341" /></a></div>
</div>
<div>I do have some minor criticisms on Code Assistant behavior that I noticed. For example, if you were to write into your controller file something like</div>
<div><em>$this-&gt;view-&gt;assign(&#8220;username&#8221;, &#8220;branko.ajzele&#8221;);</em></div>
<div><em><br />
</em></div>
<div>and now if in your view file you try to write something like</div>
<p><em>$this-&gt;use&#8230; </em></p>
<div>
<div>then you won&#8217;t get auto complete from Code Assistant. It does not seem to recognize this kind of connection.</div>
<div>Another problem with Code Assistant is that it behaves differently in .phtml files and html files when writing html code. It does not work very well in .phtml files in this case. However, despite these problems, Zend Studio is still a powerful and extremely useful developer tool.</div>
<div>One of the first features I looked for in Zend Studio was its ability to manage database connections. There is a nice little icon on the main toolbar called <strong>Create new SQL connection</strong> (Oracle, Postgre, MySQL, MS SQL, Derby, IBM DB2, their variations and addition of new ones).</div>
<div>
<div id="a575"><a href="http://docs.google.com/File?id=ddk3pgmk_116c5cmgzgr_b"><img src="http://docs.google.com/File?id=ddk3pgmk_116c5cmgzgr_b" alt="" width="346" height="326" /></a></div>
</div>
<div>Combined with a nice little feature called Scrapbook, we get simple but effective developer to database relation solutions. It&#8217;s so easy you may never look back at other solutions again!</div>
<div>Below is the screenshot of Zend Studio&#8217;s Database Development Perspective view:</div>
<div>
<div id="vw4."><a href="http://docs.google.com/File?id=ddk3pgmk_11772bpjccj_b"><img src="http://docs.google.com/File?id=ddk3pgmk_11772bpjccj_b" alt="" width="389" height="262" /></a></div>
</div>
</div>
<p>This brings me to the next topic, <strong>Perspective view</strong>. This too might not look as cool or seem necessary, but I love it. In my opinion it&#8217;s a step in right direction towards smart applications. Zend Studio Eclipse uses this concept of Perspective views (the way of rearranging the application interface based on the technology you&#8217;re working on) from PHP to SQL.</p>
<div>Another cool feature not many PHP IDE&#8217;s have is a <strong>PHPDoc generator</strong>. Below is a screenshot of generated documentation on my empty application. I only wrote one empty method inside IndexController.php file and assigned it some description. All you need to do is go to Project &gt; Generate PHPDoc and that&#8217;s it. Your documentation will be built in a matter of seconds.</div>
<div>
<div id="m5j2"><a href="http://docs.google.com/File?id=ddk3pgmk_118chddfrcr_b"><img src="http://docs.google.com/File?id=ddk3pgmk_118chddfrcr_b" alt="" width="605" height="370" /></a></div>
<p><strong>Remote Systems monitor</strong> is another cool and extremely useful feature. Below are two screenshots for you to see it:</div>
<div id="v4qp"><a href="http://docs.google.com/File?id=ddk3pgmk_120gphm8ngb_b"><img src="http://docs.google.com/File?id=ddk3pgmk_120gphm8ngb_b" alt="" width="315" height="340" /></a></div>
<div>
<div id="v4qp">
<div id="ggg."><a href="http://docs.google.com/File?id=ddk3pgmk_121htns4sgk_b"><img src="http://docs.google.com/File?id=ddk3pgmk_121htns4sgk_b" alt="" width="389" height="262" /></a></div>
<div>Everything mentioned so far is just a fraction of what Zend Studio Eclipse is made of and what it can enable you to do.</div>
<div>I recommend you try it out.</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/zend-studio-for-eclipse-professional-edition-6-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>CRU(EL)D: Reinventing the Wheel</title>
		<link>http://inchoo.net/tools-frameworks/crueld-reinventing-the-wheel/</link>
		<comments>http://inchoo.net/tools-frameworks/crueld-reinventing-the-wheel/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 19:56:13 +0000</pubDate>
		<dc:creator>Branko Ajzele</dc:creator>
				<category><![CDATA[Tools & Frameworks]]></category>
		<category><![CDATA[framework]]></category>

		<guid isPermaLink="false">http://inchoo.net/?p=493</guid>
		<description><![CDATA[Every developer knows what CRUD stands for. Its an acronym for (C)reate, (R)ead, (U)pdate, and (D)elete. Dealing with CRUD is one of the most time-consuming tasks in a Web developer&#8217;s day. Combine that with website styling process and you get &#8230;<p><a href="http://inchoo.net/tools-frameworks/crueld-reinventing-the-wheel/">Read more</a><p>]]></description>
			<content:encoded><![CDATA[<p>Every developer knows what CRUD stands for. Its an acronym for (C)reate, (R)ead, (U)pdate, and (D)elete. Dealing with CRUD is one of the most time-consuming tasks in a Web developer&#8217;s day. Combine that with website styling process and you get at least 50-60% of the development time spent on each site, on average (at least that is my experience).<span id="more-493"></span></p>
<p>You can use any number of frameworks or approach a problem from any number of angles, but the CRUD is always there. And every time we use it, it is like we&#8217;re reinventing the wheel. We struggle with all those $_GET and $_POST, if, switch, else&#8230; (and so on) statements over and over again, but it often feels more like a waste of time and resources more than anything.</p>
<p>So, what do we do? When most developers need to write something to database tables, or make a update interface for some table, we write down the custom form for it (including the CRUD). On one hand, it keeps our skills sharp. But on the other hand, it&#8217;s  time we could better spend on focusing and developing additional features, bug-fixing our applications, and so on. But the CRUD is relevant as well.</p>
<p>CRUD is almost always important at the user interface level of most applications. For example, in address book software, the basic storage unit is an individual <em>contact entry</em>. As a bare minimum, the software must allow the user to:</p>
<ul>
<li>(C)reate or add new entries</li>
<li>(R)ead, retrieve, search, or view existing entries</li>
<li>(U)pdate or edit existing entries</li>
<li>(D)elete existing entries</li>
</ul>
<p>Without at least these four operations, the software cannot be considered complete.Because these operations are so fundamental, they are often documented and described under one comprehensive heading, such as &#8220;contact management&#8221; or &#8220;contact maintenance&#8221; (or &#8220;document management&#8221; in general, depending on the basic storage unit for the particular application), but they are really just CRUD.</p>
<p>So how do you deal with it?</p>
<p>PHP has numerous frameworks, meaning numerous philosophies of building a website. Personally, I love frameworks because they establish order in the midst of chaos. And, although some of these frameworks can  help you avoid CRUD, it is worth considering the price you will pay by using these solutions.</p>
<p>Recently I came across <a href="http://www.doctrine-project.org/">Doctrine</a>. Not many developers know about the term ORM. Hard to imagine, but true. So what is ORM? ORM stands for Object Relational Mapping, and it&#8217;s a promising concept that is slowly becoming popular for developers. One of the best features of ORM is that it can help us greatly when we are in need of dealing with many relational tables. However, ORM does not solve issues with CRUD because it uses somewhat complex configurations to solve the same problems.  A solution that truly <em>saves time</em> with CRUD has yet to be developed. So, we return to the same CRUD again and again. There simply does not seem to be a flexible, fast, and easy (two or three lines of code) solution to map and auto-generate all the necessary fields from database to form.</p>
<p>But I&#8217;ll keep looking.</p>
<p>Feel free to post your thoughts, ideas, and solutions on dealing with CRUD problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://inchoo.net/tools-frameworks/crueld-reinventing-the-wheel/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

