<?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>Abhi&#039;s Weblog &#187; Framework</title>
	<atom:link href="http://abhinavsingh.com/blog/tag/framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://abhinavsingh.com/blog</link>
	<description>PHP, Memcached, XMPP and Web Development</description>
	<lastBuildDate>Wed, 06 Apr 2011 22:19:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</title>
		<link>http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/</link>
		<comments>http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 22:41:07 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Open Source Projects]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[JAXL]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=641</guid>
		<description><![CDATA[After months of restructuring the Jaxl library, I am pleased to announce Jaxl 2.0, an object oriented XMPP framework in PHP for developing real time applications for browsers, desktops and hand held devices. What&#8217;s new in Jaxl 2.0? A lot of structural changes has been done from the previous version to make it more scalable, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Freleasing-jaxl-2-0-object-oriented-xmpp-framework-in-php%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Freleasing-jaxl-2-0-object-oriented-xmpp-framework-in-php%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Framework,JAXL,Open+Source,PHP,XMPP&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>After months of restructuring the Jaxl library, I am pleased to announce Jaxl 2.0, an object oriented XMPP framework in PHP for developing real time applications for browsers, desktops and hand held devices.</p>
<p><strong style="font-size:18px;"><u>What&#8217;s new in Jaxl 2.0?</u></strong></p>
<ul>
<li>A lot of structural changes has been done from the previous version to make it more scalable, robust, flexible and easy to use</li>
<li>Library now provides an event mechanism, allowing developers to register callbacks for various xmpp events in their application code</li>
<li>Use integrated BOSH support to write real time web applications in minutes</li>
<li>More than 10 new implemented XMPP extensions (XEP&#8217;s) added</li>
<li>Development hosting moves to <a href="http://github.com/abhinavsingh/JAXL">github</a>, stable releases available at <a href="http://code.google.com/p/jaxl/">google code</a></li>
</ul>
<p><strong style="font-size:18px;"><u>Documentation for Jaxl users</u></strong><br />
Below is a list of getting started documentation for XMPP app developers:</p>
<ul>
<li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-installation-usage-guide-and-example-apps">Installation, Usage guide and Sample applications</a></li>
<li><a href="http://abhinavsingh.com/blog/2010/08/jaxl-2-0-core-classes-available-methods-and-directory-structure/">Jaxl Core classes, available methods and directory structure</a></li>
<li><a href="http://abhinavsingh.com/blog/2010/08/writing-a-command-line-xmpp-bot-echobot-using-jaxl-2-0/">Writing your first command line bot using Jaxl</a></li>
<li><a href="http://abhinavsingh.com/blog/2010/08/facebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0/">Facebook chat connect with X-FACEBOOK-PLATFORM using Jaxl</a></li>
<li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/">Code, Setup and Demo of Bosh chat application</a></li>
<li><a href="http://abhinavsingh.com/blog/2010/08/how-to-write-external-jabber-components-in-php-using-jaxl-library/">Writing External Jabber Components in PHP using Jaxl library</a></li>
<li>Writing XMPP web applications using Jaxl in 5 minutes <em>(coming soon)</em></li>
<li>Available hooks for various xmpp events <em>(coming soon)</em></li>
<li>Migration guide for Jaxl 1.x users <em>(coming soon)</em></li>
</ul>
<p><strong style="font-size:18px;"><u>Implemented XEP&#8217;s</u></strong><br />
A lot of new XEP&#8217;s has been implemented and packaged with Jaxl 2.0. Developers can use Jaxl event mechanism to implement new XEP&#8217;s without knowing the working of other core parts of the library.</p>
<p>Below is a list of released implemented XEP with Jaxl 2.0:</p>
<ul>
<li>0004 &#8211; Data Forms</li>
<li>0030 &#8211; Service Discovery</li>
<li><a href="http://abhinavsingh.com/blog/2010/08/xep-0045-%e2%80%93-multi-user-chat-muc-available-methods-in-jaxl-2-0/">0045 &#8211; Multi-User Chat</a></li>
<li>0050 &#8211; Ad-Hoc Commands</li>
<li>0085 &#8211; Chat State Notification</li>
<li>0092 &#8211; Software Version</li>
<li><a href="http://abhinavsingh.com/blog/2010/08/how-to-write-external-jabber-components-in-php-using-jaxl-library/">0114 &#8211; Jabber Component Protocol</a></li>
<li>0115 &#8211; Entity Capabilities</li>
<li>0124 &#8211; Bosh Implementation</li>
<li><a href="http://abhinavsingh.com/blog/2010/08/xep-0133-service-administration-available-methods-in-jaxl-2-0/">0133 &#8211; Service Administration</a></li>
<li>0119 &#8211; XMPP Ping</li>
<li>0202 &#8211; Entity Time</li>
<li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/">0206 &#8211; XMPP over BOSH</a></li>
<li>0249 &#8211; Direct MUC Invitation</li>
</ul>
<p><strong style="font-size:18px;"><u>Documentation for project contributors</u></strong><br />
For developers interested in contributing to the Jaxl project, here is a list of insight documentation to get you started:</p>
<ul>
<li>Jaxl core workflow and architecture <em>(coming soon)</em></li>
<li>How to implement new XMPP extensions using Jaxl <em>(coming soon)</em></li>
</ul>
<p><strong style="font-size:18px;"><u>Useful Links</u></strong><br />
For live help and discussion join <a href="xmpp:jaxl@conference.psi-im.org?join">jaxl@conference.psi-im.org</a> chat room</p>
<ul>
<li><a href="http://groups.google.com/group/jaxl">Developer Mailing List</a></li>
<li><a href="http://code.google.com/p/jaxl/issues/list?can=1&#038;q=">Issue Tracker</a></li>
<li><a href="http://www.facebook.com/imjaxlim">Facebook</a></li>
<li><a href="http://twitter.com/imjaxlim">Twitter</a></li>
</ul>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F08%2Freleasing-jaxl-2-0-object-oriented-xmpp-framework-in-php%2F","http:\/\/github.com\/abhinavsingh\/JAXL","http:\/\/code.google.com\/p\/jaxl\/","xmpp:jaxl@conference.psi-im.org?join","http:\/\/groups.google.com\/group\/jaxl","http:\/\/code.google.com\/p\/jaxl\/issues\/list?can=1&#038;q=","http:\/\/www.facebook.com\/imjaxlim","http:\/\/twitter.com\/imjaxlim"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA4L3JlbGVhc2luZy1qYXhsLTItMC1vYmplY3Qtb3JpZW50ZWQteG1wcC1mcmFtZXdvcmstaW4tcGhwLzx3cHRiPlJlbGVhc2luZyBKYXhsIDIuMCAmIzgyMTE7IE9iamVjdCBvcmllbnRlZCBYTVBQIGZyYW1ld29yayBpbiBQSFA8d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%2BQWJoaSYjMDM5O3MgV2VibG9n";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/01/introducing-jaxl-open-source-jabber-xmpp-library/" title="Introducing JAXL &#8211; Open Source Jabber XMPP Library">Introducing JAXL &#8211; Open Source Jabber XMPP Library</a> (92)</li><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2010/01/get-real-time-system-server-load-notification-on-any-im-using-php-and-xmpp/" title="Get real time system &amp; server load notification on any IM using PHP and XMPP">Get real time system &amp; server load notification on any IM using PHP and XMPP</a> (20)</li><li><a href="http://abhinavsingh.com/blog/2010/01/get-lyrics-for-any-song-using-xmpp-and-php-right-into-your-im-add-lyricsflygtalkbots-com/" title="Get lyrics for any song using XMPP and PHP right into your IM &#8211; Add lyricsfly@gtalkbots.com">Get lyrics for any song using XMPP and PHP right into your IM &#8211; Add lyricsfly@gtalkbots.com</a> (17)</li><li><a href="http://abhinavsingh.com/blog/2009/09/5-exciting-gaming-bots-you-can-create-using-jaxl-jabber-xmpp-library-in-php/" title="5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP">5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP</a> (23)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Building a Custom PHP Framework with a custom template caching engine using Output Control functions</title>
		<link>http://abhinavsingh.com/blog/2009/08/building-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions/</link>
		<comments>http://abhinavsingh.com/blog/2009/08/building-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 07:23:11 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Output Control]]></category>
		<category><![CDATA[Template Caching Engine]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=517</guid>
		<description><![CDATA[In past 1 year or so, I had opportunities of using a lot of php frameworks including zend, symfony, cakephp, codeigniter. All frameworks have their pros and cons, however that is out of scope of this blog post. You may want to checkout this comparison list of php frameworks here. In this blog post I [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Fbuilding-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Fbuilding-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Framework,MVC,Open+Source,Output+Control,PHP,Template+Caching+Engine&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In past 1 year or so, I had opportunities of using a lot of php frameworks including <a href="http://framework.zend.com/">zend</a>, <a href="http://www.symfony-project.org/">symfony</a>, <a href="http://cakephp.org/">cakephp</a>, <a href="http://codeigniter.com/">codeigniter</a>. All frameworks have their pros and cons, however that is out of scope of this blog post. You may want to checkout this comparison list of php frameworks <a href="http://www.phpframeworks.com/">here</a>.</p>
<p>In this blog post I will build a custom PHP framework (MVC Architecture). Then go on to discuss in brief about the output control functions and finally show how to build a custom template caching engine using these functions for our framework.</p>
<p><strong style="font-size:18px"><u>Source Code</u></strong><br />
You may want to download the complete source code for this blog post <a href="http://abhinavsingh.googlecode.com/files/Custom%20PHP%20Framework%20with%20Custom%20Template%20Caching%20Engine.rar">from here</a>.</p>
<p><strong style="font-size:18px"><u>Building a custom PHP Framework</u></strong><br />
We will choose a MVC architecture for our framework. Here is a basic directory structure for our custom framework:</p>
<p>/index.php<br />
/.htaccess<br />
/config.ini.php<br />
/404.php<br />
<strong>/view</strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;/view/test1.php<br />
&nbsp;&nbsp;&nbsp;&nbsp;/view/test2.php<br />
<strong>/model</strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;/model/model.class.php<br />
<strong>/controller</strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;/controller/controller.class.php<br />
<strong>/log</strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;/log/logger.class.php<br />
&nbsp;&nbsp;&nbsp;&nbsp;/log/log.log<br />
<strong>/cache</strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;/cache/cache.class.php<br />
&nbsp;&nbsp;&nbsp;&nbsp;/cache/template.cache.class.php<br />
&nbsp;&nbsp;&nbsp;&nbsp;<strong>/cache/template</strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/cache/template/test1.php.tmp<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/cache/template/test2.php.tmp</p>
<p>The view, model, controller, log and cache directories contains the following framework modules respectively:</p>
<ol>
<li><strong>view</strong> directory contains our view level files. i.e. files containing our HTML, js, css code.</li>
<li><strong>model</strong> directory contains the model class responsible for interacting with database and other storages</li>
<li><strong>controller</strong> directory contains our controller class. Each incoming request is first received by the controller class constructor, which thereafter controls the flow of request in the framework</li>
<li><strong>log</strong> directory contains our logger class. This class is auto loaded for every request providing a basic <code>logger::log($log_message)</code> logger method throughout the framework. This class logs all data in a file called log.log.</li>
<li><strong>cache</strong> directory contains our cache class. For this blog tutorial, we will only write the <em>template caching engine class</em>. In production systems, we might have individual classes for other types of cache systems e.g. memcached (Read <a href="http://abhinavsingh.com/blog/2009/01/memcached-and-n-things-you-can-do-with-it/">Memcached and “N” things you can do with it – Part 1</a> to know more about memcached and <a href="http://abhinavsingh.com/blog/2009/01/mysql-query-cache-wp-cache-apc-memcache-what-to-choose/">MySQL Query Cache, WP-Cache, APC, Memcache – What to choose</a> for a complete comparison lists of various other caching techniques.</li>
</ol>
<p>Lets see in details, what all file each and every directory contain contains.</p>
<p><strong><u>Root directory files</u></strong><br />
We have 4 files in our root directory, namely .htaccess, index.php, config.ini.php and 404.php in order of relevance. Lets look through the content of these files:</p>
<p><u>.htaccess</u></p>
<pre name="code" class="php">RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
</pre>
<ol>
<li>1st two lines essentially means that Switch on the apache rewrite module and set RewriteBase as / i.e. the root directory</li>
<li>Last 3 lines mean that, if incoming request is for a file or directory which physically exists under the root directory serve them otherwise route all other requests to index.php in the root directory</li>
</ol>
<p>Hence now for an incoming request like <a href="http://localhost/test1.php">http://localhost/test1.php</a>, apache will route the request to <code>index.php</code> in the root directory because there is no <code>test1.php</code> under the root directory. Cool, lets see what <code>index.php</code> has to offer.</p>
<p><u>index.php</u></p>
<pre name="code" class="php">&lt;?php

  // include configuration file
  include_once("config.ini.php");

  // include controller files
  include_once("controller/controller.class.php");

?&gt;
</pre>
<p>index.php doesn&#8217;t do much except for including our core configuration file and controller class file. Controller class constructor is initiated as soon as the class file is included.</p>
<p><code>config.ini.php</code> is our core configuration file. It provides the framework with an array called <code>$config</code> containing various information like: mysql database credentials, requested url details and various other global parameters. Lets see what all parameter does it provide us with.</p>
<p><u>config.ini.php</u></p>
<pre name="code" class="php">&lt;?php

  $config = array(
                  'host'=&gt;array(
                                'name' =&gt; "http://".$_SERVER['HTTP_HOST'].'/',
                                'uri' =&gt; $_SERVER['REQUEST_URI'],
                                'url' =&gt; parse_url($_SERVER['REQUEST_URI']), // note it contains the parsed url contents
                               ),
                  'mysql'=&gt;array(
                                 'host' =&gt; 'localhost',
                                 'name'=&gt; 'testdb',
                                 'user' =&gt; 'root',
                                 'pass' =&gt; 'password',
                                ),
                  'cache'=>array(
                                 'template' => 'On', // template caching switched on by default
                                 'memcached' => 'Off', // switch off memcached caching
                                ),
                 );

?&gt;
</pre>
<p>$config['host'] array saves various parameter about the host itself, e.g. hostname, hosturi (the requested uri, hosturl (it contains the parse_url(hosturi)).</p>
<p>$config['mysql'] array contains mysql database parameters. However in this blog post we will not interact with databases.</p>
<p>$config['cache'] tells the framework what all caching modules are switched on.</p>
<p><u>404.php</u></p>
<pre name="code" class="php">&lt;html&gt;
  &lt;head&gt;

  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;404 Page&lt;/h1&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p><strong><u>Controller directory files</u></strong><br />
For this blog post, controller directory consists of a single class file. i.e. <code>controller.class.php</code>. We saw this being included by <code>index.php</code> in the root folder above. As soon as controller class is included, it&#8217;s constructor is invoked. Before we dig in more, lets see the controller class file:</p>
<p><u>controller.class.php</u></p>
<pre name="code" class="php">&lt;?php

  // include logger class
  include_once("log/logger.class.php");

  // include cache class (contains template caching)
  include_once("cache/cache.class.php");

  // include model class
  include_once("model/model.class.php");

  class controller {

    function __construct($config) {
        global $config;

        // generate requested template name and path
        $config['template']['name'] = $config['host']['uri'] == '/' ? 'index.php' : substr($config['host']['uri'], 1, strlen($config['host']['uri']));
        $config['template']['path'] = "view/".$config['template']['name'];

        // check 404
        if(!file_exists($config['template']['path'])) {
            $config['template']['name'] = "404.php";
            $config['template']['path'] = "404.php";
        }
        logger::log("Requested template name ".$config['template']['name'].", path ".$config['template']['path']);

        // invoke template caching engine
        $template_cache = new template_cache();

        // include the template
        include_once($config['template']['path']);

        // cache template
        $template_cache-&gt;setTemplate();
    }

  }

  $controller = new controller($config);

?&gt;
</pre>
<p>At the top, controller class includes the <code>logger.class.php</code>, <code>cache.class.php</code> and <code>model.class.php</code> files. At the bottom, the controller object is instantiated.</p>
<p>The constructor performs the following 5 tasks:</p>
<ol>
<li>At first it generates a template name and a template path for the incoming request i.e. for <a href="http://localhost/">http://localhost/</a>, <code>$config['template']['name']='index.php'</code> and for <a href="http://localhost/test1.php">http://localhost/test1.php</a>, <code>$config['template']['name']='test1.php'</code>.</li>
<li>Second it checks for 404. For the above generated template path, e.g. <code>$config['template']['path']='view/test1.php'</code>, it checks whether this file exists inside root directory. If it doesn&#8217;t template path and names are set to <code>404.php</code></li>
<li>Thirdly, It invokes the template caching engine. i.e. <code>$template_cache = new template_cache();</code></li>
<li>Forth, it includes the generated template path above i.e. <code>include_once($config['template']['path']);</code></li>
<li>Fifth and finally, it caches the generated HTML, js, css code by the template file includes above. This is achieved by the following code, <code>$template_cache->setTemplate();</code></li>
</ol>
<p>Before we move our attention to, lets see in short the content of log and view directories.</p>
<p><strong><u>Log directory files</u></strong><br />
Log directory contains our logger class. This class is auto loaded for each incoming request that is being routed to index.php in the root directory (as we saw above). The <code>logger.class.php</code> provides a static <code>logger::log($log_message)</code> method, which can be used throughout the framework for logging messages. We will be using it everywhere.</p>
<p><u>logger.class.php</u></p>
<pre name="code" class="php">&lt;?php

  class logger {

    static $log_file = "log/log.log";

    static function log($log) {
      if($log != '') {
        $fh = fopen(self::$log_file, "a");
        fwrite($fh,date('Y-m-d H:i:s')."\n".$log."\n\n");
        fclose($fh);
      }
    }

  }

?&gt;
</pre>
<p>The logger class by default logs all data to a file called log.log.</p>
<p><strong><u>View directory files</u></strong><br />
For this blog post, we have two simple test pages in view directory namely <code>test1.php</code> and <code>test2.php</code>, which can be access by typing <a href="http://localhost/test1.php">http://localhost/test1.php</a> and <a href="http://localhost/test2.php">http://localhost/test2.php</a> respectively in the browser.</p>
<p><u>test1.php</u></p>
<pre name="code" class="php">&lt;html&gt;
  &lt;head&gt;

  &lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;
      &lt;?php echo model::test1data(); ?&gt;
    &lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>test1.php simply calls the model class method called model::test1data() (static method). This method extracts some dummy text from the database and returns it back.</p>
<p><strong><u>Model directory files</u></strong><br />
Model directory contains the model class file. In production systems, model class file will provide various methods to select and insert data in the databases. However for this blog post we will simply return some static dummy test.</p>
<p><u>model.class.php</u></p>
<pre name="code" class="php">&lt;?php

  class model {

    // This method will return data generally from a database table
    // To keep it simple for the post we return some dummy lipsum text
    static function test1data() {
      logger::log("Returning test1data() from database");
      return "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ut nulla ac risus viverra ornare. Nulla consectetur, metus eleifend pharetra posuere, lacus nibh elementum leo, in fermentum lectus lorem in ipsum. Nullam pulvinar purus at erat pharetra volutpat. Pellentesque egestas rutrum lectus, ut rutrum tellus tristique sed. Integer diam est, ornare ac ultricies vel, aliquam non mi. Etiam tempor leo eu lacus tempus sagittis sagittis turpis dictum. Sed leo sapien, pharetra sit amet faucibus et, mollis id nulla. Praesent feugiat mi nec dui scelerisque mollis vehicula magna feugiat. Aliquam erat volutpat. Curabitur quis velit ut nibh rhoncus convallis. Proin mauris nunc, rhoncus vel laoreet vel, aliquet quis nunc. Aenean interdum risus non neque blandit sed adipiscing ipsum mollis. Vivamus enim orci, ultrices at scelerisque vel, laoreet a turpis. Nullam posuere ante sed nisl porta porta aliquam metus suscipit. Fusce enim odio, iaculis at suscipit eget, vestibulum volutpat enim. Nam dictum turpis quis velit posuere in malesuada mi convallis. Donec faucibus, felis id dictum imperdiet, orci tortor tristique neque, vitae lobortis libero tellus sed lorem. Duis tellus magna, commodo eget blandit ut, auctor nec nibh. Maecenas ornare ornare risus nec ultrices. Pellentesque lectus eros, imperdiet ut rhoncus vel, tempus ut nisi.";
    }

    static function test2data() {
      logger::log("Returning test2data() from database");
      return "Vestibulum laoreet nibh sed nulla mollis cursus. Maecenas sodales mauris sit amet ligula euismod a lacinia turpis adipiscing. Nulla gravida porta augue, id adipiscing libero tincidunt ac. Morbi non velit id odio porta tempus id eget massa. Cras nibh purus, gravida sed suscipit ut, tincidunt eu neque. In id est eros, ac sodales orci. Ut lectus augue, feugiat sit amet consectetur id, pharetra quis tellus. Maecenas eget lobortis urna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce tincidunt eleifend neque. Aenean accumsan orci vitae erat blandit porttitor. Aliquam tristique dolor ac nibh elementum id lacinia diam cursus.";
    }

  }

?&gt;
</pre>
<p><strong><u>Cache directory files</u></strong><br />
For this blog post, cache directory contains the main cache.class.php file which in turn includes various other cache classes e.g. <code>template.cache.class.php</code></p>
<p><u>cache.class.php</u></p>
<pre name="code" class="php">&lt;?php

  // check for switched on cache modules
  foreach($config['cache'] as $key =&gt; $value) {
    // include all cache classes, which are swicted on
    if($value == 'On') {
      // naming convention is &lt;modulename.cache.class.php&gt;
      include_once('cache/'.$key.'.cache.class.php');
    }
  }

?&gt;
</pre>
<p><strong style="font-size:18px"><u>Output Control Functions</u></strong><br />
<a href="http://php.net">PHP</a> is a very simple language. You can write a Hello World! code or calculate similarity between two strings (see <a href="http://us2.php.net/manual/en/function.similar-text.php">similar_text()</a>), both with a single line of code. And hence there are a lot of fundamental concepts of PHP, which not only beginners  but even some advanced coders can ignore. One such concept is <a href="http://in3.php.net/manual/en/intro.outcontrol.php">Output Control in PHP</a>.</p>
<p>The Output Control functions allow you to control when the output of your PHP script will be thrown to the browsers (console). i.e. You can pre-process the final html output (append, prepend, chip-chop, inserting ad-codes, url linking, keyword highlighting, template caching), which will otherwise be thrown on the browser. Interesting, isn&#8217;t it? Can you feel the power of Output Control functions?</p>
<ol>
<li><a href="http://in3.php.net/manual/en/function.ob-start.php">ob_start</a>: This turns on output buffering. i.e. no output is sent from the script, instead the output is saved in an internal buffer. However output buffering doesn&#8217;t buffers your headers. <code>ob_start()</code> also takes an optional callback function name. The function is called when output buffer is flushed (see <a href="http://in3.php.net/manual/en/function.ob-flush.php">ob_flush()</a>) or cleaned (see <a href="http://in3.php.net/manual/en/function.ob-clean.php">ob_clean()</a>). We can access the this internal buffer using functions like <a href="http://in3.php.net/manual/en/function.ob-get-contents.php">ob_get_contents()</a></li>
<li><a href="http://in3.php.net/manual/en/function.ob-end-flush.php">ob_end_flush</a>: This function send the content of the buffer (if any) and turns off output buffering. We should always call functions like <a href="http://in3.php.net/manual/en/function.ob-get-contents.php">ob_get_contents()</a> before <code>ob_end_flush()</code>, since any changes after this functions will not reflect on the browser</li>
</ol>
<p><strong style="font-size:18px"><u>Building a custom Template Caching Engine</u></strong><br />
We saw above some of the output control functions PHP has to offer. <code>ob_start()</code>, <code>ob_get_contents()</code> and <code>ob_end_flush();</code> are the 3 functions we will use to create our custom template caching engine.</p>
<p><u>template.cache.class.php</u></p>
<pre name="code" class="php">&lt;?php

  class template_cache {

    var $template_cache_file = FALSE;
    var $template_cache_file_ext = ".tmp";
    var $template_cache_dir = "cache/template/";
    var $template_cache_ttl = 300; // secs

    function __construct() {

      // initiate template caching
      $this-&gt;init();

    }

    function init() {
      // get template path
      $this-&gt;template_cache_file = $this-&gt;generateTemplatePath();

      // get template from cache if exists
      $this-&gt;getTemplate();

      // start output buffering
      ob_start();
    }

    function generateTemplatePath() {
      global $config;

      // generate template file name
      return $this-&gt;template_cache_dir.$config['template']['name'].$this-&gt;template_cache_file_ext;
    }

    function getTemplate() {
      global $config;

      // check if a cached template exists
      if(file_exists($this-&gt;template_cache_file)) {
        if(time() - filemtime($this-&gt;template_cache_file) &lt; $this-&gt;template_cache_ttl) {
          logger::log("Cache hit for template ".$config['template']['name']);
          $content = file_get_contents($this-&gt;template_cache_file);
          echo $content;
          exit;
        }
        else {
          logger::log("Cache stale for template ".$config['template']['name']);
          return FALSE;
        }
      }
      else {
        logger::log("Cache miss for template ".$config['template']['name']);
        return FALSE;
      }
    }

    function setTemplate() {
      global $config;

      // get buffer
      $content = ob_get_contents();

      // save template
      logger::log("Caching template ".$config['template']['name']);
      $fh = fopen($this-&gt;template_cache_file, 'w');
      fwrite($fh, $content);
      fclose($fh);

      // Flush the output buffer and turn off output buffering
      ob_end_flush();
    }

  }

?&gt;
</pre>
<p>As we saw above in controller class, the template engine class was instantiated before including the actual template file. Template engine constructor do the following 3 tasks:</p>
<ol>
<li>Generate a cached file name for the requested uri by calling the <code>$this->generateTemplatePath();</code> method. e.g. if <code>http://localhost/test1.php</code> is the requested uri, <code><strong>test1.php.tmp</strong></code> is it&#8217;s static cached template</li>
<li>Secondly, it tries to fetch the cached template file by calling the method <code>$this->getTemplate();</code> (read on for details of this method)</li>
<li>Finally it turns on output buffering by calling <code>ob_start();</code></li>
</ol>
<p>List of methods provided by template.cache.class.php are:</p>
<ol>
<li>generateTemplatePath() method generates a cache file name for incoming request. By default extension of all cached files in <strong>&#8220;.tmp&#8221;</strong> and are stored under the <strong>/cache/template</strong> directory.</li>
<li>getTemplate() method do a number of tasks. First, it checks if a cached template exists for the requested uri. If it does not exists or if it is not a fresh cache (see $template_cache_ttl), this method simply returns control back to controller which go ahead and include the actual template file. However if the file exists and is fresh it reads the content of the file and throw back to browser. At this point control is no longer transferred back to the controller, hence saving various un-necessary processing and database calls.</li>
<li>setTemplate() method is called by controller after including the actual template file from under the view directory. Point to note is that, before getTemplate() returns control back to controller (in case of missed or stale cache), the template cache class constructor does switch on output buffering. And when setTemplate() method is called, we can access this buffer using output functions like <code>ob_get_contents()</code> and then save the template for next incoming request. Bingo!. Finally this method throw away the buffer to the browser using <code>ob_end_flush();</code></li>
</ol>
<p><strong style="font-size:18px;"><u>Is it working?</u></strong><br />
To verify the flow of framework, I hit the url http://localhost/test1.php 3 times, with <code>$template_cache_ttl = 10;</code> (seconds).</p>
<ol>
<li>Once after clearing the template cache folder</li>
<li>Once within next 10 seconds</li>
<li>And finally after 10 seconds</li>
</ol>
<p>Here is how the log file looks like:</p>
<pre name="code" class="php">
2009-08-16 19:50:49
Requested template name test1.php, path view/test1.php (1st REQUEST)

2009-08-16 19:50:49
Cache miss for template test1.php

2009-08-16 19:50:49
Returning test1data() from database

2009-08-16 19:50:49
Caching template test1.php

2009-08-16 19:50:54
Requested template name test1.php, path view/test1.php (2nd REQUEST)

2009-08-16 19:50:54
Cache hit for template test1.php

2009-08-16 19:51:03
Requested template name test1.php, path view/test1.php (3rd REQUEST)

2009-08-16 19:51:03
Cache stale for template test1.php

2009-08-16 19:51:03
Returning test1data() from database

2009-08-16 19:51:03
Caching template test1.php
</pre>
<p><strong style="font-size:18px;"><u>Moving forward, What&#8217;s Next? Extending template.cache.class.php</u></strong><br />
Template cache class can be extended to do a lot more, other than caching the template files. For instance we might want to perform (chip-chop, append, prepend etc) a few tasks, before we cache the final template and throw back to the browser. Few tasks which look quite obvious to me are:</p>
<ol>
<li><strong>Short Codes:</strong> We can insert short codes in our HTML templates, which later on can be expanded into full fledged codes. e.g. For embedding a YouTube video, we can simply put something like <code>[[YouTube yjPBkvYh-ss]]</code> into test1.php. And in setTemplate() method we can call <em>helper/plugin methods</em> to process such short codes. More professionally, we can add hooks for various tasks we might want to perform before caching the template. Read <a href="http://abhinavsingh.com/blog/2009/07/how-to-add-wordpress-like-add_filter-hooks-in-your-php-framework/">How to add wordpress like add_filter hooks in your PHP framework</a> for a more professional approach.</li>
<li><strong>Inserting page header and footer:</strong> Instead of including page header and footer inside <code>test1.php</code>, we can simply put our main <code>&lt;body&gt;</code> code inside test1.php. Then before caching the template file, we can append and prepend header and footer modules to the buffer of each page. Thus avoiding including the same header and footer files across various pages.</li>
<li><strong>HTML module caching:</strong> There are several instances where we can have a common module across all pages. For instance, I can have a events module across all my pages, which basically displays a calendar with various events for the week or month marked on it. The event details are extracted from the database. Since this module of mine is a static HTML chunk for atleast a week, I would like to have a difference cache for this module. Intelligently hooking up these modules with template caching engine, can allow us to do module level caching</li>
</ol>
<p>I can probably write down 10-15 more such applications and probably there might be many more such applications of the above coded template caching engine. (Note: The power actually lies in Output Control Functions provided by PHP).</p>
<p>Let me know if you liked the post or any bug in it.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Fbuilding-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions%2F","http:\/\/framework.zend.com\/","http:\/\/www.symfony-project.org\/","http:\/\/cakephp.org\/","http:\/\/codeigniter.com\/","http:\/\/www.phpframeworks.com\/","http:\/\/abhinavsingh.googlecode.com\/files\/Custom%20PHP%20Framework%20with%20Custom%20Template%20Caching%20Engine.rar","http:\/\/localhost\/test1.php","http:\/\/localhost\/","http:\/\/localhost\/test1.php","http:\/\/localhost\/test1.php","http:\/\/localhost\/test2.php","http:\/\/php.net","http:\/\/us2.php.net\/manual\/en\/function.similar-text.php","http:\/\/in3.php.net\/manual\/en\/intro.outcontrol.php","http:\/\/in3.php.net\/manual\/en\/function.ob-start.php","http:\/\/in3.php.net\/manual\/en\/function.ob-flush.php","http:\/\/in3.php.net\/manual\/en\/function.ob-clean.php","http:\/\/in3.php.net\/manual\/en\/function.ob-get-contents.php","http:\/\/in3.php.net\/manual\/en\/function.ob-end-flush.php","http:\/\/in3.php.net\/manual\/en\/function.ob-get-contents.php"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzA4L2J1aWxkaW5nLWEtY3VzdG9tLXBocC1mcmFtZXdvcmstd2l0aC1hLWN1c3RvbS10ZW1wbGF0ZS1jYWNoaW5nLWVuZ2luZS11c2luZy1vdXRwdXQtY29udHJvbC1mdW5jdGlvbnMvPHdwdGI%2BQnVpbGRpbmcgYSBDdXN0b20gUEhQIEZyYW1ld29yayB3aXRoIGEgY3VzdG9tIHRlbXBsYXRlIGNhY2hpbmcgZW5naW5lIHVzaW5nIE91dHB1dCBDb250cm9sIGZ1bmN0aW9uczx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2008/10/how-to-build-a-login-registration-system-using-symfony-a-php-framework-part-2/" title="How to build a login-registration system using Symfony &#8211; A PHP Framework &#8211; Part 2">How to build a login-registration system using Symfony &#8211; A PHP Framework &#8211; Part 2</a> (37)</li><li><a href="http://abhinavsingh.com/blog/2008/10/getting-started-with-symfony-a-php-framework-part-1/" title="Getting started with Symfony &#8211; A PHP Framework &#8211; Part 1">Getting started with Symfony &#8211; A PHP Framework &#8211; Part 1</a> (33)</li><li><a href="http://abhinavsingh.com/blog/2009/09/5-exciting-gaming-bots-you-can-create-using-jaxl-jabber-xmpp-library-in-php/" title="5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP">5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP</a> (23)</li><li><a href="http://abhinavsingh.com/blog/2009/08/how-to-generate-random-password-like-wordpress-using-php/" title="How to generate random password like Wordpress using PHP?">How to generate random password like Wordpress using PHP?</a> (9)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/08/building-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to add wordpress like add_filter hooks in your PHP framework</title>
		<link>http://abhinavsingh.com/blog/2009/07/how-to-add-wordpress-like-add_filter-hooks-in-your-php-framework/</link>
		<comments>http://abhinavsingh.com/blog/2009/07/how-to-add-wordpress-like-add_filter-hooks-in-your-php-framework/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 09:23:59 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=506</guid>
		<description><![CDATA[I simply love wordpress mainly because of the architectural design it follows to deliver the good. WordPress provide a hook or filter functionality to almost everything that appears on your blog. If you are a wordpress plugin developer you surely must have used one of them, specially add_filter() hook. add_filter functionality provides plugin developer a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F07%2Fhow-to-add-wordpress-like-add_filter-hooks-in-your-php-framework%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F07%2Fhow-to-add-wordpress-like-add_filter-hooks-in-your-php-framework%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Demo,Framework,PHP,WordPress&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I simply love wordpress mainly because of the architectural design it follows to deliver the good. WordPress provide a hook or filter functionality to almost everything that appears on your blog. If you are a wordpress plugin developer you surely must have used one of them, specially <a href="http://codex.wordpress.org/Function_Reference/add_filter">add_filter()</a> hook.</p>
<p>add_filter functionality provides plugin developer a way to apply custom hooks on various page sections. For instance <code>add_filter('the_content', 'HelloWorld')</code> will force the content to be passed through the <code>function HelloWorld($content)</code> before being displayed to your blog users.</p>
<p>In this blog post I will show you how can you achieve doing the same thing for your custom PHP frameworks. Otherwise you can also use this in your day to day projects. We will start with a simple directory structure, assuming this is all we have in our framework to start with:</p>
<p><strong style="font-size:18px;"><u>Files/Folder structure of our framework</u></strong><br />
&#8211; addHooks<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#8211; index.php<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#8211; applyHooks.php<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#8211; hooks<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8211; Subscribe.php<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8211; Signature.php</p>
<p><u>addHooks: </u>Our framework root directory.<br />
<u>index.php: </u>Homepage for our framework.<br />
<u>applyHooks.php: </u>Responsible for including and implementing various hooks.<br />
<u>hooks: </u>Our hooks directory. We will put all our hooks here.<br />
<u>Subscribe.php: </u>A simple hook which will add a subscribe my feed link.<br />
<u>Signature.php: </u>Another simple hook which adds my signature.</p>
<p><strong style="font-size:18px;"><u>Source code</u></strong><br />
<a href="http://abhinavsingh.googlecode.com/files/addHooks.rar">Download the complete source code from here.</a></p>
<p><strong>index.php</strong></p>
<pre name="code" class="php">
  // define some content
  // in this demo i will show to how to apply hook to $content, similar to wordpress blog $content
  $content = "In this blog post I will show you how to add wordpress like add_filter hooks in your PHP framework.";

  // Include our hook management file
  require_once("applyHooks.php");
  </pre>
<p><strong>Subscribe.php</strong></p>
<pre name="code" class="php">
  function Subscribe($content) {
    $subscribe = '';
    $subscribe .= 'Subscribe to my RSS feed';
    $subscribe .= '<br/><br/>';

    return $subscribe.$content;
  }

  add_filter('the_content', 'Subscribe');
  </pre>
<p><strong>Signature.php</strong></p>
<pre name="code" class="php">
  function Signature($content) {
    $signature = '<br/><br/>';
    $signature .= 'Abhinav Singh<br/>';
    $signature .= 'Follow on twitter @imoracle<br/>';

    return $content.$signature;
  }

  add_filter('the_content', 'Signature');
  </pre>
<p><strong>applyHooks.php</strong></p>
<pre name="code" class="php">
  /* plugin directory */
  $hook_dir = "hooks/";

  /* get all plugin files */
  $hook_files = glob($hook_dir."*.php");

  /* array saving all our hooks on the_content */
  $hooks['the_content'] = array();

  /* add_filter functionality */
  function add_filter($on, $func) {
    global $hooks;
    array_push($hooks[$on], $func);
  }

  /* include plugin files */
  foreach($hook_files as $hook_file) {
    require_once($hook_file);
  }

  /* implement the hooks */
  foreach($hooks['the_content'] as $hook) {
    $content = call_user_func($hook, $content);
  }

  echo $content;
  </pre>
<p><strong style="font-size:18px;"><u>Final Result</u></strong><br />
When you try to visit your framework opening page on your browser, i.e. index.php. You will see your $content being filtered/modified and displayed as:<br />
<img src="http://abhinavsingh.com/blog/wp-content/uploads/2009/07/add_filter_output.png" alt="add_filter_output" title="add_filter_output" width="621" height="131" class="alignleft size-full wp-image-507" style="border:1px solid #777777; padding:4px;" /></p>
<p><strong style="font-size:18px;"><u>How does applyHooks.php works</u></strong><br />
So what allows us adding such hooks in our framework. <strong>call_user_func</strong> is a PHP function which allows you to call a user defined function. Here is in short how <strong>applyHooks.php</strong> work:</p>
<ol>
<li>applyHooks.php adds a method called <code>add_filter($on, $func)</code> before including the hook files</li>
<li>add_filter() essentially takes input as <em>$on = the element on which you want to apply the hook</em> and <em>$func = the hook you want to apply $on element</em>.</li>
<li>If you see our Signature.php code, you will find <code>add_filter('the_content', 'Signature');</code>. Which essentially means, apply the filter called $func=&#8217;Signature&#8217;, $on=&#8217;the_content&#8217;</li>
<li>The applyHooks.php file keep registering these hooks and save them in $hooks array</li>
<li>Finally it implement all hook one by one by calling the <a href="http://in2.php.net/call_user_func">call_user_func</a> function (PS: You may also want to use <a href="http://in2.php.net/call_user_func_array">call_user_func_array</a>)</li>
</ol>
<p><strong style="font-size:18px;"><u>Extending applyHooks.php</u></strong><br />
In this blog post I have shown a demo, how you can create a add_filter type functionality. You may want to extend this to include hooks like:</p>
<ul>
<li>remove_filter</li>
<li>add_shortcode</li>
</ul>
<p>and others.</p>
<p>Hope this will help you making your web apps more expendable and manageable. <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F07%2Fhow-to-add-wordpress-like-add_filter-hooks-in-your-php-framework%2F","http:\/\/codex.wordpress.org\/Function_Reference\/add_filter","http:\/\/abhinavsingh.googlecode.com\/files\/addHooks.rar","http:\/\/in2.php.net\/call_user_func","http:\/\/in2.php.net\/call_user_func_array"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzA3L2hvdy10by1hZGQtd29yZHByZXNzLWxpa2UtYWRkX2ZpbHRlci1ob29rcy1pbi15b3VyLXBocC1mcmFtZXdvcmsvPHdwdGI%2BSG93IHRvIGFkZCB3b3JkcHJlc3MgbGlrZSBhZGRfZmlsdGVyIGhvb2tzIGluIHlvdXIgUEhQIGZyYW1ld29yazx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2010/01/jaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs/" title="JAXL BOSH Demo: IM chat client for all Wordpress blogs">JAXL BOSH Demo: IM chat client for all Wordpress blogs</a> (35)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/10/web-security-using-crumbs-to-protect-your-php-api-ajax-call-from-cross-site-request-forgery-csrfxsrf-and-other-vulnerabilities/" title="Web Security : Using crumbs to protect your PHP API (Ajax) call from Cross-site request forgery (CSRF/XSRF) and other vulnerabilities">Web Security : Using crumbs to protect your PHP API (Ajax) call from Cross-site request forgery (CSRF/XSRF) and other vulnerabilities</a> (13)</li><li><a href="http://abhinavsingh.com/blog/2009/08/building-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions/" title="Building a Custom PHP Framework with a custom template caching engine using Output Control functions">Building a Custom PHP Framework with a custom template caching engine using Output Control functions</a> (10)</li><li><a href="http://abhinavsingh.com/blog/2009/08/how-to-generate-random-password-like-wordpress-using-php/" title="How to generate random password like Wordpress using PHP?">How to generate random password like Wordpress using PHP?</a> (9)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/07/how-to-add-wordpress-like-add_filter-hooks-in-your-php-framework/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>How to create a social networking website in 5 minutes</title>
		<link>http://abhinavsingh.com/blog/2008/11/how-to-create-a-social-networking-website-in-5-minutes/</link>
		<comments>http://abhinavsingh.com/blog/2008/11/how-to-create-a-social-networking-website-in-5-minutes/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 09:03:12 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Elgg]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Social Network]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/2008/11/how-to-create-a-social-networking-website-in-5-minutes/</guid>
		<description><![CDATA[Hello Friends, Social media is the way to go now-a-days. After Orkut, Facebook and My Space we saw hundreds of social networking site making their mark in the market. However now a days socialness is not only restricted to social networking sites. Now every company wants to include some amount of socialness into their website, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F11%2Fhow-to-create-a-social-networking-website-in-5-minutes%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F11%2Fhow-to-create-a-social-networking-website-in-5-minutes%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Elgg,Framework,Open+Source,Social+Network&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello Friends,</p>
<p>Social media is the way to go now-a-days. After Orkut, Facebook and My Space we saw hundreds of social networking site making their mark in the market. However now a days socialness is not only restricted to social networking sites. Now every company wants to include some amount of socialness into their website, product or whatever it is.</p>
<p>However the features which any of the social networking site provide are same and restricted to a certain extent. 3 of the sites which I have developed so far, all have socialness as a base component. (<a href="http://gtalkbots.com" target="_blank">Gtalkbots</a>, <a href="http://altertunes.com" target="_blank">Altertunes</a>,<a href="http://iitgalumni.org" target="_blank"> IITG Alumni</a>) However after I saw <a href="http://elgg.org" target="_blank">Elgg</a> a few days back, I was just wondering how much time I wasted in building social features in all the 3 sites. I just wish I could have found this before.</p>
<p>Here in 5 minutes we will see how to build a full fledged social networking site using Elgg:</p>
<ol>
<li>Download Elgg setup from the download page <a href="http://elgg.org/downloads.php" target="_blank">here</a> or directly using this link <a href="http://elgg.org/getelgg.php?forward=elgg1.1.zip" target="_blank">http://elgg.org/getelgg.php?forward=elgg1.1.zip</a></li>
<li>Lets name our social networking site as <span style="font-weight: bold;">Snizr</span>.</li>
<li>Extract the downloaded zip file in your Apache Document Root and name the folder as snizr. In my case it is <span style="font-weight: bold;">C:\Workspace\snizr&nbsp;</span></li>
<li>Now just<span style="font-weight: bold;"> </span>open the url <a href="http://localhost/snizr" target="_blank">http://localhost/snizr</a> and you will see a page like this:
<p><img src="http://abhinavsingh.com/library/images/400x1000-elgg1.gif" style="border: 1px solid rgb(119, 119, 119); padding: 5px;" /></li>
<li>Create a database named <span style="font-weight: bold;">snizr</span> in mysql and enter the details in the form above. Press enter and you will come to the system settings page. If for some reasons this configuration page doesn&#8217;t take you to the system settings page, manually go to <span style="font-weight: bold;">engine/settings.example.php</span> and rename it to <span style="font-weight: bold;">engine/settings.php</span> and enter the details inside.
<p><img src="http://abhinavsingh.com/library/images/400x1000-elgg2.gif" style="border: 1px solid rgb(119, 119, 119); padding: 5px;" /></p>
<p><img src="http://abhinavsingh.com/library/images/400x1000-elgg3.gif" style="border: 1px solid rgb(119, 119, 119); padding: 5px;" /></li>
<li>Now enter the details of your social network here. Create a upload folder outside the installation directory e.g. C:\Workspace\snizr-uploads\ . You will be asked to enter this path in the system settings above.
</li>
<li>After you are done you are taken to the registration page. The first registered user is admin by default.<br />
<!-- YOUR LEFT AD HERE --><br />
<img src="http://abhinavsingh.com/library/images/400x1000-elgg4.gif" style="border: 1px solid rgb(119, 119, 119); padding: 5px;" /></li>
<li>Thats it. You have a full social networking available for you. After registration you come to the login page and after loggin in you come to your dashboard.</li>
</ol>
<p><span style="font-weight: bold; text-decoration: underline; color: rgb(102, 51, 255);">Features provided by Elgg:</span><br />
You just got a feel of how easy it is and its not even 5 minutes as per my watch. Still 2 min to go <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  .<br />
Quickly lets see what else does Elgg offer.</p>
<ol>
<li>Click on <a href="http://localhost/snizr/pg/admin/statistics/" target="_blank">Administration</a> link at the top navigation bar and you will be amazed to see the kind of admin panel it provides.
</li>
<li>Next go to <a href="http://localhost/snizr/pg/admin/plugins/" target="_blank">Tool Administration</a> and you can see about 10 plugins at your service. From Blog, API, Bookmarks, Friends, Groups, Messages, Status, UserValidationByEmail and what not.</li>
<li>Enable a few and go to your profile pages to see them being reflected immediately.</li>
</ol>
<p>Now I will leave to explore rest of it yourself. 5 minutes are almost over <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I hope you enjoyed discovering Elgg.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F11%2Fhow-to-create-a-social-networking-website-in-5-minutes%2F","http:\/\/gtalkbots.com","http:\/\/altertunes.com","http:\/\/iitgalumni.org","http:\/\/elgg.org","http:\/\/elgg.org\/downloads.php","http:\/\/elgg.org\/getelgg.php?forward=elgg1.1.zip","http:\/\/localhost\/snizr","http:\/\/localhost\/snizr\/pg\/admin\/statistics\/","http:\/\/localhost\/snizr\/pg\/admin\/plugins\/"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA4LzExL2hvdy10by1jcmVhdGUtYS1zb2NpYWwtbmV0d29ya2luZy13ZWJzaXRlLWluLTUtbWludXRlcy88d3B0Yj5Ib3cgdG8gY3JlYXRlIGEgc29jaWFsIG5ldHdvcmtpbmcgd2Vic2l0ZSBpbiA1IG1pbnV0ZXM8d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%2BQWJoaSYjMDM5O3MgV2VibG9n";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/08/building-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions/" title="Building a Custom PHP Framework with a custom template caching engine using Output Control functions">Building a Custom PHP Framework with a custom template caching engine using Output Control functions</a> (10)</li><li><a href="http://abhinavsingh.com/blog/2010/02/wordpress-toolbar-v-2-2-custom-toolbar-url-support-for-wpmu-and-bug-fixes/" title="Wordpress Toolbar v 2.2 : Custom toolbar url,  Support for WPMU and bug fixes">Wordpress Toolbar v 2.2 : Custom toolbar url,  Support for WPMU and bug fixes</a> (37)</li><li><a href="http://abhinavsingh.com/blog/2009/09/5-exciting-gaming-bots-you-can-create-using-jaxl-jabber-xmpp-library-in-php/" title="5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP">5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP</a> (23)</li><li><a href="http://abhinavsingh.com/blog/2009/08/introducing-jslider-a-content-slider-plugin-for-jquery/" title="Introducing jSlider: A Content Slider plugin for JQuery">Introducing jSlider: A Content Slider plugin for JQuery</a> (6)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2008/11/how-to-create-a-social-networking-website-in-5-minutes/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>How to build a login-registration system using Symfony &#8211; A PHP Framework &#8211; Part 2</title>
		<link>http://abhinavsingh.com/blog/2008/10/how-to-build-a-login-registration-system-using-symfony-a-php-framework-part-2/</link>
		<comments>http://abhinavsingh.com/blog/2008/10/how-to-build-a-login-registration-system-using-symfony-a-php-framework-part-2/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 15:51:01 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Propel]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/2008/10/how-to-build-a-login-registration-system-using-symfony-a-php-framework-part-2/</guid>
		<description><![CDATA[Hello again, In the last tutorial we saw a very basic implementation which will simply print &#8220;Hello World&#8221; on your browser screen. For those who have landed up here straight here, you may want to go through this blog post. Getting started with Symfony &#8211; A PHP Framework &#8211; Part 1 By now if you [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F10%2Fhow-to-build-a-login-registration-system-using-symfony-a-php-framework-part-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F10%2Fhow-to-build-a-login-registration-system-using-symfony-a-php-framework-part-2%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Framework,MVC,PHP,Propel,Symfony,Tutorial&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello again,</p>
<p>In the last tutorial we saw a very basic implementation which will simply print <span style="font-weight: bold;">&#8220;Hello World&#8221;</span> on your browser screen. For those who have landed up here straight here, you may want to go through this blog post. <a href="http://abhinavsingh.com/blog/2008/10/getting-started-with-symfony-a-php-framework-part-1/">Getting started with Symfony &#8211; A PHP Framework &#8211; Part 1</a> By now if you have decided to go ahead with symfony and use it for your site development, this is what you will be looking for next.</p>
<p>You can download the code for this tutorial from google code base.</p>
<pre style="border: 1px solid rgb(153, 153, 153); padding: 5px; background: rgb(204, 204, 204) none repeat scroll 0% 50%; width: 500px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">svn checkout http://abhinavsingh.googlecode.com/svn/trunk/PHP/<br/>Frameworks/Symfony/Authentication abhinavsingh-read-only
</pre>
<p><span style="font-weight: bold; text-decoration: underline; color: rgb(51, 51, 255);">A Registration-Login-Logout System for your site<br />
</span><span style="color: rgb(0, 0, 0);">This is mostly the first thing you end up building for your site. To be frank, I myself haven&#8217;t made this application. I will make it as I write this blog, and note down all my steps here, so that I don&#8217;t miss any detail.<br />
</span>
<ol>
<li>We will name our project as <span style="font-weight: bold;">Authentication</span></li>
<li>Create a folder called Authentication under the Symfony directory we made in the last tutorial. For me its here <span style="font-weight: bold;">C:\Workspace\Symfony\Authentication</span></li>
<li>Open your command line and point it to the above created folder</li>
<li>Type &#8220;<span style="font-weight: bold;">symfony init-project Authentication</span>&#8221; and it will create same directory structure that we discussed in last tutotial.</li>
<li>Lets create an application inside this, we will name it as <span style="font-weight: bold;">Auth</span></li>
<li>Type &#8220;<span style="font-weight: bold;">symfony init-app Auth</span>&#8221; and it will create an application named Auth under the apps folder. (<span style="font-weight: bold;">C:\Workspace\Symfony\Authentication\apps\Auth)</span></li>
<li>First we need a module called <span style="font-weight: bold;">Registration</span>, to allow our users to register.</li>
<li>Type &#8220;<span style="font-weight: bold;">symfony init-module Auth Registration</span>&#8221; and it will tell symfony to create a module named Registration inside our application Auth</li>
<li>As told in last tutorial copy the <span style="font-weight: bold;">C:\php5\pear\data\symfony\web\sf folder</span> to <span style="font-weight: bold;">C:\Workspace\Symfony\Authentication\web\sf</span>. At the end of this part, we will learn how can we skip this copying again and again</li>
<li>Open <span style="font-weight: bold;">C:\Workspace\Symfony\Authentication\apps\Auth\modules\Registration\actions\actions.class.php</span> and comment out the forwarding as discussed in last tutorial.</li>
<li>Go to your command line and type &#8220;<span style="font-weight: bold;">symfony clear-cache</span>&#8220;. Read why we do this in the last tutorial.</li>
<li>Open <a href="http://localhost/Symfony/Authentication/web/">http://localhost/Symfony/Authentication/web/</a> in your browser and you must get something like this.</li>
</ol>
<p><img src="http://abhinavsingh.com/library/images/symfony-2-1.gif" title="" alt="" style="border: 1px solid rgb(119, 119, 119); padding: 2px;" /><br />
Figure 1</p>
<p>OOPS! Did we missed something? Yes we did and intentionally. We could have gone to C:\Workspace\Symfony\Authentication\apps\Auth\config\routing.yml and redirected our Authentication application to our Registration Module by default. In that case we would have seen an empty page since indexSuccess.php file inside C:\Workspace\Symfony\Authentication\apps\Auth\modules\Registration\templates is empty. But since we didn&#8217;t modified the routing.yml file, it took us to the default module of symfony.<br />
<!-- ADSENSE LEFT TEXT AD --><br />
So how do we access our Registration module without modifying routing.yml file??<br />
<span style="font-weight: bold;">http://localhost/Symfony/Authentication/web/Registration/index</span> is the answer <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>As a convention<br />
<span style="font-weight: bold;">http://localhost/Symfony/Authentication/web/&lt;Module&gt;/&lt;ModuleFile&gt;<br />
</span>this is the standard for symfony.</p>
<p>Hence it went to Registration module and then indexSuccess.php page inside that. Cool so we actually just followed up from our last tutorial till here. Lets now do the actual development.</p>
<p><span style="font-weight: bold; text-decoration: underline; color: rgb(51, 51, 255);">Defining a layout for our website<br />
</span><span style="color: rgb(0, 0, 0);">Before we do any backend stuff, lets atleast get our site out of that blank page (</span><span style="font-weight: bold;">http://localhost/Symfony/Authentication/web/Registration/index)</span><span style="color: rgb(0, 0, 0);">. However, If you view the source of that blank page, you will actually find that there are already some header, css, body tags in the source code. How is this coming? when we have an empty <span style="font-style: italic;">indexSuccess.php</span> file.</p>
<p>From our last tutorial we saw the flow which symfony follows to finally display a page on the browser. But then I actually skipped a step to ease down the tutorial. In symfony we follow the <span style="font-style: italic;">Decorator Design Patterns</span> (I hope i m not wrong here) , to get the front end stuff. Essentially Decorator Design Pattern consists of a Layout and a Content page.</p>
<p>In symfony our layout file is located under at <span style="font-weight: bold;">C:\Workspace\Symfony\Authentication\apps\Auth\templates\layout.php. </span>Open it up and you will know the answer to &#8220;How are those meta tags, head tags and body tags coming&#8221;.</p>
<p>Cool enough. Lets go back to our indexSuccess.php file of Registration module and design our website. With a little CSS and HTML, I came up with this design page for our site. Mostly inspired and stolen from my new site <a href="http://gtalkbots.com">Gtalkbots.com</a></p>
<p></span><img src="http://abhinavsingh.com/library/images/symfony-2-2.gif" title="" alt="" style="border: 1px solid rgb(119, 119, 119); padding: 2px;" /><br />
Figure 2</p>
<p>We will shift a bit of code from this page to our layout.php page later on so that we need now write the same modules again and again. Download all the code, from the my google code vault location given at the beginning and end of this tutorial.</p>
<p><span style="font-weight: bold; text-decoration: underline; color: rgb(51, 51, 255);">Designing the backend database:</span><br />
Now we need&nbsp; a databases schema which will save our registered user&#8217;s data.&nbsp; Lets create our database structure.</p>
<p>As talked about in last tutorial, symfony follows ORM programming technique. For this, they provide a method through which you actually need not go to your database and create tables. Symfony will do that for you. Not only this, Symfony will also allow you to skip most of the SQL queries. Lets see how.</p>
<ol>
<li>Open<span style="font-weight: bold;"> C:\Workspace\Symfony\Authentication\config\schema.yml</span> . From extension we know that symfony follows YAML structures which is similar to XML, but a bit easy to write. We will define our table structures in this file.</li>
<li>Type the following in the schema.yml file:
<pre style="border: 1px solid rgb(153, 153, 153); padding: 5px; background: rgb(204, 204, 204) none repeat scroll 0% 50%; width: 600px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">Propel:
  users:
    id:        { type: integer, primaryKey: true, autoIncrement: true }
    username:  varchar(100)
    emailid:   varchar(100)
    password:  varchar(100)
</pre>
</li>
<li>Note the indentation, it is very very important when you are using YAML. Indentation actually decides how the YAML parsers will read and interpret the information you want to write in .yml files. In our case we have a very simple schema.yml file having only one table. We will learn about what that &#8220;<span style="font-weight: bold;">Propel</span>&#8221; is all about later, but lets focus from line 2.</li>
<li>We are trying to make a table called <span style="font-weight: bold;">users </span>having fields like id, username, emailid and password</li>
<li>Now before Symfony makes this table for you, we need to tell symfony the database username and password. For this we have a configuration file called propel.ini, located at <span style="font-weight: bold;">C:\Workspace\Symfony\yahoo\config\propel.ini</span></li>
<li><span style="font-weight: bold;"></span>Open it and change the lines as below:
<pre style="border: 1px solid rgb(153, 153, 153); padding: 5px; background: rgb(204, 204, 204) none repeat scroll 0% 50%; width: 600px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">propel.database.createUrl  = mysql://root@localhost/
propel.database.url        = mysql://root:password@localhost/authentication
</pre>
<p>Now go to your mysql database and create a database named <span style="font-weight: bold;">authentication,</span> which symfony will use from now on.
</li>
<li>Type &#8220;<span style="font-weight: bold;">symfony propel-build-all</span>&#8221; in your command line. This command will happily create a table named &#8220;users&#8221; in youy MySQL database &#8220;authentication&#8221;. Some of the possible errors which I got in the past are:
<ul>
<li>Your PHP must be compiled with XSLT, hence enable it by going in your php.ini file</li>
<li>In schema.yml file never use TABS. The YAML parsers don&#8217;t understand TABS. User SPACES intead of that.</li>
</ul>
</li>
<li>To cross verify check your database, if the table has been created. Now a bit about Propel.</li>
</ol>
<p>Propel is nothing but a third-party-vendor plugin which Symfony use. It helps in parsing the YAML files, creating and executing the whole ORM module including parsing of schema.yml , creating tables, creating ORM data objects. We will slowly and gradually learn a lot more about ORM.</p>
<p><span style="font-weight: bold; text-decoration: underline; color: rgb(51, 51, 255);">A look at the model layer<br />
</span><span style="color: rgb(0, 0, 0);">Another thing which the propel command did was, it created the whole ORM module. If you go to <span style="font-weight: bold;">C:\Workspace\Symfony\Authentication\lib\model</span> you can see 2 folders being created and a few files too.</p>
<p>For every table, propel build 5 files under the model folder. These files are basically the class files, which will provide use with a database object which we can use to select or insert data in the database.</p>
<p>C:\Workspace\Symfony\Authentication\lib\model\om\BaseUsers.php &amp;<br />
</span><span style="color: rgb(0, 0, 0);">C:\Workspace\Symfony\Authentication\lib\model\om\BaseUsersPeer.php are the only 2 files which will be re-created when you run the propel command again.</p>
<p>The file positioned at<br />
C:\Workspace\Symfony\Authentication\lib\model\Users.php &amp;<br />
</span><span style="color: rgb(0, 0, 0);">C:\Workspace\Symfony\Authentication\lib\model\UsersPeer.php will be as it is from this point in time. If you write your own methods in them, they will remain as it is even when you re-create your database schema.</p>
<p>We will use these created ORM files to insert, delete, select data from the databases. In symfony we can actually skip writing a SQL query (though we can always write a direct query too)</p>
<p></span><span style="font-weight: bold; text-decoration: underline; color: rgb(51, 51, 255);">Writing the backend Code:<br />
</span><span style="color: rgb(0, 0, 0);">With UI and database in shape, its time to write our backend code which will handle the registration form submission. If you notice the source code of our form, the action field is set as :</p>
<p>&lt;form id=&#8221;registration&#8221; action=&#8221;<span style="font-weight: bold;">&lt;?php echo url_for(&#8220;Registration/index&#8221;); ?&gt;</span>&#8221; method=&#8221;POST&#8221;&gt;</p>
<p>In symfony we have a lot of helper functions which we can use. In this case we users url_for helper function, which helps in generating a url with &lt;module&gt;/&lt;modulefile&gt; being passed as parameter.</p>
<p>So we have our form being submitted to indexSuccess.php itself, i.e. SELF.<br />
Hence lets go to executeIndex() method in action.class.php and write the code which will handle the submitted form.</p>
<p>Copy the modified action.class.php file from the vault location. I have documented every line inside the code, which will walk you through the code. Understand the flow and continue reading.</p>
<p>However before we insert any data in the database, we need to give the database parameters. Go to<br />
<span style="font-weight: bold;">C:\Workspace\Symfony\Authentication\config\databases.yml<br />
</span>and uncomment the lines of code in there. Finally it should be of the following structure:</span></p>
<pre style="border: 1px solid rgb(153, 153, 153); padding: 5px; background: rgb(204, 204, 204) none repeat scroll 0% 50%; width: 600px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">all:
  propel:
    class:          sfPropelDatabase
    param:
      dsn:          mysql://root:password@localhost/authentication
</pre>
<p>Lastly open:<br />
<span style="font-weight: bold;">C:\Workspace\Symfony\Authentication\apps\Auth\config\settings.yml<br />
</span>and go to the last line of the file. You will find<br />
<span style="font-weight: bold;"># compat_10&nbsp;&nbsp;&nbsp; off<br />
</span>being commented out<br />
Uncomment it and then turn on compat_10 i.e.<br />
<span style="font-weight: bold;">compat_10&nbsp;&nbsp;&nbsp; on</span><br />
<span style="font-weight: bold;"></span><span style="font-weight: bold;"></span><br />
Clear your cache, before submitting the form (<span style="font-weight: bold;">symfony clear-cache</span>) and then try to register.</p>
<p>If you have followed everything, you will be able to successfully able to register and visit mainSuccess.php of the module.</p>
<p>I have documented all the code which you can download from the vault location. Read it, try it, play with it.</p>
<p><span style="font-weight: bold; color: rgb(255, 0, 0);">PS: The best documentation is available at symfony-project website. This tutorial was intended to </span><br style="font-weight: bold; color: rgb(255, 0, 0);" /><span style="font-weight: bold; color: rgb(255, 0, 0);">build a real life scenario application using Symfony. Though I must admit that I still haven&#8217;t used 100% possible symfony </span><br style="font-weight: bold; color: rgb(255, 0, 0);" /><span style="font-weight: bold; color: rgb(255, 0, 0);">for this application, just to make it simple but still give you a feel of how things flow in symfony.</p>
<p></span><span style="color: rgb(255, 0, 0);"><span style="color: rgb(0, 0, 0);">Leave a comment if you have any doubt or difficulty in implementing the code.</span><br style="color: rgb(0, 0, 0);" /><span style="color: rgb(0, 0, 0);">Do leave a comment even if you like the code <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </span><br />
</span><span style="font-weight: bold; color: rgb(255, 0, 0);"></span></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F10%2Fhow-to-build-a-login-registration-system-using-symfony-a-php-framework-part-2%2F","http:\/\/localhost\/Symfony\/Authentication\/web\/","http:\/\/gtalkbots.com"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA4LzEwL2hvdy10by1idWlsZC1hLWxvZ2luLXJlZ2lzdHJhdGlvbi1zeXN0ZW0tdXNpbmctc3ltZm9ueS1hLXBocC1mcmFtZXdvcmstcGFydC0yLzx3cHRiPkhvdyB0byBidWlsZCBhIGxvZ2luLXJlZ2lzdHJhdGlvbiBzeXN0ZW0gdXNpbmcgU3ltZm9ueSAmIzgyMTE7IEEgUEhQIEZyYW1ld29yayAmIzgyMTE7IFBhcnQgMjx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2008/10/getting-started-with-symfony-a-php-framework-part-1/" title="Getting started with Symfony &#8211; A PHP Framework &#8211; Part 1">Getting started with Symfony &#8211; A PHP Framework &#8211; Part 1</a> (33)</li><li><a href="http://abhinavsingh.com/blog/2009/08/building-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions/" title="Building a Custom PHP Framework with a custom template caching engine using Output Control functions">Building a Custom PHP Framework with a custom template caching engine using Output Control functions</a> (10)</li><li><a href="http://abhinavsingh.com/blog/2008/11/symfony-model-layer-tips-and-tricks-a-php-framework-part-3/" title="Symfony model layer tips and tricks &#8211; A PHP Framework &#8211; Part 3">Symfony model layer tips and tricks &#8211; A PHP Framework &#8211; Part 3</a> (7)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/07/how-to-add-wordpress-like-add_filter-hooks-in-your-php-framework/" title="How to add wordpress like add_filter hooks in your PHP framework">How to add wordpress like add_filter hooks in your PHP framework</a> (18)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2008/10/how-to-build-a-login-registration-system-using-symfony-a-php-framework-part-2/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Getting started with Symfony &#8211; A PHP Framework &#8211; Part 1</title>
		<link>http://abhinavsingh.com/blog/2008/10/getting-started-with-symfony-a-php-framework-part-1/</link>
		<comments>http://abhinavsingh.com/blog/2008/10/getting-started-with-symfony-a-php-framework-part-1/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 12:33:50 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/2008/10/getting-started-with-symfony-a-php-framework-part-1/</guid>
		<description><![CDATA[Hello Friends, Since past few weeks I have been pushed into something which I have never favored i.e. using a framework for my development. Using a framework can become even more harder if you know all the actual HTML, CSS, JS, PHP coding. Then you just wonder WHY? WHY? WHY? Anyways I had to do [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F10%2Fgetting-started-with-symfony-a-php-framework-part-1%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F10%2Fgetting-started-with-symfony-a-php-framework-part-1%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Framework,MVC,ORM,PHP,Symfony&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello Friends,</p>
<p>Since past few weeks I have been pushed into something which I have never favored i.e. using a framework for my development. Using a framework can become even more harder if you know all the actual HTML, CSS, JS, PHP coding. Then you just wonder WHY? WHY? WHY?</p>
<p>Anyways I had to do it using Symfony PHP framework and there was no way out. As I couldn&#8217;t find much help outside <a href="http://symfony-project.com" target="_blank">http://symfony-project.com</a> , it made even more difficult for me to implement and understand symfony.  So I thought of writing a tutorial, which can help many others like me out there and also act as a reference for me in future. Here instead of giving a theory lecture straight up, we will learn along with little hands-on developments.</p>
<p><span style="font-weight: bold; color: #3333ff; text-decoration: underline;">Installation:<br />
</span>Before installing Symfony I assume we already have Apache, PHP 5 and MySQL installed on your system. If you don&#8217;t have them already installed, read this post of mine on how to configure WAMP on your windows. <a href="http://abhinavsingh.com/blog/2008/05/web-development-part-1-apache-mysql-php/">How to Install Apache, PHP 5 and MySQL on Windows?</a></p>
<p>This method works equally on Windows and Unix systems. On windows open your command line and on Unix open a terminal window.</p>
<ol>
<li>Go to My Computer -&gt; Right Click -&gt; Click on Properties -&gt; Advanced Tab -&gt; Environment Variables -&gt; Create a PATH variable if it doesn&#8217;t already exists -&gt; Add C:\PHP\ as the PATH variable value.</li>
<li>Go to Start -&gt; Run -&gt; Type cmd -&gt; Type C:\&gt; pear channel-discover pear.symfony-project.com</li>
<li>Type C:\&gt; pear install symfony/symfony-1.0.18 , it will install symfony latest stable version for you. (1.0 at the time of writing this tutorial)</li>
<li>If you are having trouble installing, post a message here or refer <a href="http://www.symfony-project.org/installation/1_0">http://www.symfony-project.org/installation/1_0</a> for more details.</li>
</ol>
<p>So now you have symfony framework installed and we will learn how to build our first project in symfony.</p>
<p><span style="font-weight: bold; color: #3333ff; text-decoration: underline;">My first Project:</span><br />
Before we go ahead in making our first php project using symfony, just a little theory without which its impossible to understand the flow. Symfony projects are designed as follows:</p>
<p>       My First Project &#8211;&gt; Application 1 &#8212;-&gt; Module 1<br />
                                            |                                        |<br />
                                            |                                        &#8211;&gt; Module 2<br />
                                            |<br />
                                            -&gt; Application 2 &#8212;-&gt; Module 1<br />
                                            |                                       |<br />
                                            |                                        &#8211;&gt; Module 2<br />
                                            |                                       |</p>
<p>                                            |                                        &#8211;&gt; Module 3<br />
                                            |<br />
                                            -&gt; Application 3 &#8212;-&gt; Module 1</p>
<p>So in your <span style="font-weight: bold;">Project</span> your can have <span style="font-weight: bold;">multiple Applications</span> and inside every application you can have <span style="font-weight: bold;">multiple Modules</span>.</p>
<ol>
<li>Go to your Apache Web Folder (Document Root) which in my case is C:\Workspace.</li>
<li>Create a folder called Symfony. We will keep all our symfony related development work in this folder.</li>
<li>Go inside the folder C:\Workspace\Symfony and create another folder for our 1st project. Lets name it HelloWorld</li>
<li>Open your command line and go to the above folder path i.e. type &#8216;cd C:\Workspace\Symfony\HelloWorld&#8217; on your command line.</li>
<li>Type &#8216;symfony init-project HelloWorld&#8217; and press enter. This will automatically create the project directory structure for you. Don&#8217;t be afraid if you see some 10 folders being create by the last command.</li>
</ol>
<p>Don&#8217;t close the command line window, we will need that throughout.</p>
<p>So by now we have our first symfony project folder ready (structurally). But to view this on your browser we need atleast 1 application and atleast 1 module in that application. Lets create them quickly.</p>
<ol>
<li>Type &#8216;symfony init-app HelloWorld&#8217; and press enter. This will create an application folder C:\Workspace\Symfony\HelloWorld\apps\HelloWorld. Now lets create a module inside this application</li>
<li>Type &#8216;symfony init-module HelloWorld HelloWorld&#8217; and press enter. This command means, create a module named HelloWorld inside application HelloWorld. Generic level syntax is &#8216;symfony init-module [application] [module]&#8216;</li>
</ol>
<p>So we have our first symfony project ready. Type <a href="http://localhost/Symfony/HelloWorld/web">http://localhost/Symfony/HelloWorld/web</a> in your browser window and press enter. You will see a page like this:</p>
<p><img style="border: 1px solid #777777; padding: 2px;" src="http://abhinavsingh.com/library/images/symfony-1.gif" alt="" /><br />
Figure 1</p>
<p>But this is not what it should be. If you read the page, it says &#8220;If you see no image in this page, you may need to configure your web server so that it gains access to the symfony_data/web/sf  directory&#8221;.</p>
<p>So all you need is to copy folder C:\php5\pear\data\symfony\web\sf (in my case) to C:\Workspace\Symfony\HelloWorld\web\sf. If you don&#8217;t find sf folder at the specified place, kindly search for it on your system. It was created when we were installing symfony.</p>
<p>After copying the folder refresh your web page again and see if you see any difference. For me it looks like:</p>
<p><img style="border: 1px solid #777777; padding: 2px;" src="http://abhinavsingh.com/library/images/symfony-2.gif" alt="" /><br />
Figure 2</p>
<p>Well Congratulations ! You just made your first symfony project. But unfortunately you know 0% of what did. Right? Lets understand what exactly is going in the background.</p>
<p><span style="font-weight: bold; color: #3333ff; text-decoration: underline;">A bit about MVC Architecture:<br />
</span><span style="color: #333333;">Symfony follows MVC (Model-Viewer-Controller) Architecture to the core. If you haven&#8217;t worked with MVC architectural frameworks before, it can really take sometime to get a feel of it. I took about a week to actually understand what goes in the background.</span></p>
<p>MVC Architecture is nothing but breaking your whole page code into three parts namely Model (Database) , Viewer (Frontend HTML Pages) and Controller (Which fetches data from Model i.e. database and provide it in required format to Viewer i.e. what we finally see on our browsers). This is a very layman definition which I have given. We will slowly and gradually see each aspect of MVC in Symfony.</p>
<p><span style="font-weight: bold; color: #3333ff; text-decoration: underline;">A bit about ORM (Object Relational Mapping):<br />
</span><span style="color: #333333;">This is yet another programming technique which you will find in each and every framework. In layman language, ORM provides you an object to handle your database. You need not write a SQL Query in actual at any point in your project. You will access all your database rows using this ORM Object.</span></p>
<p>Strange it may seem at first, but consider a big project running on MySQL with a lot of INSERT queries. Now at some point in time when database size reaches &gt; 50 Gb or so and you are finding MySQL not efficient enough to handle such a large database, you would want to change to a database like Oracle. In such a scenario, ORM takes all the headache off from you, as you need not care about the actual SQL queries that goes in the background. ORM automatically takes care of this stuff.</p>
<p><span style="font-weight: bold; color: #3333ff; text-decoration: underline;">Understanding Symfony Directory Structure:<br />
</span><span style="color: #333333;">The Symfony directory structure of our first project will look like this:</span></p>
<p><img style="border: 1px solid #777777; padding: 2px;" src="http://abhinavsingh.com/library/images/symfony-3.gif" alt="" /><br />
Figure 3</p>
<p>Remember we still don&#8217;t have anything dealing with the databases, hence I can say that Model layer is still missing from the directory structure. But let us first complete our targeted &#8220;Hello World&#8221; application.</p>
<ol>
<li>Go to HelloWorld/apps/HelloWorld/config folder and open the file rounting.yml</li>
<li>Change the 4th line in that file from &#8211; param: { module: default, action: index } to param: { module: HelloWorld, action: index }</li>
<li>We will learn about all .yml files which you see, but as of now lets focus on what we just did. By default our Symfony project points to a default module created by Symfony. Thats why we see Figure 2 above. By changing the above piece of code, we are telling our HelloWorld application inside HelloWorld project that, by default point to my HelloWorld Module. Confusing! Read the last line again and continue reading <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
<li>Go to HelloWorld/apps/HelloWorld/modules/HelloWorld/actions and open the file actions.class.php</li>
<li>Comment the following php code $this-&gt;forward(&#8216;default&#8217;, &#8216;module&#8217;); inside executeIndex() method.</li>
<li>Go back to your command line and type: &#8216;symfony clear-cache&#8217;</li>
<li>Type <a href="http://localhost/Symfony/HelloWorld/web">http://localhost/Symfony/HelloWorld/web</a> in your browser window and press enter.</li>
</ol>
<p>Bingo! You see a blank white page. Lets understand what we actually did. But before that just a few points on how a page is actually displayed in Symfony.</p>
<ol>
<li>When we type <a href="http://localhost/Symfony/HelloWorld/web">http://localhost/Symfony/HelloWorld/web</a> in our browser, index.php in the web folder goes to routing.yml file</li>
<li>Routing file then tells which module to follow by default. By following Step 2 above, we directed the flow to our HelloWorld module.</li>
<li>Then flow goes to the actions.class.php file of the module provided by Routing file. Hence in our case it must have gone to actions.class.php file of HelloWorld module.</li>
<li>It looks for executeIndex() method in the class file, executes it and</li>
<li>Finally goes to indexSuccess.php file placed under the template folder of our HelloWorld Module.</li>
</ol>
<p>But since our actions class method was already diverting the flow to the default module, flow won&#8217;t have come to step 5 above and would have gone to default symfony module. By commenting out the line in step 5 above, we actually skip this forwarding and the flow comes to indexSuccess.php file under templates module. And finally since indexSuccess.php file is a blank file, we see a blank page. <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Read the above 2 point charts carefully. If you can understand this flow, you already conquered half the symfony.</p>
<p><span style="font-weight: bold; text-decoration: underline;">Note:</span> All this will go waste if you forget &#8216;symfony clear-cache&#8217; in step 6 above. As a rule of thumb, always run this command when ever you make any changes to any of the .yml files.</p>
<p><span style="font-weight: bold; color: #3333ff; text-decoration: underline;">My First Project &#8220;HelloWorld&#8221;</span><br />
Open indexSuccess.php and type &lt;h1&gt;Hello World&lt;/h1&gt; into it. Run <a href="http://localhost/Symfony/HelloWorld/web">http://localhost/Symfony/HelloWorld/web</a> in our browser, and thats it <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  You will see a page like below.</p>
<p><img style="border: 1px solid #777777; padding: 2px;" src="http://abhinavsingh.com/library/images/symfony-4.gif" alt="" /></p>
<p>And with that we completed our Part 1 of this Symfony tutorial series. In upcoming parts of the series we will learn how to manage databases and build a bit more complex application and modules. Post your doubts and comments if any.</p>
<p><span style="color: #cc0000; font-weight: bold;">Note: I am myself learning many parts in Symfony and I myself gather knowledge by experimentation and through various web sources. Hence if a Symfony expert is reading this and find anything wrong, kindly correct me. </span></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F10%2Fgetting-started-with-symfony-a-php-framework-part-1%2F","http:\/\/symfony-project.com","http:\/\/www.symfony-project.org\/installation\/1_0","http:\/\/localhost\/Symfony\/HelloWorld\/web","http:\/\/localhost\/Symfony\/HelloWorld\/web","http:\/\/localhost\/Symfony\/HelloWorld\/web","http:\/\/localhost\/Symfony\/HelloWorld\/web"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA4LzEwL2dldHRpbmctc3RhcnRlZC13aXRoLXN5bWZvbnktYS1waHAtZnJhbWV3b3JrLXBhcnQtMS88d3B0Yj5HZXR0aW5nIHN0YXJ0ZWQgd2l0aCBTeW1mb255ICYjODIxMTsgQSBQSFAgRnJhbWV3b3JrICYjODIxMTsgUGFydCAxPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2008/10/how-to-build-a-login-registration-system-using-symfony-a-php-framework-part-2/" title="How to build a login-registration system using Symfony &#8211; A PHP Framework &#8211; Part 2">How to build a login-registration system using Symfony &#8211; A PHP Framework &#8211; Part 2</a> (37)</li><li><a href="http://abhinavsingh.com/blog/2009/08/building-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions/" title="Building a Custom PHP Framework with a custom template caching engine using Output Control functions">Building a Custom PHP Framework with a custom template caching engine using Output Control functions</a> (10)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/07/how-to-add-wordpress-like-add_filter-hooks-in-your-php-framework/" title="How to add wordpress like add_filter hooks in your PHP framework">How to add wordpress like add_filter hooks in your PHP framework</a> (18)</li><li><a href="http://abhinavsingh.com/blog/2008/11/symfony-model-layer-tips-and-tricks-a-php-framework-part-3/" title="Symfony model layer tips and tricks &#8211; A PHP Framework &#8211; Part 3">Symfony model layer tips and tricks &#8211; A PHP Framework &#8211; Part 3</a> (7)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2008/10/getting-started-with-symfony-a-php-framework-part-1/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>Essential frameworks for web development</title>
		<link>http://abhinavsingh.com/blog/2008/05/essential-frameworks-for-web-development/</link>
		<comments>http://abhinavsingh.com/blog/2008/05/essential-frameworks-for-web-development/#comments</comments>
		<pubDate>Mon, 12 May 2008 12:49:58 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Google Web Toolkit]]></category>
		<category><![CDATA[OpenLaszlo]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Scriptaculous]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/2008/05/essential-frameworks-for-web-development/</guid>
		<description><![CDATA[Hello developers, Initially when I started working on Altertunes, I was unaware of the various frameworks which one can use for his website. Though I never have used any of them for Altertunes (main reason being the eagerness to do everything by myself), but may be some of you out there might be interested in [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F05%2Fessential-frameworks-for-web-development%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F05%2Fessential-frameworks-for-web-development%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Framework,Google+Web+Toolkit,OpenLaszlo,Prototype,Scriptaculous,Web+Development&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello developers,</p>
<p>Initially when I started working on <a href="http://altertunes.com">Altertunes</a>, I was unaware of the various frameworks which one can use for his website. Though I never have used any of them for Altertunes (main reason being the eagerness to do everything by myself), but may be some of you out there might be interested in having a look at the same:</p>
<ul>
<li><a href="http://prototypejs.org/">http://prototypejs.org</a> : Undoubtedly one of the best available framework for Ajax in the market. Prototype is a javascript framework that aims to ease development of dynamic web applications.</li>
<li><a href="http://script.aculo.us/">http://script.aculo.us</a> : If you are looking to have all those fade-in and fade-out effects for your website, probably Scriptaculous does the best for your website. Scriptaculous provides you with <b>easy-to-use</b>, <b>cross-browser</b> user interface <b>JavaScript libraries</b> to make your web sites and web applications fly. Though I am not too sure, but I guess Ruby on Rails already comes packaged with Scriptaculous.</li>
<li><a href="http://prototype-window.xilinus.com/">Prototype Windows Class</a> : Another master piece which allows your website to have all those fancy popups, fade-in and fade-out effect.</li>
<li><a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a> :  Google Web Toolkit (GWT) makes it easier to write high-performance AJAX applications.  You write your<span style="font-weight: bold;"> front end in the Java</span> programming language and GWT compiles your source into highly optimized JavaScript.</li>
</ul>
<p>Probably you will find hundred&#8217;s of them in the market right now. Above I have listed a few which I tried atleast once and got good performance. However there are various factors which decide what Ajax framework you should choose for your site. Most important being:</p>
<div style="margin-left: 30px; margin-right: 30px;">&#8220;It seems that a very light framework is required for a public site. If your visitors need to upload a large Javascript API, they may not visit further your website, depending on your page’s download times. When working on intranets, or professionnal services, it may be acceptable that the first access to the application may be longer, moreover when the website is used daily. Also think about on-demand Javascript and Javascript compression.&#8221; &#8211; by <a href="http://ajaxian.com/archives/choosing-an-ajax-framework">Michael Mahemoff</a></div>
<p>If you are looking to develop your site using flash, then there are again some excellent frameworks available in the market for the same. Two of the best which I know are:<a href="http://openlaszlo.org"><br />
</a>
<ul>
<li><a href="http://openlaszlo.org">OpenLaszlo</a> : OpenLaszlo is an open source platform for creating zero-install web applications with the user interface capabilities of desktop client software. OpenLaszlo programs are written in XML and JavaScript and transparently compiled to Flash and DHTML<a style="color: rgb(0, 0, 0);" href="http://www.openlaszlo.org/advancedajax"></a>. The <a href="http://altertunes.com/alterplayer">Alterplayer</a> used on Altertunes, was developed by me using OpenLaszlo. I am open for any suggestion or question you need for development in OpenLaszlo.</li>
<li><a href="http://www.osflash.org/red5">Red5</a> : It is an opensource flash server written in Java that supports Streaming audio and video, recording client streams and many other useful things which openlaszlo fails to do currently. So if you are looking to develop a voice chat application, Red5 is the way to go.</li>
</ul>
<p>Above are just a few which I found useful on my way to Altertunes. There are several more untouched by me, which might be more powerful than the those I have listed above. If you find any, kindly post the same as comment here.</p>
<p>Happy Frameworking and web developement <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F05%2Fessential-frameworks-for-web-development%2F","http:\/\/altertunes.com","http:\/\/prototypejs.org\/","http:\/\/script.aculo.us\/","http:\/\/prototype-window.xilinus.com\/","http:\/\/code.google.com\/webtoolkit\/","http:\/\/ajaxian.com\/archives\/choosing-an-ajax-framework","http:\/\/openlaszlo.org","http:\/\/openlaszlo.org","http:\/\/www.openlaszlo.org\/advancedajax","http:\/\/altertunes.com\/alterplayer","http:\/\/www.osflash.org\/red5"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA4LzA1L2Vzc2VudGlhbC1mcmFtZXdvcmtzLWZvci13ZWItZGV2ZWxvcG1lbnQvPHdwdGI%2BRXNzZW50aWFsIGZyYW1ld29ya3MgZm9yIHdlYiBkZXZlbG9wbWVudDx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2008/10/how-to-create-a-single-button-flash-audio-player-using-openlaszlo/" title="How to create a single button flash audio player using Openlaszlo?">How to create a single button flash audio player using Openlaszlo?</a> (4)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/08/building-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions/" title="Building a Custom PHP Framework with a custom template caching engine using Output Control functions">Building a Custom PHP Framework with a custom template caching engine using Output Control functions</a> (10)</li><li><a href="http://abhinavsingh.com/blog/2009/07/how-to-add-wordpress-like-add_filter-hooks-in-your-php-framework/" title="How to add wordpress like add_filter hooks in your PHP framework">How to add wordpress like add_filter hooks in your PHP framework</a> (18)</li><li><a href="http://abhinavsingh.com/blog/2009/07/getting-started-with-openlaszlo-framework-for-developing-flash-apps/" title="Getting started with Openlaszlo &#8211; Framework for developing flash apps">Getting started with Openlaszlo &#8211; Framework for developing flash apps</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2008/05/essential-frameworks-for-web-development/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

