<?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>I-Am-Bot &#187; php</title>
	<atom:link href="http://iambot.net/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://iambot.net</link>
	<description>Code, technology and life</description>
	<lastBuildDate>Tue, 10 Jan 2012 03:40:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Symfony2 form theme for Bootstrap</title>
		<link>http://iambot.net/2011/11/symfony2-form-theme-for-bootstrap/</link>
		<comments>http://iambot.net/2011/11/symfony2-form-theme-for-bootstrap/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 07:25:00 +0000</pubDate>
		<dc:creator>Srinath</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://iambot.net/?p=523</guid>
		<description><![CDATA[Symfony2 is a flexible, fast and secure PHP 5 framework for developing modern applications. This post assumes you already know the basics of working with Symfony. Symfony2 has a very powerful templating engine in the form of Twig, a simple templating engine much like the popular Mustache. Twig allows non programmers to quickly design HTML [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><a href="http://symfony.com"><em>Symfony2</a> is a flexible, fast and secure PHP 5 framework for developing modern applications. This post assumes you already know the basics of working with Symfony.</em></p></blockquote>
<p>Symfony2 has a very powerful templating engine in the form of <a href="http://symfony.com/doc/current/book/templating.html">Twig</a>, a simple templating engine much like the popular Mustache. Twig allows non programmers to quickly design HTML layouts without the need to write PHP code. It also makes working with forms a breeze, and all that is needed to output a form on a template is</p>
<p><code>form_widget(form)</code></p>
<p>However, styling the form to suit your need takes a bit more effort. Symfony does allow your application to have different <a href="http://symfony.com/doc/2.0/cookbook/form/form_customization.html">form themes</a> which can be then be applied to various forms. It involves overriding various blocks to render different parts of the form. The problem is in finding which blocks to edit, and which to leave alone. This post can serve as a theme to render forms styled like the ones in <a href="http://twitter.github.com/bootstrap/">Bootstrap</a>.</p>
<p>When drawing a form using the <code>form_widget(form)</code> or <code>form_row(form.field)</code>, Symfony uses the default theme that is defined in the file <a href="https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig">form_div_layout.html.twig</a>. This file contains the various block definitions that are called when you use the appropriate twig function. For example, when you simply call <code>form_widget(form)</code>, you can see how it in turn calls <code>field_rows(form)</code>, which then renders the form errors, and for every field in the form, calls the corresponding widget block.</p>
<p>For Bootstrap's theme, we will override 3 blocks, and define one macro to display errors from the form.</p>
<p>We first define the macro hasErrors to check if the current field has an error, in which case the string "error" is returned which is appended to the class of the input div for the field to be rendered as an error field</p>
<p><code>/src/Acme/DemoBundle/Resources/views/Form/macro.html.twig</code></p>
<pre class="brush: xml; title: ; notranslate">
{% macro hasErrors(field) %}
    {% if form_errors(field)|length &gt; 1 %}
        {{ 'error' }}
    {% endif %}
{% endmacro %}
</pre>
<p>Then, we redefine the field_rows block and do not display the error messages at the beginning of the form</p>
<p><code>/src/Acme/DemoBundle/Resources/views/Form/theme.html.twig</code></p>
<pre class="brush: xml; title: ; notranslate">
{% block field_rows %}
{% spaceless %}
    {% for child in form %}
        {{ form_row(child) }}
    {% endfor %}
{% endspaceless %}
{% endblock field_rows %}
</pre>
<p>Next, we define the custom field_row block that actually renders the HTML for each field. We define the container div for each input field, and call the hasErrors macro to check if Symfony has returned an error for that field. If yes, the class "error" will be added to the class attribute, and the entire field will be highlighted in red to indicate an error. We then echo the error after the field, just like in Bootstrap. Notice how we are passing the global _context object to the form_widget block. By default, you can pass custom attributes to the form_widget block and not to the field_row block. This is done so that we can add custom attributes to each input field, as shown in the example at the end.</p>
<p><code>/src/Acme/DemoBundle/Resources/views/Form/theme.html.twig</code></p>
<pre class="brush: xml; title: ; notranslate">
{% block field_row %}
{% spaceless %}
    {% if macro is not defined %}
        {% import 'AcmeDemoBundle:Form:macro.html.twig' as macro %}
    {% endif %}
    &lt;div class=&quot;clearfix {{macro.hasErrors(form)}}&quot;&gt;
        {{ form_label(form) }}
        &lt;div class=&quot;input&quot;&gt;
            {{ form_widget(form, _context) }}
            {{ form_errors(form) }}
        &lt;/div&gt;
    &lt;/div&gt;
{% endspaceless %}
{% endblock field_row %}
</pre>
<p>We have defined the actual macro, but we now have to customize the error display. That is done in the field_errors block</p>
<p><code>/src/Acme/DemoBundle/Resources/views/Form/theme.html.twig</code></p>
<pre class="brush: xml; title: ; notranslate">
{% block field_errors %}
{% spaceless %}
    {% if errors is defined and errors|length &gt; 0 %}
        {% for error in errors %}
        &lt;span class=&quot;help-inline error&quot; style=&quot;float:right;width:170px;margin-top:5px;&quot;&gt;{{ error.messageTemplate|trans(error.messageParameters, 'validators') }}&lt;/span&gt;
        {% endfor %}
    {% endif %}
{% endspaceless %}
{% endblock field_errors %}
</pre>
<p>That's it! We have now created a custom form theme! To use this, just include the following twig block before drawing the theme</p>
<pre class="brush: xml; title: ; notranslate">
{% form_theme form 'AcmeDemoBundle:Form:theme.html.twig' %}
{{ form_row(form.name, { 'attr': {'class':'xlarge','placeholder':'Please enter your name'} }) }}
{{ form_row(form.description, {'attr': {'class':'xlarge'} }) }}
{{ form_rest(form) }}
</pre>
<p>We are using the form_row block to render each field, so that we can also pass along custom attributes to each field, just like the form_widget block <code>{{ form_widget(form.task, { 'attr': {'class': 'task_field'} }) }}</code>. However, if we use <code>form_widget(form)</code>, then custom attributes cannot be passed to individual fields, but the theme will be rendered nevertheless. Passing custom attributes is particularly useful to adjust the width, height, placeholder, etc of the fields.</p>
<p>That's it! You can define various themes for different parts of your application in a similar fashion, and simply set the appropriate theme with the <code>form_theme</code> directive before rendering a form. Have fun theming forms in Symfony2!</p>
]]></content:encoded>
			<wfw:commentRss>http://iambot.net/2011/11/symfony2-form-theme-for-bootstrap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpUserAuth Released!</title>
		<link>http://iambot.net/2010/07/phpuserauth-released/</link>
		<comments>http://iambot.net/2010/07/phpuserauth-released/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 02:04:13 +0000</pubDate>
		<dc:creator>Srinath</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://iambot.net/?p=426</guid>
		<description><![CDATA[It's finally done! The package is up for grabs, with a quick starter guide. Details Download Demo Please go through the project page for more details! The Readme.txt file inside folder "readme" contains instructions for installation and usage Leave your comments/questions/suggestions on the project page. Out.]]></description>
			<content:encoded><![CDATA[<p>It's finally done! The package is up for grabs, with a quick starter guide.</p>
<p><strong><a href="http://iambot.net/projects/phpuserauth/">Details</a></strong></p>
<p><strong><a href="http://iambot.net/dScript/download.php?fname=./phpuserauth.zip">Download</a></strong></p>
<p><strong><a href="http://iambot.net/demo/phpuserauth/">Demo</a></strong></p>
<p>Please go through the project page for more details!</p>
<p>The Readme.txt file inside folder "readme" contains instructions for installation and usage</p>
<p>Leave your comments/questions/suggestions on the project page.</p>
<p>Out.</p>
]]></content:encoded>
			<wfw:commentRss>http://iambot.net/2010/07/phpuserauth-released/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Introducing phpUserAuth</title>
		<link>http://iambot.net/projects/phpuserauth/</link>
		<comments>http://iambot.net/projects/phpuserauth/#comments</comments>
		<pubDate>Sun, 23 May 2010 03:23:44 +0000</pubDate>
		<dc:creator>Srinath</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://iambot.net/?p=383</guid>
		<description><![CDATA[Update: Please visit the project page for more details After weeks of fighting with myself, I finally got down to work on something that has been on my mind for sometime now. Yes, it is yet another user authentication/management system in PHP. There are already some great ones out there, and some not so good [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update: Please visit the <a href="http://iambot.net/projects/phpuserauth/">project page</a> for more details</strong></p>
<p>After weeks of fighting with myself, I finally got down to work on something that has been <a href="http://iambot.net/2010/03/status-update/">on my mind</a> for sometime now. Yes, it is <em>yet</em> another user authentication/management system in PHP. There are already some great ones out there, and some not so good ones. I wanted a system that was secure, flexible, and easy to work with. What took me an entire week of effort is presented below. Without further delay, presenting <strong>phpUserAuth</strong></p>
<p><strong>Features</strong></p>
<ul>
<li> Secure with support for sessions based and/or cookie based authentication</li>
<li> Tons of configuration option for those who know what they are doing. For others, its easy as a cake!</li>
<li> Passwords are *always* hashed before they are sent over the network, with fallback to plain text if JavaScript is not supported in the browser</li>
<li> Only salted, hashed passwords are saved in the database. Even if the DB is stolen, it is almost impossible to get the original password</li>
<li> Support for multiple simultaneous sessions or a single active session </li>
<li> Administrator can choose how users are activated after they signup. It can be automatic activation, manual activation by the admin, or an activation mail can be sent to the user </li>
<li> Password is <strong>NEVER</strong> sent over the email. If the user forgets his password, he can request a password reset mail. </li>
<li> User defined access control levels</li>
<li> Flexible. If the administrator wants to add another field, simply updated the configuration file, and put the field in the signup form! The rest is taken care of by the script!</li>
<li> Prevention from XSS attacks - all data sent to the server is cleaned using the excellent <a href="http://www.phpclasses.org/package/2189-PHP-Filter-out-unwanted-PHP-Javascript-HTML-tags-.html">InputFilter</a> class</li>
<li> Support for template based HTML email notifications with changeable templates</li>
<li> Emailing done through the excellent <a href="http://sourceforge.net/projects/phpmailer/">PHPMailer</a> with support for SMTP+SSL</li>
<li> Custom redirection after login/logout </li>
<li> Pre-designed forms </li>
<li> Snap in install - Simply drop the folder into your existing application, configure a few site options and database settings, and you are done! </li>
</ul>
<p><strong>Requirements</strong></p>
<ul>
<li> PHP 5+ as the core classes are OO </li>
<li> MySQLi support </li>
<li> MySQL 5+ database server </li>
</ul>
<p>Is that too much to ask? That being said, if you run a fairly recent server, all these should be there by default. For testing, you can check out <a href="http://apachefriends.org">XAMPP</a> which is available for Windows, Mac and Linux!</p>
<p><strong> License </strong><br />
I'm planning to release it under some open source license. If that doesn't work out, it will still be <strong>FREE</strong></p>
<p><strong> Download </strong><br />
It is not <em>completely</em> done yet. The admin area needs some work. So it will be released, when its done</p>
<p><strong> Notes</strong><br />
1) As always, it isn't perfect! If you find any bugs, errors, or know a way where things can be done better, please leave a comment!<br />
2) The application hasn't been profiled yet. There WILL be places where I might have  complicated things. Will be taken care of after its been released</p>
]]></content:encoded>
			<wfw:commentRss>http://iambot.net/projects/phpuserauth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Symfony is THE PHP Framework to work with</title>
		<link>http://iambot.net/2009/07/symfony-framework/</link>
		<comments>http://iambot.net/2009/07/symfony-framework/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 03:43:57 +0000</pubDate>
		<dc:creator>Srinath</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://iambot.net/?p=162</guid>
		<description><![CDATA[I've spent the last few days fruitfully, searching and comparing the most popular and promising of PHP frameworks. Before I get started, I know the automatic follow up will be PHP bashing, and hailing RoR as the savior of the world. This post isn't about a rails vs PHP comparison, though I intend to write [...]]]></description>
			<content:encoded><![CDATA[<p>I've spent the last few days fruitfully, searching and comparing the most popular and promising of PHP frameworks. Before I get started, I know the automatic follow up will be PHP bashing, and hailing RoR as <a href="http://www.prospotlight.com/pro/webdeveloper/website/ruby-on-rails-vs-php.html">the savior of the world</a>. This post isn't about a rails vs PHP comparison, though I intend to write on that shortly.</p>
<p><span id="more-162"></span></p>
<p>Anyone looking for a complete PHP framework will have definitely stumbled across these four major options</p>
<ul>
<li><a href="http://www.zend.com/en/">Zend</a> - <span style="text-decoration: line-through;">The original PHP framework that started it all</span> (Apparently CakePHP came earlier than Zend)</li>
<li><a href="http://cakephp.org/">Cake PHP</a> - Easy and light with support for both PHP 4.1+ and PHP 5+</li>
<li><a href="http://codeigniter.com">Codeigniter</a> - Relatively new lightweight framework</li>
<li><a href="http://symfony-project.org">Symfony</a> - Rails inspired, comprehensive</li>
</ul>
<p>Although there are many more frameworks out there in the wild, these are the most popular and actively developed. As you guessed, this post is about Symfony and why I think its the best. Calling something "the best" is sure to draw a lot of fire from all quarters, so I'll omit it hereon</p>
<p><strong>The Good:</strong></p>
<ul>
<li>Feature Rich - Has all the features one expects from a RAD framework - MVC design pattern, ORM tools, scaffolding, caching, authentication, internalization and localization</li>
<li>Actively Developed - The team not only works on the framework, it also incorporates suggestions/enhancements from community members</li>
<li>Extensive Plugin Repository - It has <strong>647 </strong>plugins from 283 contributors</li>
<li>Amazing Documentation - I can't stress on this enough. Documentation makes ALL the difference when you are spoilt for choice. In addition to the complete API reference, you have "The Book" which is a complete reference to learn Symfony step by step. Then there are the real world examples - Jobeet.com tutorial which guides you in making a Complete working website in 24 days (1 hour a day). And yes, you can check out the site <a href="http://jobeet.com">here<br />
</a> Then, you have the customary "Create a blog in 1 hour" tutorial, and another one that makes the admin interface</li>
<li>Flexible - There are always two ways to do something using Symfony. For ORM, you have doctrine and propel. For javascript you can use prototype(inbuilt), jQuery or Mootools. Supports XCache, eAccelerator, APC , Memcached for caching.</li>
<li>Automatic Admin Generation - Borrowed from Rails, this module makes it a breeze to generate a  optimized and fully functional CRUD interface for your applications. And yes, it does work perfectly well</li>
<li>Extensive developer tools - Symfony supports three deployment environments, along with very good developer tools that lets you configure, debug and monitor your application performance from the web page itself.</li>
<li>Integrated Testing Framework - The "Lime" toolkit allows for unit and functional tests to be written and executed with minimal fuss</li>
<li>Rails Inspired - Need I say more?</li>
</ul>
<p><strong>The Not So Good:</strong></p>
<ul>
<li>It is NOT a small and light framework. But I don't think you can consider 20 MB too large these days, comparing with RoR</li>
<li>Learning Curve - Don't use it if you want to finish your application yesterday. It takes time to learn how to use it, due to its strict adherence to coding standards and quality. If you are an experience programmer though, you will find it easier</li>
<li>Needs optimization - Even though it isn't a pain to optimize unlike RoR, it still needs some work like setting up caching, and using Memcached for database objects if you want to deploy a real world application on it. But then good documentation is available for that too</li>
<li>Its NOT for everyone - This is general to all frameworks. No framework, RoR included, is a "one-size-fits-all" deal. So before you decide to take the plunge, design your application, and put considerable time into thinking if you really need a framework. If all you need is a standard blogging engine, or a normal website with a couple of dynamic scripts, ANY framework in ANY language will be an overkill.</li>
</ul>
<p>If you can live with the above three points, then Symfony is for you. Even though I'm a complete beginner, I've started to love Symfony. I'm sure you will too, if you look at it objectively. So <a href="http://www.symfony-project.org/installation">install it</a>, <a href="http://www.symfony-project.org/doc/1_2/">learn it</a> and have fun!</p>
<p>Edit: Found another great post - <a href="http://www.mellowmorning.com/2007/08/18/ten-reasons-why-symfony-rocks-part-1/">http://www.mellowmorning.com/2007/08/18/ten-reasons-why-symfony-rocks-part-1/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://iambot.net/2009/07/symfony-framework/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Simple PHP calendar with inline edit</title>
		<link>http://iambot.net/2009/07/simple-php-calendar-with-inline-edit/</link>
		<comments>http://iambot.net/2009/07/simple-php-calendar-with-inline-edit/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 09:01:39 +0000</pubDate>
		<dc:creator>Srinath</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://iambot.net/?p=148</guid>
		<description><![CDATA[I was working on a project which required a simple calendar with inline edit. The calendar is for a school which marks if the day is working or not, and the comment (told ya, its very simple). Needs PHP, jQuery, jQuery jEditable plugin and a MySQL table to store the data. The demo is here. [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a project which required a simple calendar with inline edit. The calendar is for a school which marks if the day is working or not, and the comment (told ya, its very simple). Needs PHP, jQuery, jQuery jEditable plugin and a MySQL table to store the data.</p>
<p>The demo is <a href="http://iambot.net/demo/calendar/" target="_blank">here</a>. If anyone is interested in the code, drop a comment.</p>
<p>P.S: Yea I suck at CSS. If anyone does a better job, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://iambot.net/2009/07/simple-php-calendar-with-inline-edit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

