<?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>Rob Rosenbaum&#039;s Development Blog</title>
	<atom:link href="http://robrosenbaum.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://robrosenbaum.com</link>
	<description>PHP, JavaScript, and Other Things</description>
	<lastBuildDate>Mon, 12 Mar 2012 21:51:40 +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>HOWTO: Force Package Removal in Ubuntu/Debian</title>
		<link>http://robrosenbaum.com/linux/howto-force-package-removal-in-ubuntudebian/</link>
		<comments>http://robrosenbaum.com/linux/howto-force-package-removal-in-ubuntudebian/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 14:10:10 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://robrosenbaum.com/linux/howto-force-package-removal-in-ubuntudebian/</guid>
		<description><![CDATA[sudo dpkg -r --force-depends <package>]]></description>
			<content:encoded><![CDATA[<p>If you need to remove a package without removing dependent packages, here is the command you need:</p>
<p>sudo dpkg -r &#8211;force-depends</p>
<p>I have no idea why this is so hard to find &#8211; you could spend an hour reading the dpkg man page and never figure it out, and most posts on forums don&#8217;t seem to even understand this issue. There seems to be an attitude that you shouldn&#8217;t do this, as though you are morally bound to rules about what software you may and may not have on your own computer. I have on several occasions had to completely remove and reinstall corrupted files. The only logical way to do this is to ignore dependency warnings. Besides, I use Linux because I don&#8217;t like people making rules about what I ought to do with my own machine. I hope this post helps someone in the same fix as I am.</p>
]]></content:encoded>
			<wfw:commentRss>http://robrosenbaum.com/linux/howto-force-package-removal-in-ubuntudebian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOWTO: Disable Session Timeout in Symfony</title>
		<link>http://robrosenbaum.com/php/howto-disable-session-timeout-in-symfony/</link>
		<comments>http://robrosenbaum.com/php/howto-disable-session-timeout-in-symfony/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 14:10:10 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://robrosenbaum.com/php/howto-disable-session-timeout-in-symfony/</guid>
		<description><![CDATA[Tell Symfony to expire sessions when the browser closes.]]></description>
			<content:encoded><![CDATA[<p>The problem: make symfony use PHP&#8217;s default session behavior.<br />
Symfony session handling is based on timed sessions &#8211; you set a time<br />
after which the session will expire &#8211; but the default PHP behavior is to<br />
 expire when the user closes the browser window. This is also the most<br />
commonly desired behavior for sessions. The drawback of using a timed<br />
session is that it could expire while the user is still on the site.<br />
This is an issue in <a href="http://web.archive.org/web/20091218091208/http://www.lecturetools.org/">LectureTools</a>,<br />
 because students may sit for an hour or more without loading a new<br />
page, and they may even have logged in before class. You can solve this<br />
little problem easily if you are using symfony 1.1 (currently in beta).<br />
Just set the timeout to <code>false</code> in settings.yml:</p>
<pre class="YAML">all:
  .settings:
    timeout:    false
</pre>
<p>But if you are using the stable 1.0 branch of symfony, this will do just<br />
 the opposite &#8211; it will make your sessions time out immediately! To make<br />
 this work, we have to override <code>sfBasicSecurityUser</code>&#8216;s <code>initialize()</code> method. I will describe two ways<br />
to do this; one is a short hack, the other is longer and somewhat more proper.</p>
<p class="leadingnoindent">Here&#8217;s the short way:</p>
<pre class="PHP">class myUser extends sfBasicSecurityUser
{
  public function initialize($context, $parameters = null)
  {
    if (sfConfig::get('sf_timeout') == 0) {
      // session will expire if window is open for a day
      sfConfig::set('sf_timeout', 86400);
    }

    return parent::initialize($context, $parameters);
  }
}
</pre>
<p>This works because the <code>sf_timeout</code> setting is not used by<br />
any other class (at the moment), so changing it doesn&#8217;t have any side<br />
effects. If you set your timeout to 0 or false, symfony will always<br />
think you have set the session timeout to 24 hours, but the session will<br />
 actually expire when the user closes the browser window.<br />
If you are not comfortable with &#8220;hacks&#8221; like the above, you could copy <code>the initialize()</code> method from<br />
<code>sfBasicSecurityUser</code>, change it in the appropriate place, and skip calling the parent constructor altogether.<br />
Unfortunately, <code>sfBasicSecurityUser</code> calls <em>its</em> parent constructor, so you have to rewrite them both:</p>
<pre class="php">class myUser extends sfBasicSecurityUser
{
  public function initialize($context, $parameters = null)
  {
    $this-&gt;context = $context;

    $this-&gt;parameterHolder = new sfParameterHolder();
    $this-&gt;parameterHolder-&gt;add($parameters);

    $this-&gt;attributeHolder = new sfParameterHolder(self::ATTRIBUTE_NAMESPACE);

    // read attributes from storage
    $attributes = $context-&gt;getStorage()-&gt;read(self::ATTRIBUTE_NAMESPACE);
    if (is_array($attributes))
    {
      foreach ($attributes as $namespace =&gt; $values)
      {
        $this-&gt;attributeHolder-&gt;add($values, $namespace);
      }
    }

    // set the user culture to sf_culture parameter if present in the request
    // otherwise
    //  - use the culture defined in the user session
    //  - use the default culture set in i18n.yml
    if (!($culture = $context-&gt;getRequest()-&gt;getParameter('sf_culture')))
    {
      if (null === ($culture = $context-&gt;getStorage()-&gt;read(self::CULTURE_NAMESPACE)))
      {
        $culture = sfConfig::get('sf_i18n_default_culture', 'en');
      }
    }

    $this-&gt;setCulture($culture);

    // read data from storage
    $storage = $this-&gt;getContext()-&gt;getStorage();

    $this-&gt;authenticated = $storage-&gt;read(self::AUTH_NAMESPACE);
    $this-&gt;credentials   = $storage-&gt;read(self::CREDENTIAL_NAMESPACE);
    $this-&gt;lastRequest   = $storage-&gt;read(self::LAST_REQUEST_NAMESPACE);

    if ($this-&gt;authenticated == null)
    {
      $this-&gt;authenticated = false;
      $this-&gt;credentials   = array();
    }
    else
    {
      // Automatic logout logged in user if no request within [sf_timeout] setting
      if (0 != sfConfig::get('sf_timeout') &amp;&amp; null !== $this-&gt;lastRequest &amp;&amp; (time() -
$this-&gt;lastRequest) &gt; sfConfig::get('sf_timeout'))
      {
        if (sfConfig::get('sf_logging_enabled'))
        {
          $this-&gt;getContext()-&gt;getLogger()-&gt;info('{sfUser} automatic user logout due to timeout');
        }
        $this-&gt;setTimedOut();
        $this-&gt;setAuthenticated(false);
      }
    }

    $this-&gt;lastRequest = time();

  }
}
</pre>
<p>That should do it!</p>
]]></content:encoded>
			<wfw:commentRss>http://robrosenbaum.com/php/howto-disable-session-timeout-in-symfony/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>sfModelTestPlugin &#8211; Simple unit tests for any ORM!</title>
		<link>http://robrosenbaum.com/php/sfmodeltestplugin-simple-unit-tests-for-any-orm/</link>
		<comments>http://robrosenbaum.com/php/sfmodeltestplugin-simple-unit-tests-for-any-orm/#comments</comments>
		<pubDate>Wed, 14 Nov 2007 19:02:31 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://robrosenbaum.com/uncategorized/sfmodeltestplugin-simple-unit-tests-for-any-orm/</guid>
		<description><![CDATA[Easy unit testing with model objects and a test database with sfModelTest plugin. Propel, Doctrine, and Propel 1.3 are supported.]]></description>
			<content:encoded><![CDATA[<p>I have redone the <a href="http://trac.symfony-project.com/wiki/sfPropelTestPlugin">sfPropelTestPlugin</a>, and it is now <a href="http://trac.symfony-project.com/wiki/sfModelTestPlugin">sfModelTestPlugin</a>, with support for Doctrine and Propel 1.3! Also new &#8211; you can now specify the test data file/directory at runtime, allowing for more flexibility with your tests. I want to thank Anders Betnér and my readers for bug reports and patches!</p>
]]></content:encoded>
			<wfw:commentRss>http://robrosenbaum.com/php/sfmodeltestplugin-simple-unit-tests-for-any-orm/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New symfony plugin &#8211; sfPropelTestPlugin simplifies unit tests</title>
		<link>http://robrosenbaum.com/php/new-symfony-plugin-sfpropeltestplugin-simplifies-unit-tests/</link>
		<comments>http://robrosenbaum.com/php/new-symfony-plugin-sfpropeltestplugin-simplifies-unit-tests/#comments</comments>
		<pubDate>Thu, 13 Sep 2007 12:59:47 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://robrosenbaum.com/symfony/new-symfony-plugin-sfpropeltestplugin-simplifies-unit-tests/</guid>
		<description><![CDATA[Easy unit testing with Propel objects and a test database with sfPropelTestPlugin.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever tried to write a symfony unit test for a model class &#8211; or for any piece of code that interacts with the database &#8211; then you know what a headache it can be. <a href="http://trac.symfony-project.com/trac/wiki/sfPropelTestPlugin">sfPropelTestPlugin</a> to the rescue! This plugin loads all the necessary symfony components for database interaction, and goes a step further: test data is automatically reloaded to the test database at the beginning of each test case, so you don&#8217;t have to worry about your tests interacting with each other. Here&#8217;s an example of a unit test written with <a href="http://trac.symfony-project.com/trac/wiki/sfPropelTestPlugin">sfPropelTestPlugin</a>:</p>
<pre class="php">
class myUnitTest extends sfPropelTest
{
  public function setup()
  {
    $this->bob = UserPeer::retrieveByPK('bob');
  }

  public function teardown()
  {
    $this->diag('Test method complete!');
  }

  public function test_user()
  {
    $this->is($this->bob->getId(), 'bob', 'Bob exists!');

    $user = new User();
    $user->setFirstName('Joe');
    $user->setLastName('Smith');
    $user->setUsername('joe');
    $user->save();

    $joe = UserPeer::getBy(UserPeer::USERNAME, 'joe');
    $this->isa_ok($joe, 'User', 'Joe exists!');
  }

  public function test_dataDelete()
  {
    $this->is($this->bob->getId(), 'bob', 'Bob still exists!');

    $joe = UserPeer::getBy(UserPeer::USERNAME, 'joe');
    $this->ok(!$joe, 'Joe no longer exists.');
  }
}

$test = new myUnitTest();
$test->execute();
</pre>
<p class="leadingnoindent">If you&#8217;ve written tests in Ruby on Rails, the above should look familiar. If not, let&#8217;s go through the code:</p>
<p>The first two lines are setup: The first line tells symfony what application to test &#8211; in this case, &#8220;myApp&#8221; &#8211; and the second line includes the code we need to test against the database. Next we define our &#8220;test case&#8221; &#8211; a class that extends <code class="php">sfPropelTest</code>, which is itself a child of <code class="php">lime_test</code>. Every method that begins with &#8220;test_&#8221; will be called in turn, with our test data being reloaded between each call. Also, the <code class="php">setup()</code> method, if defined, will be called immediately before each test method, and the <code class="php">teardown()</code> method, if defined, will be called immediately after. The last two lines create a new instance of our test suite, and call its <code class="php">execute()</code> method, which runs our tests.</p>
<p>There you have it &#8211; a quick and painless way to run unit tests in symfony. One less excuse for not writing them!</p>
]]></content:encoded>
			<wfw:commentRss>http://robrosenbaum.com/php/new-symfony-plugin-sfpropeltestplugin-simplifies-unit-tests/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Improved Plugin for Model Validation: sfPropelValidatePlugin</title>
		<link>http://robrosenbaum.com/php/improved-plugin-for-model-validation-sfpropelvalidateplugin/</link>
		<comments>http://robrosenbaum.com/php/improved-plugin-for-model-validation-sfpropelvalidateplugin/#comments</comments>
		<pubDate>Mon, 10 Sep 2007 01:08:37 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://robrosenbaum.com/symfony/improved-plugin-for-model-validation-sfpropelvalidateplugin/</guid>
		<description><![CDATA[Put your Symfony validation in the model, where it belongs, with sfPropelValidate plugin. New version is more efficient.]]></description>
			<content:encoded><![CDATA[<p>I have updated my plugin for doing <a href="http://trac.symfony-project.com/trac/wiki/sfPropelValidatePlugin">model-based validation in symfony</a>. The new plugin uses the Propel builders instead of behaviors, so it is now called <a href="http://trac.symfony-project.com/trac/wiki/sfPropelValidatePlugin">sfPropelValidatePlugin</a> instead of the former (unwieldy) name sfPropelValidateBehaviorPlugin. If you have not investigated the Propel builder classes, I suggest you give them a look. By overriding the default classes used to build your Propel object and peer classes, you can write your modifications directly into your model&#8217;s base classes. This is a much cleaner and more readable solution than using Propel behaviors, and you avoid the performance hit that behaviors incur. </p>
<p>The default Propel builders can be found in the symfony source in these places:</p>
<pre class="filesystem">
symfony/addon/propel/builder/sfObjectBuilder.php
symfony/addon/propel/builder/sfPeerBuilder.php
</pre>
<p class="leadingnoindent">The classes these inherit from are buried. They can be found here:</p>
<pre class="filesystem">
symfony/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexObjectBuilder.php
symfony/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexPeerBuilder.php
</pre>
]]></content:encoded>
			<wfw:commentRss>http://robrosenbaum.com/php/improved-plugin-for-model-validation-sfpropelvalidateplugin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

