<?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>Eric Famiglietti</title>
	<atom:link href="http://eric-famiglietti.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://eric-famiglietti.com</link>
	<description></description>
	<lastBuildDate>Wed, 22 Aug 2012 16:57:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Using non-Blade views in Blade layouts</title>
		<link>http://eric-famiglietti.com/2012/08/22/using-non-blade-views-in-blade-layouts/</link>
		<comments>http://eric-famiglietti.com/2012/08/22/using-non-blade-views-in-blade-layouts/#comments</comments>
		<pubDate>Wed, 22 Aug 2012 16:57:17 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[ember.js]]></category>
		<category><![CDATA[handlebars.js]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[templating]]></category>

		<guid isPermaLink="false">http://eric-famiglietti.com/?p=1190</guid>
		<description><![CDATA[<p>Posted in <a href="http://eric-famiglietti.com/tumblog/articles/">Articles</a></p>As of late I have been using Laravel a lot to build my applications. I recently ran into the issue of needing to embed a non-Blade view into a Blade layout. The reason for this was that I was using [...]]]></description>
				<content:encoded><![CDATA[<p>Posted in <a href="http://eric-famiglietti.com/tumblog/articles/">Articles</a></p><p>As of late I have been using Laravel a lot to build my applications.  I recently ran into the issue of needing to embed a non-Blade view into a Blade layout.  The reason for this was that I was using <a href="http://emberjs.com/">Ember.js</a>, which uses <a href="http://handlebarsjs.com/">Handlebars.js</a> templates.  Handlebars.js templates, much like Laravel&#8217;s Blade templates, use <code>{{</code> and <code>}}</code>.  Including Handlebars.js templates in a Blade template did not make Laravel happy.  My solution was to create a regular view file that contained my JavaScript templates.  The issue I ran into was getting the view embedded into my layout.</p>
<p>&nbsp;</p>
<p>Most of my Blade templates looked something like this:</p>
<p>&nbsp;</p>
<pre class="brush: xml; title: ; notranslate">
@layout('layouts.common')

@section('content')
    &lt;!-- ... --&gt;
@endsection
</pre>
<p>&nbsp;</p>
<p>Breaking this down, it does two things.  It declares that we are using the <code>layouts.common</code> layout and embeds the <code>content</code> section into the layout.  How can we do this without using a Blade template?</p>
<p>&nbsp;</p>
<p>The <a href="http://laravel.com/docs/views/templating">documentation</a> explains how to specify a layout using the <code>layout</code> property of a controller:</p>
<p>&nbsp;</p>
<pre class="brush: php; title: ; notranslate">
class Ember_Controller extends Base_Controller {

    public $layout = 'layouts.common';

}
</pre>
<p>&nbsp;</p>
<p>Embedding the view into the layout isn&#8217;t as obvious.  Digging through the <a href="http://laravel.com/api/">API</a>, I discovered the <code>\Laravel\Section::inject()</code> method which lets you inject inline content into a section.  Using this I was able to inject the contents of my view into the content section (<code>@yield('content')</code>) of my layout.</p>
<p>&nbsp;</p>
<pre class="brush: php; title: ; notranslate">
class Ember_Controller extends Base_Controller {

    public $layout = 'layouts.common';

    public function action_index()
    {
        Section::inject('content', View::make('ember.index'));
    }

}
</pre>
<p>&nbsp;</p>
<p>As a side note, Laravel is an awesome framework with some great documentation.  But if you look a little deeper and check out the API, there are some really useful methods that aren&#8217;t documented.</p>
]]></content:encoded>
			<wfw:commentRss>http://eric-famiglietti.com/2012/08/22/using-non-blade-views-in-blade-layouts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get a handle on application packages</title>
		<link>http://eric-famiglietti.com/2012/01/11/get-a-handle-on-application-packages/</link>
		<comments>http://eric-famiglietti.com/2012/01/11/get-a-handle-on-application-packages/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 00:30:09 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://ericfamiglietti/?p=1164</guid>
		<description><![CDATA[<p>Posted in <a href="http://eric-famiglietti.com/tumblog/video/">Video</a></p><p></p>I answered a question on Stack Overflow the other day and it inspired me to write a blog post about a lesser known feature of CodeIgniter called application packages. The developer had finished an application and was wondering what the [...]]]></description>
				<content:encoded><![CDATA[<p>Posted in <a href="http://eric-famiglietti.com/tumblog/video/">Video</a></p><p></p><p>I answered a question on Stack Overflow the other day and it inspired me to write a blog post about a lesser known feature of CodeIgniter called application packages.  The developer had finished an application and was wondering what the best approach would be for creating a mobile website and API while reusing configuration files, libraries, and models from their original application.  Other answers involved dynamically configuring the <code>base_url</code> based on the requested URL which seems like an unnecessary and convoluted approach.  I don’t like editing the core when a solution exists within the bounds of the framework.  I proposed the usage of application packages as a simple way to create multiple applications that share resources.</p>
<p>&nbsp;</p>
<p>For those unfamiliar, adding an application package path in CodeIgniter modifies the list of directories the Loader uses when looking for resources.  More specifically, it “instructs the Loader class to prepend a given path for subsequent requests for resources.”  Here is an example of adding an application package path:</p>
<p>&nbsp;</p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;load-&gt;add_package_path(APP_PATH . '/third_party/package_name');
</pre>
<p>&nbsp;</p>
<p>Note that application packages do not need to be located in the <code>/application/third_party</code> folder; they can be located anywhere on the file system.</p>
<p>&nbsp;</p>
<p>The <code>add_package_path()</code> method also accepts an optional second parameter for setting whether or not you would like to load views from the package.  By default, CodeIgniter will load views from a package.  Setting the second parameter to false will stop that.  Here is an example:</p>
<p>&nbsp;</p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;load-&gt;add_package_path(APP_PATH . '/third_party/package_name', FALSE);
</pre>
<p>&nbsp;</p>
<p>CodeIgniter also provides methods for removing an application package path.  Here are examples of removing an application package path:</p>
<p>&nbsp;</p>
<pre class="brush: php; title: ; notranslate">
// Remove most recently added path
$this-&gt;load-&gt;remove_package_path();

// Remove specific path
$this-&gt;load-&gt;remove_package_path(APP_PATH . '/third_party/package_name');
</pre>
<p>&nbsp;</p>
<p>The documentation on application packages is located under the section on the <a href="http://codeigniter.com/user_guide/libraries/loader.html" title="Loader Class">Loader Class</a>, however I don’t see them utilized (or discussed) very often.</p>
<p>&nbsp;</p>
<p>Getting back to the original problem, the solution I proposed was to create two new CodeIgniter instances (mobile site and API) and to add the main site <code>/application</code> folder as an application package when needed.  This would provide access to any existing resources that might be needed but still allow the flexibility to create custom controllers and views tailored to the different versions of the application.  The only downside I see with this approach is that it becomes difficult to override resources in a package since adding a package <strong>prepends</strong> the path to the list of directories.  The workaround would be to add and remove package paths depending on the file you would like to load.</p>
<p>&nbsp;</p>
<p>The developer also raised the question of whether or not using application paths would incur additional loading time for the end-user.  I have not run any benchmarks but I would assume that since CodeIgniter is only checking an additional directory for a file the usage of application paths would have a negligible effect on application performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://eric-famiglietti.com/2012/01/11/get-a-handle-on-application-packages/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Form validation best practices</title>
		<link>http://eric-famiglietti.com/2011/12/24/form-validation-best-practices/</link>
		<comments>http://eric-famiglietti.com/2011/12/24/form-validation-best-practices/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 04:33:02 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[form validation]]></category>

		<guid isPermaLink="false">http://ericfamiglietti/?p=1135</guid>
		<description><![CDATA[<p>Posted in <a href="http://eric-famiglietti.com/tumblog/video/">Video</a></p><p></p>As I am still fairly new to CodeIgniter, I write down a lot of tips and tricks that may not be entirely obvious from reading through the documentation. I collect these from various blogs, forum posts, or Stack Overflow questions. [...]]]></description>
				<content:encoded><![CDATA[<p>Posted in <a href="http://eric-famiglietti.com/tumblog/video/">Video</a></p><p></p><p>As I am still fairly new to CodeIgniter, I write down a lot of tips and tricks that may not be entirely obvious from reading through the documentation.  I collect these from various blogs, forum posts, or Stack Overflow questions.  Here I have compiled some best practices that I follow when using the form validation library.</p>
<p>&nbsp;</p>
<h3>Putting form validation in configuration files</h3>
<p>This shouldn&#8217;t be a secret to anyone, but storing your form <a href="http://codeigniter.com/user_guide/libraries/form_validation.html#savingtoconfig">validation rules in a configuration file</a> is great way to cut down on the size of your controllers.  Anytime I’m not dynamically assigning validation rules and have a list of static rules I like to do this.</p>
<p>&nbsp;</p>
<h3>Changing default error delimiters</h3>
<p>By default, CodeIgniter wraps error messages in paragraph tags, which isn&#8217;t very useful.  We all know how to change the error delimiters, but we have to do so each time we load the library.  Chris Schmitz shares a great tip for <a href="http://chris-schmitz.com/changing-default-error-delimiters-in-codeigniter/">changing  the default error delimiters</a>.  Simply extend the form validation library and set them in the constructor.  When the form validation library is loaded your custom error delimiters will be set automatically and you can still override them when you need to.</p>
<p>&nbsp;</p>
<h3>Creating new validation functions</h3>
<p>CodeIgniter’s form validation library provides many useful validation functions, but it is certainly far from complete.  One might be tempted to use the callback mechanism for utilizing your own validation functions.  The downside to this approach is that you won’t be able to access them from other controllers.  If you need to utilize custom validation functions from multiple controllers, extend the form validation class and place your new validation methods there.</p>
<p>&nbsp;</p>
<h3>Validation functions in models</h3>
<p>If you want to take form validation a step further and store validation functions in your models there is a great <a href="http://codeigniter.com/forums/viewthread/205469/">post in the CodeIgniter forums</a> that explains how to do so.  This is useful if you have validation functions that rely heavily on methods in your models or could be considered part of the model.  The basic idea is that you extend the base controller with a validation function that calls model functions.</p>
<p>&nbsp;</p>
<h3>Ordering of validation rules</h3>
<p>When setting validation rules, I always make sure to check the order of the rules.  I generally put my filtering rules before my validation rules.  I also try to put validation rules that don&#8217;t require a database query before those that do.  It makes no sense to validate the length of a string after you have queried the database to see if it already exists.  These are just small optimizations and probably won’t have too much of an effect on performance but is something I always like to check.</p>
<p>&nbsp;</p>
<p>I hope these suggestions will be of good use to anyone that is new to CodeIgniter or inexperienced with the form validation library.  For those who have used it, are there any tips or best practices that you&#8217;ve found to be useful?</p>
]]></content:encoded>
			<wfw:commentRss>http://eric-famiglietti.com/2011/12/24/form-validation-best-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easily generate QR codes using gc-qrcode</title>
		<link>http://eric-famiglietti.com/2011/12/14/easily-generate-qr-codes-using-gc-qrcode/</link>
		<comments>http://eric-famiglietti.com/2011/12/14/easily-generate-qr-codes-using-gc-qrcode/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 03:35:02 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[qr codes]]></category>
		<category><![CDATA[sparks]]></category>

		<guid isPermaLink="false">http://ericfamiglietti/?p=1053</guid>
		<description><![CDATA[<p>Posted in <a href="http://eric-famiglietti.com/category/codeigniter/" title="Codeigniter">Codeigniter</a></p>It it with great excitement that I announce my first contribution to the CodeIgniter/open source community. gc-qrcode is a CodeIgniter spark for creating QR codes through the Google Chart Tools API. Here is an example that shows how easy it [...]]]></description>
				<content:encoded><![CDATA[<p>Posted in <a href="http://eric-famiglietti.com/category/codeigniter/" title="Codeigniter">Codeigniter</a></p><p>It it with great excitement that I announce my first contribution to the CodeIgniter/open source community.  gc-qrcode is a CodeIgniter spark for creating QR codes through the Google Chart Tools API.  Here is an example that shows how easy it is to create generate QR codes:</p>
<p>&nbsp;</p>
<pre class="brush: php; auto-links: false; title: ; notranslate">
// Configure QR code
$this-&gt;gc_qrcode-&gt;size(350)
                -&gt;data('http://example.com/')
                -&gt;output_encoding('UTF-8')
                -&gt;error_correction_level('L')
                -&gt;margin(0);

// Get URL to QR code
$this-&gt;gc_qrcode-&gt;url();

// Generate &lt;img&gt; tag containing QR code
$this-&gt;gc_qrcode-&gt;img();
</pre>
<p>&nbsp;</p>
<p>For those of you who don’t know what a spark is, I encourage you to checkout <a href="http://getsparks.org/">http://getsparks.org/</a>.  Sparks is a package management system for CodeIgniter similar to RubyGems for Ruby.  I first found out about sparks in August when I attended CICON 2011.  Since then I have been itching to create one. Lately I have been working a lot with QR codes so I decided to package up some code and release it as a spark.</p>
<p>&nbsp;</p>
<p>Checkout gc-qrcode on <a href="http://getsparks.org/packages/gc-qrcode/versions/HEAD/show">Sparks</a> or <a href="https://github.com/eric-famiglietti/gc-qrcode">GitHub</a> for more documentation or to download the package.</p>
]]></content:encoded>
			<wfw:commentRss>http://eric-famiglietti.com/2011/12/14/easily-generate-qr-codes-using-gc-qrcode/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>First post</title>
		<link>http://eric-famiglietti.com/2011/12/12/first-post/</link>
		<comments>http://eric-famiglietti.com/2011/12/12/first-post/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 02:39:38 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://ericfamiglietti/?p=889</guid>
		<description><![CDATA[<p>Posted in <a href="http://eric-famiglietti.com/tumblog/articles/">Articles</a></p>I have been meaning to build a personal website for some time now and have finally gotten around to making one.  I will primarily be using this site as a way to give back to the web development community by [...]]]></description>
				<content:encoded><![CDATA[<p>Posted in <a href="http://eric-famiglietti.com/tumblog/articles/">Articles</a></p><p>I have been meaning to build a personal website for some time now and have finally gotten around to making one.  I will primarily be using this site as a way to give back to the web development community by sharing useful tips and creating tutorials.  I will also be using this website to showcase some of the work that I have done.  Most of the articles that I post will be centered around PHP and CodeIgniter although I may occasionally post about something else.</p>
<p>&nbsp;</p>
<p>I hope you find my posts informative and useful.  I would greatly appreciate any feedback that you can provide, whether good or bad.  Thanks for checking out my site.</p>
<p>&nbsp;</p>
<p>- Eric Famiglietti</p>
]]></content:encoded>
			<wfw:commentRss>http://eric-famiglietti.com/2011/12/12/first-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
