<?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>On Tech and Software &#187; symfony</title>
	<atom:link href="http://jmgtan.com/tag/symfony/feed/" rel="self" type="application/rss+xml" />
	<link>http://jmgtan.com</link>
	<description>Random thoughts on technology, ventures, algorithms, frameworks, gadgets and THE MAN</description>
	<lastBuildDate>Fri, 02 Jul 2010 11:14:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Upgrading to Symfony 1.4 from PEAR based 1.2</title>
		<link>http://jmgtan.com/2010/01/03/upgrading-to-symfony-1-4-from-pear-based-1-2/</link>
		<comments>http://jmgtan.com/2010/01/03/upgrading-to-symfony-1-4-from-pear-based-1-2/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 02:26:45 +0000</pubDate>
		<dc:creator>Jan Michael Tan</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jmgtan.com/?p=199</guid>
		<description><![CDATA[I&#8217;ve been working on a project, which started on 1.2.7, for almost 6 months now and have been upgrading it religiously along the 1.2.x branch which stopped at 1.2.10. We&#8217;re currently entering the testing stage, and being as curious as I am opted to create a 1.4 branch from the current trunk and started the [...]]]></description>
			<content:encoded><![CDATA[<p></p>
<p>I&#8217;ve been working on a project, which started on 1.2.7, for almost 6 months now and have been upgrading it religiously along the 1.2.x branch which stopped at 1.2.10. We&#8217;re currently entering the testing stage, and being as curious as I am opted to create a 1.4 branch from the current trunk and started the upgrade process while merging fixes from the trunk as fixes come in. We&#8217;re using the PEAR-based approach which allows us to quickly upgrade the base installation as soon as a new release comes in. Although i&#8217;m planning to migrate it to the subversion approach soon, but thats another blog post.</p>
<p><span id="more-199"></span></p>
<p>So lets start with the upgrade, symfony 1.4 and 1.3 is basically the same feature-wised but the former lacks the backwards compatibility that the latter provides, basically 1.3 is just a stepping stone to upgrade to 1.4. The Symfony team really did a great job on the seamless upgrade process. Also to have a better background on the upgrade process read the upgrade document from their website (<a href="http://www.symfony-project.org/tutorial/1_4/en/upgrade" target="_blank">http://www.symfony-project.org/tutorial/1_4/en/upgrade</a>). Ok, so lets start with the upgrade.</p>
<p>Lets uninstall symfony 1.2</p>
<pre class="brush: bash;">

pear uninstall symfony/symfony
</pre>
<p>Then install symfony 1.3</p>
<pre class="brush: bash;">

pear install symfony/symfony-1.3.1
</pre>
<p>Once installed, make sure to upgrade the plugins, rebuild the models, and clear the cache to make sure you&#8217;re using the new files. Now you can opt to continue upgrading to 1.4 and drop the backwards compatibility or just stick with 1.3 for the time being, both of which are being supported but 1.4 is a LTS release, meaning that it has a longer support period than 1.3. Before upgrading to 1.4 it is important to remove old class files, symfony provides a build-in task to ease the transition. Just execute this command and symfony will list down all of the deprecated stuff that should be remove/modified, they also provided documentation on what to replace the deprecated stuff with (<a href="http://www.symfony-project.org/tutorial/1_4/en/deprecated" target="_blank">http://www.symfony-project.org/tutorial/1_4/en/deprecated</a>)</p>
<pre class="brush: bash;">

symfony project:validate
</pre>
<p>So now that you&#8217;ve removed/modified all of the deprecated stuff, upgrading is quite similar to 1.3.</p>
<p>Remove the old symfony installation</p>
<pre class="brush: bash;">

pear uninstall symfony/symfony
</pre>
<p>Install the new one</p>
<pre class="brush: bash;">

pear install symfony/symfony-1.4.1
</pre>
<p>Then just clear the cache. Also the freeze/unfreeze task has been removed in 1.4; it may or may not be important to you but I use it when deploying to our servers, one quick fix is to just create a lib/vendor folder and copy/paste the symfony folder found in your PEAR installation folder, and then modifying the include call in the config/ProjectConfiguration.class.php file. So now you have a easily upgradable and independent symfony installation inside your app.</p>
<p></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fjmgtan.com%2F2010%2F01%2F03%2Fupgrading-to-symfony-1-4-from-pear-based-1-2%2F&amp;linkname=Upgrading%20to%20Symfony%201.4%20from%20PEAR%20based%201.2"><img src="http://jmgtan.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jmgtan.com/2010/01/03/upgrading-to-symfony-1-4-from-pear-based-1-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Symfony Doctrine or Propel</title>
		<link>http://jmgtan.com/2009/09/10/symfony-doctrine-or-propel/</link>
		<comments>http://jmgtan.com/2009/09/10/symfony-doctrine-or-propel/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 12:22:08 +0000</pubDate>
		<dc:creator>Jan Michael Tan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[propel]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://jmgtan.com/?p=173</guid>
		<description><![CDATA[Been giving this alot of thought lately. What to use for my next project. Ever since symfony 1.2&#8242;s move to Propel 1.3, the major argument of speed against Propel has been solved with its migration out of creole and into PDO. So speed is definitely at par with Doctrine, but the curious side of me [...]]]></description>
			<content:encoded><![CDATA[<p></p>
<p>Been giving this alot of thought lately. What to use for my next project. Ever since symfony 1.2&#8242;s move to Propel 1.3, the major argument of speed against Propel has been solved with its migration out of creole and into PDO. So speed is definitely at par with Doctrine, but the curious side of me wishes to delve into something new to mix things up a bit.</p>
<p>What to use? Doctrine or Propel?</p>
<p></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fjmgtan.com%2F2009%2F09%2F10%2Fsymfony-doctrine-or-propel%2F&amp;linkname=Symfony%20Doctrine%20or%20Propel"><img src="http://jmgtan.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jmgtan.com/2009/09/10/symfony-doctrine-or-propel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Symfony Forms Tutorial: Quick Registration Form</title>
		<link>http://jmgtan.com/2009/07/09/symfony-forms-tutorial-quick-registration-form/</link>
		<comments>http://jmgtan.com/2009/07/09/symfony-forms-tutorial-quick-registration-form/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 09:27:23 +0000</pubDate>
		<dc:creator>Jan Michael Tan</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jmgtan.com/?p=148</guid>
		<description><![CDATA[I was initially skeptical about these numerous form frameworks that are coming out, I would initially opt to create forms and validations the old fashion way, but after giving symfony forms a shot; I can honestly say i&#8217;m converted! Lets start the tutorial by creating a basic registration form with a captcha. I would assume [...]]]></description>
			<content:encoded><![CDATA[<p></p>
<p>I was initially skeptical about these numerous form frameworks that are coming out, I would initially opt to create forms and validations the old fashion way, but after giving symfony forms a shot; I can honestly say i&#8217;m converted! Lets start the tutorial by creating a basic registration form with a captcha. I would assume you know the basics of symfony if not go to their website (<a title="Symfony" href="http://www.symfony-project.org" target="_blank">http://www.symfony-project.org</a>) and check out their tutorial.</p>
<p><span id="more-148"></span></p>
<p>After setting up the project, app and modules we will install the plugin sfFormExtraPlugin so we can use ReCaptcha:</p>
<pre class="brush: bash;">
symfony plugin:install sfFormExtraPlugin
</pre>
<p>After that, go to <a title="ReCaptcha" href="http://www.recaptcha.net" target="_blank">http://www.recaptcha.net</a> and register to acquire a public and private key; we&#8217;ll use that later. Now lets start creating the form class</p>
<pre class="brush: php;">
class RegistrationForm extends sfForm {
const PUBLIC_KEY = 'PASTE YOUR PUBLIC KEY FROM RECAPTCHA';
const PRIVATE_KEY = 'PASTE YOUR PRIVATE KEY FROM RECAPTCHA';

public function configure() {
$this-&gt;setWidgets(array(
'username'=&gt;new sfWidgetFormInput(array(), array('size'=&gt;32)),
'password'=&gt;new sfWidgetFormInputPassword(array(), array('size'=&gt;32)),
'confirm_password'=&gt;new sfWidgetFormInputPassword(array(), array('size'=32)),
'email'=&gt;new sfWidgetFormInput(array(), array('size'=&gt;32)),
'captcha'=&gt;new sfWidgetFormReCaptcha(array(
'public_key'=&gt;self::PUBLIC_KEY
))
));

$this-&gt;widgetSchema-&gt;setNameFormat('register[%s]'); //this acts as a namespace and also will be use later for binding POST

$this-&gt;setValidators(array(
'username'=&gt;new sfValidatorString(array('max_length'=&gt;50), array('max_length'=&gt;'Max length of username is 50')),
'password'=&gt;new sfValidatorString(),
'confirm_password'=&gt;new sfValidatorString(),
'email'=&gt;new sfValidatorEmail(),
'captcha'=&gt;new sfValidatorReCaptcha(array('private_key' =&gt; self::PRIVATE_KEY), array('captcha' =&gt; 'Didn\'t match captcha'))
));

$this-&gt;validatorSchema-&gt;setPostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'confirm_password', array(), array('invalid' =&gt; 'Passwords do not match')));

$this-&gt;widgetSchema-&gt;setLabels(array(
'username'=&gt;'Username',
'password'=&gt;'Password',
'confirm_password'=&gt;'Confirm Password',
'email'=&gt;'Email Address',
'captcha'=&gt;'Captcha'
));
}
}
</pre>
<p>The code in your actions.class.php would be as follows</p>
<pre class="brush: php;">
public function executeRegister(sfWebRequest $r) {
$this-&gt;form = new RegistrationForm();
if($r-&gt;isMethod('post')) {
$captcha = array(
'recaptcha_challenge_field' =&gt; $request-&gt;getParameter('recaptcha_challenge_field'),
'recaptcha_response_field'  =&gt; $request-&gt;getParameter('recaptcha_response_field'),
);

$this-&gt;form-&gt;bind(array_merge($request-&gt;getParameter('register'), array('captcha' =&gt; $captcha)));
if($this-&gt;form-&gt;isValid()) {
$values = $this-&gt;form-&gt;getValues(); //associative array of values
//you can access the POST data like $values['username'] or $values['email']
//do database insertion or other processsing here
}
}
}
</pre>
<p>And lastly displaying the form in your corresponding template would be as follows</p>
<pre class="brush: php;">
&amp;lt;?php echo $form ?&gt;
</pre>
<p>In the next article, we would be discussing how to customize your form layout.</p>
<p></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fjmgtan.com%2F2009%2F07%2F09%2Fsymfony-forms-tutorial-quick-registration-form%2F&amp;linkname=Symfony%20Forms%20Tutorial%3A%20Quick%20Registration%20Form"><img src="http://jmgtan.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jmgtan.com/2009/07/09/symfony-forms-tutorial-quick-registration-form/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
