<?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>CentreSource Interactive Agency Blog &#187; Brent Shaffer</title>
	<atom:link href="http://blog.centresource.com/author/bshaffer/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.centresource.com</link>
	<description>Web Development &#124; Nashville, TN</description>
	<lastBuildDate>Tue, 09 Mar 2010 16:39:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Code That Saves The Day: Symfony Admin Generator</title>
		<link>http://blog.centresource.com/2010/01/13/code-that-saves-the-day-symfony-admin-generator/</link>
		<comments>http://blog.centresource.com/2010/01/13/code-that-saves-the-day-symfony-admin-generator/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 19:07:27 +0000</pubDate>
		<dc:creator>Brent Shaffer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Code that Saves the Day]]></category>

		<guid isPermaLink="false">http://blog.centresource.com/?p=1392</guid>
		<description><![CDATA[Every day at CentreSource brings with it a new challenge. With every challenge comes the opportunity to try a unique approach.]]></description>
			<content:encoded><![CDATA[<p>Every day at CentreSource brings with it a new challenge. With every challenge comes the opportunity to try a unique approach. We all know sailing the interweb can be stormy at best. But if you keep your eyes open, you will find code that can be a lighthouse to your sinking ship. Today&#8217;s Code that Saves the Day™:<strong> The Symfony Admin Generator!</strong></p>
<p>For those who don&#8217;t know, <a  href="http://www.symfony-project.org">Symfony</a> is an MVC web framework built on PHP. Symfony is a great tool to use for custom development, and is very similar to the als0-opensource MVC framework Ruby on Rails. The <a  href="http://www.symfony-project.org/screencast/admin-generator">Symfony Admin Generator</a> is a tool connected to a command-line task that allows you to easily spin up editable interfaces for your website&#8217;s administrators. Do you have a table for contacts in your database? Type a single command into your terminal&#8230;</p>
<blockquote><p><tt>$: php symfony doctrine:generate-admin backend Contacts</tt></p></blockquote>
<p>&#8230;and presto! Your users can filter, sort, view, edit, and create new contacts! Yes, it really is that simple. There are a variety of customizations available (some of which could use healthier documentation, which extends beyond the scope of this post), and you can read about those <a  href="http://www.symfony-project.org/book/1_2/14-Generators">here</a>.</p>
<h3>Problem: Client demands additional functionality for administrative purposes.</h3>
<p><em>example:</em> &#8220;We want to easily export data from the tables in our database. We want to customize exported fields per export, change column labels, and make other fields unable to be exported&#8221;.</p>
<h3>Mediocre Solution: Override the generated admin module with code to export.</h3>
<p><em>explanation: </em>While not a terrible alternative, this is certainly not the best one. The admin generator places most of the generated code in cache, so a good way to customize it is to override the generated files. This is great for small customizations, but <u>not optimal for potentially reusable code!</u> Allowing for any table in your application to be exported is a pretty tempting solution, yes? Think about it. What if you could do this?</p>
<blockquote><p><tt>$: php symfony doctrine:generate-admin backend Contacts --theme=export</tt></p></blockquote>
<p>And have a fully generated export interface at your disposal? Pretty slick, I&#8217;d say. Which brings us to the:</p>
<h3>Better Solution: Customize the admin generator itself (as opposed to the generated code).</h3>
<p>That&#8217;s right! We get to write code that writes code! Nervous? Scared? Envisioning tiny software bugs slowly infecting every part of your application? Don&#8217;t be! It&#8217;s easy. Now I know you&#8217;re salivating. </p>
<p>The admin generator is contained in Symfony core. I used the doctrine version, because we&#8217;re pulling directly from the database. In the <tt>sfDoctrinePlugin</tt>, copy the files in <tt>data/generator/sfDoctrineModule/admin</tt> into your own data directory (I used the path <tt><a  class="thickbox" href="http://blog.centresource.com/wp-content/uploads/2010/01/Screen-shot-2010-01-11-at-9.35.40-AM.png" target="_blank" title="The proper path for your custom admin generator theme in your Symfony project">data/generator/sfDoctrineModule/export</a></tt> in my project&#8217;s root directory. The directory after <tt>sfDoctrineModule</tt> is the name of your theme). There are three directories: parts, skeleton, and templates. <em>Skeleton </em>is what gets generated outside of cache into the project itself. <em>Template </em>is what is generated INTO cache. <em>Parts </em>contains all your files you do NOT want to copy over into cache or the project, but you need for organizational purposes.</p>
<p>I chose to override the <tt>sfModelGeneratorConfiguration</tt> class to give myself more flexibility when customizing. The <tt>sfModelGeneratorConfiguration</tt> class parses the <tt>generator.yml</tt> file, which is what allows the developers to tweak the generated code to their specifications without having to copy over/write new code. In my admin generator, a user can<a  class="thickbox" href="http://blog.centresource.com/wp-content/uploads/2010/01/Screen-shot-2010-01-11-at-9.46.08-AM.png" target="_blank" title="generator.yml configuration for export admin generator"> customize their export fields</a> via the generator.yml file.</p>
<p>We now have a flexible admin generator on demand that not only exports the fields of a database table, but allows our user to customize which fields are appropriate to show to the end user. On top of this, the system allows the user to declare fields to export that <em>don&#8217;t even exist on the object!</em> Lets say we want to have a field exported called &#8220;timespan&#8221;, which symbolizes the duration the user has been in the system. This is going to be a calculation of the current date minus the date the user was added to the system. All we need to do is add &#8220;timespan&#8221; to the <em>fields</em> option in <tt>generator.yml</tt>, and add a method to our Contact model called <tt>getTimespan()</tt> that returns the appropriate string. If you still haven&#8217;t salivated, then maybe this will help: The export interface feeds off the sorting/filtering applied by the user in the main view, <em>and </em>allows the users to rename columns and deselect unwanted columns appropriately for their export.</p>
<p>We now have an out-of-the-box exporting solution for the following deliverables for our end-user:</p>
<ul>
<li>Filtering for Export result set</li>
<li>Sorting for Export result set</li>
<li>Exported column naming</li>
<li>Exported column selection</li>
</ul>
<p>And the following deliverables for our developers:</p>
<ul>
<li>Customization of available fields for exporting</li>
<li>Customizing of filters/sorting capability (pulls from existing admin-generator functionality)</li>
<li>Addition of non-real export fields</li>
<li>Easy extension of the admin generator
	</li>
<li><em>all of this functionality is object-oriented, normalized, and easily overridden or extended.</em></li>
<li>Extended admin generator functionality<br />
<em>The export admin generator adds several helpful methods such as <tt>hasExport</tt> and <tt>isFiltered</tt> to the classic admin generator. It also adds a flash message &#8220;Your results are currently filtered, click HERE to unfilter them&#8221; to any list view.</em></li>
</ul>
<p>You can find all of this code <a  href="http://github.com/bshaffer/Symfony-Snippets/tree/master/AdminGeneratorExport">here</a>. Now go forth, and <a  href="http://www.strangebuzz.com/index.php/2008/04/03/31-symfony-10-tutorial-extending-the-admin-generator">EXTEND THY ADMIN GENERATOR</a>!!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.centresource.com/2010/01/13/code-that-saves-the-day-symfony-admin-generator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nashville Symfony Users Group &#8211; Extending Symfony Routing and More!</title>
		<link>http://blog.centresource.com/2009/10/03/nashville-symfony-users-group-extending-symfony-routing-and-more/</link>
		<comments>http://blog.centresource.com/2009/10/03/nashville-symfony-users-group-extending-symfony-routing-and-more/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 21:00:32 +0000</pubDate>
		<dc:creator>Brent Shaffer</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://blog.centresource.com/?p=1076</guid>
		<description><![CDATA[On Thursday, the Nashville Symfony Users Group met in the Centresource conference room to discuss the extension of the Symfony...]]></description>
			<content:encoded><![CDATA[<p>On Thursday, the <a  href="http://groups.google.com/group/nashville-symfony">Nashville Symfony Users Group</a> met in the Centresource conference room to discuss the extension of the Symfony routing framework.  I lead the talk, but it did not take long for the presentation to become a round table discussion, with everyone contributing their own thoughts and snippets of Symfony wisdom.  Overall, the session was a lot of fun.  You can view the slideshow from the presentation <a  href="http://www.slideshare.net/bshafs/nashvile-symfony-routes-presentation">here</a>.</p>
<p>Doctrine 2.0 was also discussed.  We are hoping for a more complete presentation from <a  href="http://jwage.com">Jon Wage</a> next month.  Keep your fingers crossed!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.centresource.com/2009/10/03/nashville-symfony-users-group-extending-symfony-routing-and-more/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Symfony Faux Form Serialization</title>
		<link>http://blog.centresource.com/2009/07/14/symfony-faux-form-serialization/</link>
		<comments>http://blog.centresource.com/2009/07/14/symfony-faux-form-serialization/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 21:09:36 +0000</pubDate>
		<dc:creator>Brent Shaffer</dc:creator>
				<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[form framework]]></category>
		<category><![CDATA[web-development]]></category>

		<guid isPermaLink="false">http://blog.centresource.com/?p=992</guid>
		<description><![CDATA[Recently, I ran into an issue when building a Symfony plugin for Slideshow renderings.  When I added the support for...]]></description>
			<content:encoded><![CDATA[<p>Recently, I ran into an issue when building a Symfony plugin for Slideshow renderings.  When I added the support for multiple libraries, in this case Google Slideshow2 and JQuery Cycle, they had drastically different configuration options.  JQuery Cycle allows you to use a list of effects, such as blindX and blindY.  These effects are great, and I want the end user to be able to easily select between them.  Google Slideshow2 allows the adding of thumbnails and traversing controls.  Neither of these settings apply to the other, and this is only two slideshow renderers.  What happens when I add another one?  Five more?  I could create multiple tables for each renderer, such as google_slideshow2_options and jquery_cycle_options.  I could also just provide a textarea for key-value pairs (effect=blindX timeout=500) that the user typed in.  I did not like either of these options, as the former struck me as over-architecting, and the latter as unusable.</p>
<p>The solution I ended up with was to use something similar to serialization techniques.  This allowed me to configure dynamic forms, add options, and keep the whole thing in a single database field.  The solution has worked great, and has only required a few extra lines of code to my form.  With tweaking, I hope to turn this code into a widget, to allow it to be added quickly to any Symfony form.</p>
<p>If you are interested in implementing this kind of functionality, you can see my code <a  href="http://brentertainment.com/2009/07/11/symfony-options-form-faux-form-serialization/">here</a>, or you can check out the code for <a  href="http://www.symfony-project.org/plugins/csDoctrineSlideshowPlugin">csDoctrineSlideshowPlugin</a> and see it in action.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.centresource.com/2009/07/14/symfony-faux-form-serialization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Centresource Releases New Plugins to the Symfony Community</title>
		<link>http://blog.centresource.com/2009/05/09/centresource-releases-new-plugins-to-the-symfony-community/</link>
		<comments>http://blog.centresource.com/2009/05/09/centresource-releases-new-plugins-to-the-symfony-community/#comments</comments>
		<pubDate>Sat, 09 May 2009 18:39:50 +0000</pubDate>
		<dc:creator>Brent Shaffer</dc:creator>
				<category><![CDATA[Company News]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Company-News]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[web-development]]></category>

		<guid isPermaLink="false">http://blog.centresource.com/?p=797</guid>
		<description><![CDATA[Over the last week, the developers here at CentreSource have published nine plugins for the symfony community.  The plugins have...]]></description>
			<content:encoded><![CDATA[<p>Over the last week, the developers here at CentreSource have published nine plugins for the <a  href="http://www.symfony-project.org/">symfony</a> community.  The plugins have been used in several of our internal projects and client web applications, but have been developed on a private repository.  We finally decided the plugins were properly documented and tested.  These plugins can be found <a  href="http://www.symfony-project.org/plugins/developer/brent-shaffer">here</a>.</p>
<p>1) <a  href="http://www.symfony-project.org/plugins/csDoctrineActAsAttachablePlugin">csDoctrineActAsAttachablePlugin</a> &#8211; associates various uploads with multiple models, and includes an AJAX uploading client interface.</p>
<p>2) <a  href="http://www.symfony-project.org/plugins/csDoctrineActAsCategorizablePlugin">csDoctrineActAsCategorizablePlugin</a> &#8211; associates models into nestable categories and category groups.</p>
<p>3) <a  href="http://www.symfony-project.org/plugins/csDoctrineActAsGeolocatablePlugin">csDoctrineActAsGeolocatablePlugin</a> &#8211; integrate your model with the Google Maps API to pull in geocodes based on record fields.  Supports radius and proximity searches.</p>
<p>4) <a  href="http://www.symfony-project.org/plugins/csDoctrineActAsSortablePlugin">csDoctrineActAsSortablePlugin</a> &#8211; adds a sortable behavior to your models</p>
<p>5) <a  href="http://www.symfony-project.org/plugins/csDoctrineSlideshowPlugin">csDoctrineSlideshowPlugin</a> &#8211; add and configure slideshows in your project.</p>
<p>6) <a  href="http://www.symfony-project.org/plugins/csFormTransformPlugin">csFormTransformPlugin</a> -  give your forms a web 2.0 look within a few easy steps.</p>
<p>7) <a  href="http://www.symfony-project.org/plugins/csGlossaryPlugin">csGlossaryPlugin</a> &#8211; group your models alphabetically in glossary/directory format</p>
<p>8) <a  href="http://www.symfony-project.org/plugins/csSEOToolkitPlugin">csSEOToolkitPlugin</a> &#8211; A toolkit to improve your website&#8217;s search engine optimization.</p>
<p>9) <a  href="http://www.symfony-project.org/plugins/sfSympalSlideshowPlugin">sfSympalSlideshowPlugin</a> &#8211; An advanced slideshow used for the <a  href="http://www.symfony-project.org/plugins/sfSympalPlugin">Sympal</a> Content Management Framework.</p>
<p>You can check out my plugin list <a  href="http://www.symfony-project.org/plugins/developer/brent-shaffer">here</a>.  If you are interested in using these plugins, or have any suggestions for addition useful symfony plugins, please contact me or any of the developers here at CentreSource.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.centresource.com/2009/05/09/centresource-releases-new-plugins-to-the-symfony-community/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
