<?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>Delivering Quality &#187; symfony</title>
	<atom:link href="http://www.markdeepwell.com/tag/symfony/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markdeepwell.com</link>
	<description>A Software Developers View of the World</description>
	<lastBuildDate>Sat, 31 Dec 2011 22:41:24 +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>Add an i18n Static Page to Symfony</title>
		<link>http://www.markdeepwell.com/2011/05/add-an-i18n-static-page-to-symfony/</link>
		<comments>http://www.markdeepwell.com/2011/05/add-an-i18n-static-page-to-symfony/#comments</comments>
		<pubDate>Mon, 16 May 2011 02:00:48 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[multilingual]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[static page]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.markdeepwell.com/?p=611</guid>
		<description><![CDATA[My last post explained the basics on how to add static pages in symfony, this post expands on that and shows you how to do it for a multilingual site. We split the template finding code out for code maintainability, and we enhance it on where to look for the file. First it tries to [...]]]></description>
			<content:encoded><![CDATA[<p>My last post explained the basics on how to <a href="http://www.markdeepwell.com/2011/03/add-a-static-page-to-symfony/">add static pages in symfony</a>, this post expands on that and shows you how to do it for a multilingual site.</p>
<p>We split the template finding code out for code maintainability, and we enhance it on where to look for the file. First it tries to find the template in the language and country eg: en_CA, then it tries to find the template in the matching language, and if that is not found, it falls back to the default language.</p>
<pre class="brush: php; title: ; notranslate">
/**
 * Load a static page.
 * @param sfRequest $request A request object
 */
public function executePage(sfWebRequest $request)
{
  $template = $this-&gt;findTemplate($request-&gt;getParameter('view'), $this-&gt;getUser()-&gt;getCulture());
  $this-&gt;forward404Unless($template);
  $this-&gt;setTemplate($template);
}

/**
 * Check if a template page exists for a given culture.
 * Be intelligent and check if language &amp; country exist, try language, and then default to english.
 * @param string $name Template filename to check
 * @param string $culture Symfony culture string
 */
protected function findTemplate($name, $culture)
{
  // for safety, strip out all non-alphanumeric characters
  $name = preg_replace('/[^a-zA-Z0-9\s]/', '', $name);

  $directory = $this-&gt;getContext()-&gt;getModuleDirectory() . DIRECTORY_SEPARATOR .&quot;templates&quot;;
  // try language and country: en_CA
  if (is_readable($directory . DIRECTORY_SEPARATOR . $culture. DIRECTORY_SEPARATOR . $name .&quot;Success.php&quot;))
  {
    return $culture. DIRECTORY_SEPARATOR . $name;
  }
  // try langage only: en
  elseif (is_readable($directory . DIRECTORY_SEPARATOR . substr($culture, 0, 2). DIRECTORY_SEPARATOR . $name .&quot;Success.php&quot;))
  {
    return substr($culture, 0, 2). DIRECTORY_SEPARATOR . $name;
  }
  // try default language
  elseif (is_readable($directory . DIRECTORY_SEPARATOR . $name .&quot;Success.php&quot;))
  {
    return $name;
  }
  return false;
}
</pre>
<p>The template directory should have the default language file as usual, eg: templates/helpSuccess.php, and then there should be folders for each language and possibly language &#038; country with the same filename, but localized. eg: templates/fr/helpSuccess.php</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markdeepwell.com/2011/05/add-an-i18n-static-page-to-symfony/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add a Static Page to Symfony</title>
		<link>http://www.markdeepwell.com/2011/03/add-a-static-page-to-symfony/</link>
		<comments>http://www.markdeepwell.com/2011/03/add-a-static-page-to-symfony/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 15:02:19 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[static page]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.markdeepwell.com/?p=597</guid>
		<description><![CDATA[Static pages can be added to Symfony quite easily. Edit your routing.yml file which is probably located at apps/frontend/config/routing.yml, and add the following routes to add an about, a privacy, and a terms and conditions page. If you are going to keep the generic rules, make sure you add these new rules before the default [...]]]></description>
			<content:encoded><![CDATA[<p>Static pages can be added to Symfony quite easily.</p>
<p>Edit your routing.yml file which is probably located at apps/frontend/config/routing.yml, and add the following routes to add an about, a privacy, and a terms and conditions page.</p>
<pre class="brush: plain; title: ; notranslate">
# static pages
about:
  url:   /about
  param: { module: home, action: page, view: about }
privacy:
  url:   /privacy
  param: { module: home, action: page, view: privacy }
terms:
  url:   /terms
  param: { module: home, action: page, view: terms }
</pre>
<p>If you are going to keep the generic rules, make sure you add these new rules <strong>before</strong> the default actions.</p>
<p>Clear your cache:<br />
./symfony clear-cache</p>
<p>Then inside the module named <strong>home</strong> (create it if it doesn&#8217;t exist), add the following action:</p>
<pre class="brush: php; title: ; notranslate">
  /**
   * Load a static page.
   * @param sfRequest $request A request object
   */
  public function executePage(sfWebRequest $request)
  {
    $directory = $this-&gt;getContext()-&gt;getModuleDirectory().DIRECTORY_SEPARATOR.&quot;templates&quot;;
    $name = $request-&gt;getParameter('view');
    // for safety, strip out all non-alphanumeric characters
    $name = preg_replace('/[^a-zA-Z0-9\s]/', '', $name);
    if (is_readable($directory.DIRECTORY_SEPARATOR.$name.&quot;Success.php&quot;))
    {
      return $this-&gt;setTemplate($name);
    }
    else
    {
      $this-&gt;forward404();
    }
  }
</pre>
<p>The template files will be on the home/templates directory, called aboutSuccess.php, privacySuccess.php, and termsSuccess.php</p>
<p>This action will check if the template file exists, and if so load the template, if not it will forward to the 404 not found page. Easy and safe static templates. Add more routes and the appropriate template file as required.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markdeepwell.com/2011/03/add-a-static-page-to-symfony/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Form Errors in symfony 1.3+</title>
		<link>http://www.markdeepwell.com/2010/04/debugging-form-errors-in-symfony-1-3/</link>
		<comments>http://www.markdeepwell.com/2010/04/debugging-form-errors-in-symfony-1-3/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 16:19:13 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[form validation]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.markdeepwell.com/?p=503</guid>
		<description><![CDATA[Symfony 1.3 (or symfony 1.4) provides an incredibly helpful feature to help debug forms. This new feature is included in the developer toolbar and shows valuable information about the forms on the page. To access the detailed form information, click on the view button, click on the template or partial that the form is in, [...]]]></description>
			<content:encoded><![CDATA[<p>Symfony 1.3 (or symfony 1.4) provides an incredibly helpful feature to help  debug forms. This new feature is included in the developer toolbar and shows valuable information about the forms on the page. To access the detailed form information, click on the <em>view</em> button, click on the template or partial that the form is in, and then click to expand the form. It lists each form widget and if any errors for a given widget exist they are shown   right under it. Errors are also highlighted to make them easy to   spot.</p>
<p><a href="http://www.markdeepwell.com/wp-content/uploads/2010/04/form-widget-view.jpg"><img class="aligncenter size-full  wp-image-508" title="form widget view" src="http://www.markdeepwell.com/wp-content/uploads/2010/04/form-widget-view.jpg" alt="" width="435" height="202" /></a></p>
<p>The symfony debug toolbar will look like this when there is a validation error in one of the forms on the current page. This is one of the most incredibly useful features I&#8217;ve seen and greatly  improves productivity while building forms in the symfony framework. Congratulations to the symfony developers who came up with this tool!</p>
<p><a href="http://www.markdeepwell.com/wp-content/uploads/2010/04/symfony-debug-toolbar-1.4.jpg"><img class="aligncenter size-full  wp-image-509" title="symfony debug toolbar 1.4" src="http://www.markdeepwell.com/wp-content/uploads/2010/04/symfony-debug-toolbar-1.4.jpg" alt="" width="492" height="21" /></a></p>
<p>Have symfony 1.1 or 1.2? read <a href="http://www.markdeepwell.com/2009/07/catch-symfony-form-errors/">catch symfony form errors</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markdeepwell.com/2010/04/debugging-form-errors-in-symfony-1-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Alternative to symfony&#8217;s schema.yml</title>
		<link>http://www.markdeepwell.com/2009/08/an-alternative-to-symfonys-schema-yml/</link>
		<comments>http://www.markdeepwell.com/2009/08/an-alternative-to-symfonys-schema-yml/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 04:13:07 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[database schema]]></category>
		<category><![CDATA[Propel]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.markdeepwell.com/?p=96</guid>
		<description><![CDATA[The symfony web framework provides two methods for building the database model files when using the Propel Object-relational mapping (ORM) toolkit. The recommended method by the symfony team is to use the schema.yml file, where you explicitly explain your table structure. The second method is to generate a schema.xml file directly from the database. schema.yml: [...]]]></description>
			<content:encoded><![CDATA[<p>The symfony web framework provides two methods for building the database model files when using the <a href="http://propel.phpdb.org/">Propel Object-relational mapping</a> (ORM) toolkit. The  recommended method by the symfony team is to use the  <a href="http://www.symfony-project.org/book/1_2/08-Inside-the-Model-Layer#chapter_08_symfony_s_database_schema">schema.yml</a> file, where you explicitly explain your table structure. The second method is to generate a <a href="http://www.symfony-project.org/book/1_2/08-Inside-the-Model-Layer#chapter_08_sub_beyond_the_schema_yml_the_schema_xml">schema.xml</a> file directly from the database.</p>
<h3>schema.yml:<img class="alignright size-full wp-image-97" title="symfony schema yml" src="http://www.markdeepwell.com/wp-content/uploads/2009/08/symfony-schema-yml.png" alt="symfony schema yml" width="209" height="102" /></h3>
<p>Just edit config/schema.yml and list your tables, columns, column types, and foreign keys in YAML form. Build the model files by running:</p>
<pre>./symfony propel-build-model</pre>
<p>Pros:</p>
<ul>
<li> Interfaces better with  plugins because most, if not all, plugins use the schema.yml method</li>
<li>Can be used to create the database tables</li>
<li>Overall easier to use because it is the most common method</li>
</ul>
<p>Cons:</p>
<ul>
<li> Requires duplicate data by having the database structure in a text file, which can be outdated when the database is updated directly</li>
</ul>
<h3>schema.xml:</h3>
<p>To create the model files simply run:</p>
<pre>./symfony propel-build-schema xml
./symfony propel-build-model</pre>
<p>Pros:</p>
<ul>
<li>Supports ALL  database features</li>
<li>Supports the most complex schemas</li>
</ul>
<p>Cons:</p>
<ul>
<li>Errors while building the XML file are cryptic and time consuming to track down (eg: om-template)</li>
</ul>
<h3>Comparison</h3>
<p>The schema.yml method supports most projects with relative ease, but is limiting if you need to use more advanced database features that are not supported (propel only supports limited <a href="http://propel.phpdb.org/trac/wiki/Users/Documentation/1.3/ColumnTypes">column types</a>). Although, there are tricks to get around these limitations. For example, if you need to use column types that aren&#8217;t supported, like ENUM, you can simply declare the column as a varchar and Propel won&#8217;t know any better. This works fine for ENUM because it&#8217;s simply a text field, but may work for other column types too.</p>
<p>I recommend the schema.xml file for projects that have a very complex schema that cannot be represented in the yml file, or for projects already using XML files to define the database scheme.</p>
<p>I have used both methods on different large projects and have found the schema.yml method to provide faster  application development, have more  developer support, and easier to work with. I full recommend use of the schema.yml method in all but the most exceptional projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markdeepwell.com/2009/08/an-alternative-to-symfonys-schema-yml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Catch Symfony Form Errors</title>
		<link>http://www.markdeepwell.com/2009/07/catch-symfony-form-errors/</link>
		<comments>http://www.markdeepwell.com/2009/07/catch-symfony-form-errors/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 18:43:11 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.markdeepwell.com/?p=68</guid>
		<description><![CDATA[Have you built a form while developing with the symfony form framework that appears to work fine but fails because of an unknown error? Here is the simplest and easiest way to catch most errors. First open the web page with the form and fill it in with valid input. Then, open the form php [...]]]></description>
			<content:encoded><![CDATA[<p>Have you built a form while developing with the <a href="http://www.symfony-project.org/forms/1_2/en/01-Form-Creation">symfony form framework</a> that appears to work fine but fails because of an unknown error? Here is the simplest and easiest way to catch most errors. </p>
<p>First open the web page with the form and fill it in with valid input. Then, open the form php file, temporarily delete all your custom form render code and replace it with echo $form. Go back to the web page and click your form submit button. It should show you any validation errors that appear in the form but were missing on your customized version, because this time it&#8217;s rendering the form with the default settings. At the very least it could show you something you missed and hint at the solution. </p>
<p>Your test form would look like this:</p>
<pre class="brush: php; title: ; notranslate">
&lt;form action=&quot;&lt;?php echo url_for('user/'.($form-&gt;getObject()-&gt;isNew() ? 'create' : 'update').(!$form-&gt;getObject()-&gt;isNew() ? '?id='.$form-&gt;getObject()-&gt;getId() : '')) ?&gt;&quot; method=&quot;post&quot; &lt;?php $form-&gt;isMultipart() and print 'enctype=&quot;multipart/form-data&quot; ' ?&gt;&gt;
&lt;table&gt;
  &lt;tfoot&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;?php echo $form-&gt;renderHiddenFields() ?&gt;
      &lt;input type=&quot;submit&quot; value=&quot;Save&quot;&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tfoot&gt;
  &lt;tbody&gt;
    &lt;?php echo $form ?&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/form&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.markdeepwell.com/2009/07/catch-symfony-form-errors/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Symfony CRUD Generator</title>
		<link>http://www.markdeepwell.com/2009/07/symfony-crud-generator/</link>
		<comments>http://www.markdeepwell.com/2009/07/symfony-crud-generator/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 01:01:22 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[code generation]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.markdeepwell.com/?p=35</guid>
		<description><![CDATA[The symfony CRUD generator is a very useful tool for speeding up your web development. When you need a list of items that you can list and edit, you are most likely building a standard CRUD (create-read-update-delete) interface. This is common functionality that is found in most applications. Since this is such a common task, [...]]]></description>
			<content:encoded><![CDATA[<p>The symfony <a href="http://www.symfony-project.org/forms/1_2/en/04-Propel-Integration#chapter_04_the_crud_generator">CRUD generator</a> is a very useful tool for speeding up your web development. When you need a list of items that you can list and edit, you are most likely building a standard CRUD (create-read-update-delete) interface. This is common functionality that is found in most applications. Since this is such a common task, it makes perfect sense that the symfony <a href="http://www.symfony-project.org/">web framework</a> has a tool to build it for you.</p>
<p>For example: Lets say your web application allow users to sign-up (surprise!) and you  need a user management tool in the admin section to manage these users. To create this in symfony, you&#8217;d run the following:</p>
<pre><code>./symfony propel:generate-crud admin user User
</code></pre>
<p>This assumes you have an admin application, and a User model file. With that one line, it will create a listing of all users with the ability to edit and delete them. It generates HTML and PHP code that you can modify to your requirements. Fantastic for less than a minute of work!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markdeepwell.com/2009/07/symfony-crud-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

