<?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>A Path Less Taken &#187; PHP Development</title>
	<atom:link href="http://www.legendrefamily.org/blog/category/php-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.legendrefamily.org/blog</link>
	<description>Breaking with convention in a very conventional fashion.</description>
	<lastBuildDate>Tue, 11 Oct 2011 03:19:11 +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>Getting Started with Spot ORM</title>
		<link>http://www.legendrefamily.org/blog/2011/10/getting-started-with-spot-orm/</link>
		<comments>http://www.legendrefamily.org/blog/2011/10/getting-started-with-spot-orm/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 03:19:11 +0000</pubDate>
		<dc:creator>JJ</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.legendrefamily.org/blog/?p=1513</guid>
		<description><![CDATA[In a recent post I touted the coolness factor of the Spot ORM. Based on a response to that post I prepared this short tutorial on how to get started. This is culled from personal experience and guidance that I received from the software&#8217;s author. I hope this is helpful to you if you are [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>In a recent post I touted the coolness factor of the Spot ORM.  Based on a response to that post I prepared this short tutorial on how to get started.  This is culled from personal experience and guidance that I received from the software&#8217;s author.  I hope this is helpful to you if you are interested in giving Spot a try.</p>
<p><span id="more-1513"></span></p>
<p>First, download the code from github <a href="https://github.com/actridge/Spot" title="Github\Spot">here</a> and copy the included folder where it can be referenced by your project.  I renamed my folder Spot and put it in the modules folder for my project.  Your approach my vary.</p>
<p>Next we set up the Spot objects for use.  Here is a MySql example.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">&quot;modules/Spot/Config.php&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$cfg</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Spot\Config <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$adapter</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cfg</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addConnection</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mysql://username:password@localhost/databasename'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$mapper</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Spot\Mapper <span style="color: #009900;">&#40;</span><span style="color: #000088;">$cfg</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Right away you can see that Spot uses the namespace Spot.  It&#8217;s a trivial observation, but it might save you a little frustration when you are just getting started.  Next we need to define our entity.  Spot is based on the Data Mapper design pattern so the Entity is sort of a dumb object, but we need to define it anyway.  Here is a basic entity example.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
	Author Mapper
*/</span>
<span style="color: #000000; font-weight: bold;">class</span> Authors <span style="color: #000000; font-weight: bold;">extends</span> Spot\Entity
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Specify the data source (table for SQL adapters)</span>
    <span style="color: #000000; font-weight: bold;">protected</span> static <span style="color: #000088;">$_datasource</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;authors&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Define your fields as public class properties</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> fields <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span>
		<span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'int'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'primary'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'serial'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'firstname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'string'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'lastname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'string'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'sex'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'string'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> relations <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Authors Relationship</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span>
		<span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'books'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> 
			<span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'HasMany'</span><span style="color: #339933;">,</span> 
				<span style="color: #0000ff;">'entity'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Books'</span><span style="color: #339933;">,</span> 
				<span style="color: #0000ff;">'where'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'author_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">':entity.id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ASC'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As you can see the Entity defines both the fields it cares about as well as foreign key related fields.  The naming conventions are pretty standard.  Note the $_datasource property which defines the actual data table where the entity is stored.  I don&#8217;t think this is necessary in the above example, but I wanted to include it as a reference for how you might refer to an authors mapper where the table name was something other than authors.  Also note the use of the singular author_id in the HasMany definition array.  This is by convention.  Now let&#8217;s use this Entity to do something useful.  Let&#8217;s get a single author.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$author</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">first</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Authors'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'lastname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$lastname</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastname</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;, &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">firstname</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;(&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sex</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;)&lt;/br&gt;&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As you can see it is trivial to access the individual record retrieved from the DB.  In this example there could be more than one authors with the same last name, but only the first one would be returned and acted upon.  Now let&#8217;s create a new author entry.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$author</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Authors <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">firstname</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;John&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastname</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Smith&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sex</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Male&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$mapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Again, pretty simple stuff.  The Data Mapper pattern takes care of all the dirty translation into the underlying data store.  You just work at the object level which is far more intuitive for a programmer.  Updating the entity is just as easy.  You simply retrieve the entity you want to update as shown above, assign new values to the properties you want to change and call the same save method on the mapper class.  That&#8217;s it. It looks like this.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$author</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mapper</span><span style="color: #339933;">-&gt;</span> <span style="color: #004000;">first</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Authors&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;firstname&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;John&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lastname&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Smith&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$author</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sex</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Female&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$mapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>What is John up to anyway?  Well, at least you get the idea.  Deleting the record is just as easy.  Here is an example.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$author</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mapper</span><span style="color: #339933;">-&gt;</span> <span style="color: #004000;">first</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Authors&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;firstname&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;John&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lastname&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Smith&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$mapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>That&#8217;s all there is to deleting.  Now let&#8217;s look at some other useful commands.  Here we select all entities matching a specific criteria and order the result.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$authors</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">all</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Authors&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lastname&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$author_sirname</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sex&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Male&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">order</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lastname&quot;</span> <span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;desc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$authors</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$authors</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$author</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Do something</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here is a more complicated example using where.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$authors</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">all</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Authors&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lastname :like&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$sirname</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;firstname :like&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;OR&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;AND&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">order</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lastname&quot;</span> <span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;desc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Shifting examples a bit here, below is an actual working example of a HasManyThrough relationship.  In this example the Tags table is related to the Items table through the Items_Tags table.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
	Tags Mapper
*/</span>
<span style="color: #000000; font-weight: bold;">class</span> Tags <span style="color: #000000; font-weight: bold;">extends</span> Spot\Entity
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Specify the data source (table for SQL adapters)</span>
	<span style="color: #000000; font-weight: bold;">protected</span> static <span style="color: #000088;">$_datasource</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;tags&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Define your fields as public class properties</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> fields <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span>
		<span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'int'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'primary'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'serial'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'string'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'user_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'int'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'index'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Items Relationship</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> relations <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span>
		<span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'items'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span>
			<span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'HasManyThrough'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'entity'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Items'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'where'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">':throughEntity.items_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'throughEntity'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Items_Tags'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'throughWhere'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tags_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">':entity.id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'created_on'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'desc'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Based on this example we can select all Items associated with a group of tags.  Two things to note about the example below.  First, the user_id is another relation of a tag to a user which is defined in the tag&#8217;s entity.  Second, the nested foreach behavior is (I think, but I can&#8217;t recall for certain) an implementation of lazy loading of the associated item records for the tags.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$tags</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">all</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tags'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$tag</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'user_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> config<span style="color: #339933;">::</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000088;">$tags</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tag</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$buffer</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">something_useful</span> <span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$buffer</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>So that&#8217;s it.  A quick and easy introduction to the basic use of Spot.  If you are interested then let <a href="http://www.vancelucas.com/" title="Vance Lucas">Vance Lucas</a> (the author) know and hopefully he&#8217;ll put more time into developing the code and the documentation into an even more accessible ORM than it already is.  Thanks for your interest and good luck with Spot.</p>
<div class="shr-publisher-1513"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.legendrefamily.org%2Fblog%2F2011%2F10%2Fgetting-started-with-spot-orm%2F' data-shr_title='Getting+Started+with+Spot+ORM'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.legendrefamily.org%2Fblog%2F2011%2F10%2Fgetting-started-with-spot-orm%2F' data-shr_title='Getting+Started+with+Spot+ORM'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.legendrefamily.org/blog/2011/10/getting-started-with-spot-orm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Tale of 2 PHP ORM&#8217;s</title>
		<link>http://www.legendrefamily.org/blog/2011/08/a-tale-of-2-php-orms/</link>
		<comments>http://www.legendrefamily.org/blog/2011/08/a-tale-of-2-php-orms/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 02:03:47 +0000</pubDate>
		<dc:creator>JJ</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.legendrefamily.org/blog/?p=1483</guid>
		<description><![CDATA[No, this is not about Doctrine and Propel, although I&#8217;m sure those are both really fine PHP ORM tools if you are willing to endure the learning curve. This is about 2 lesser known but notable ORM tools that deserve a nod of recognition. I&#8217;ve tried a number of PHP ORM tools over the last [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>No, this is not about Doctrine and Propel, although I&#8217;m sure those are both really fine PHP ORM tools if you are willing to endure the learning curve.  This is about 2 lesser known but notable ORM tools that deserve a nod of recognition.  I&#8217;ve tried a number of PHP ORM tools over the last year and many of them had merit.  In fairness, as you look at one attempt you begin to realize how much each of them owes to those that came before them.  There are so many variations on a theme that you can easily get confused and give up in frustration.  But my recent efforts have revealed two that I find very useful and note worthy depending on your project.  Here is a quick run down on each.</p>
<p><span id="more-1483"></span></p>
<h4>Spot</h4>
<p><a href="https://github.com/actridge/Spot" title="Spot - The PHP DataMapper Implementation">Spot</a> is the second attempt at a Data Mapper ORM implementation for PHP by <a href="http://www.vancelucas.com/" title="Vance Lucas">Vance Lucas</a>.  Vance&#8217;s first attempt was titled <a href="http://phpdatamapper.com/">PHPDataMapper</a> a was and nifty attempt in it&#8217;s own right.  Vance took what he learned and created Spot, the 2.0 implementation of his original ORM.  Spot has straight forward configuration through object inheritance and is very easy to use once you get the hang of it.  Spot supports HasOne, HasMany and HasManyThrough relationships.  It solves the Lazy Loading problem and is hands down the best implementation of association management through an ORM model that I&#8217;ve encountered.  The available documentation is spartan right now (I&#8217;m being kind), but Vance was kind enough to give me the few pointers I needed to get working quickly.  If anyone is interested let me know and I can provide some demo code in a separate post.</p>
<p>Given how much I have enjoyed using Spot, I have only one minor quibble.  As I looked at the implementation, I could not find a way to build Models dynamically at run time rather than pre-define them.  Granted this is not a problem for many projects, but it was an issue for the last thing I was doing.  Having said that if I do any PHP projects in the future with static data models then I&#8217;ll be using Spot to do them.  If you have a similar need and value power and simplicity then I encourage you to give Spot a go!</p>
<h4>RedBeanORM</h4>
<p><a href="http://www.redbeanphp.com/" title="RedBeanORM">RedBeanORM</a> is the marvelous dynamic ORM by <a href="http://www.gabordemooij.com/" title="Gabor de Mooij">Gabor de Mooij</a>. For anyone who has read my blog you probably know that I have an on-going love / hate relationship with RedBean.  This ORM is crazy easy to use as it builds the data tables and relationships on the fly as you run your program.  The ORM picks the most appropriate type for your data items and adds any fields that are missing to the table.  It even builds associations through intersection tables.  It is such a cool concept that I am constantly drawn to it.  That is except for the fact that it builds associations through INTERSECTION TABLES!  I was never a fan of this and I posted in the forum that using only intersection tables was overkill for many common relational models.</p>
<p>After much waiting I&#8217;m happy to report that as of version 2.0 Gabor has added N:1 relationship support that implements a foreign key!  It&#8217;s like mana from digital heaven!  The implementation is not as user friendly as Spot (I have to do some of the work myself, gasp!), but it does go a long way towards making the resulting data model more practical for larger relational problems.  This coupled with the dynamic nature of RedBeanORM make it a very compelling tool.  For my dynamic model science project I&#8217;m going to use RedBean.  I&#8217;m not sure where it will end up, but I&#8217;m excited to jump in and give it another try!</p>
<p>So there you have it.  A tale of two PHP ORM&#8217;s that deserve a little recognition for their authors&#8217; hard work and vision to make something better than what was there before.  It is the true spirit of open source and I salute both of them for doing such a great job.  I&#8217;m excited about ORM tools again, and that&#8217;s saying something!</p>
<div class="shr-publisher-1483"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.legendrefamily.org%2Fblog%2F2011%2F08%2Fa-tale-of-2-php-orms%2F' data-shr_title='A+Tale+of+2+PHP+ORM%27s'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.legendrefamily.org%2Fblog%2F2011%2F08%2Fa-tale-of-2-php-orms%2F' data-shr_title='A+Tale+of+2+PHP+ORM%27s'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.legendrefamily.org/blog/2011/08/a-tale-of-2-php-orms/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Framework Free PHP</title>
		<link>http://www.legendrefamily.org/blog/2011/06/framework-free-php/</link>
		<comments>http://www.legendrefamily.org/blog/2011/06/framework-free-php/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 18:48:12 +0000</pubDate>
		<dc:creator>JJ</dc:creator>
				<category><![CDATA[Formed]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[formed]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php framework]]></category>

		<guid isPermaLink="false">http://www.legendrefamily.org/blog/?p=1459</guid>
		<description><![CDATA[My latest experiment is building a new site without leveraging one of the many MVC Frameworks that are out there today. I decided to approach a new project using the following criteria: Simple can be better sometimes. Frameworks don&#8217;t do EVERYTHING well. Components that do one job and do it well are easier. Easier can [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>My latest experiment is building a new site without leveraging one of the many MVC Frameworks that are out there today.  I decided to approach a new project using the following criteria:</p>
<ul>
<li>Simple can be better sometimes.</li>
<li>Frameworks don&#8217;t do EVERYTHING well.</li>
<li>Components that do one job and do it well are easier.</li>
<li>Easier can be more productive.</li>
</ul>
<p>To be fair, my results were a mixed bag, but so far I&#8217;m happy with the experiment.  The site is not open to the public yet, but you can check out the current version <a href="http://jjlegendre.com/brain/" title="Your Brain">here</a> if you are curious how it is going.  Below is a brief out line of the tools I used and the results (good, bad and ugly)!</p>
<p><span id="more-1459"></span></p>
<p>The Tools:</p>
<ul>
<li><a href="http://jjlegendre.com/formed/" title="Formed">Formed</a> &#8211; Formed is a PHP HTML form generator class that I created and released into the public domain.  It does one thing (render styled HTML forms using metadata and templates) and even though it is alpha right now it does it pretty well.  The code still needs to be more defensive, but I&#8217;m pleased with the results.  You can check it out and give it a try if you have a need.  If you come up with interesting templates please share with them me and I&#8217;ll include them in the zip file.</li>
<li><a href="http://gluephp.com/" title="GluePHP">GluePHP</a> &#8211; GluePHP is an excellent little PHP micro-framework that does one simple thing, it maps URL&#8217;s to Classes.  It is a simple and elegant implementation of a front controller design pattern.  Glue was created by Joe Topjian.</li>
<li><a href="http://www.raintpl.com/" title="Rain.TPL">Rain.TPL</a> &#8211; Rain.TPL is an easy PHP template engine.  Rain achieves ease of use by having only 8 Tags and 4 Methods.  This was my first time using Rain and so far I&#8217;m very pleased.  Rain is created and maintained by the Rain Team.</li>
<li><a href="http://960.gs/" title="960 Grid System">960 Grid System</a> &#8211; A sensible and easy to use CSS framework.  I&#8217;m a long time fan of this excellent work.</li>
<li><a href="http://www.redbeanphp.com/" title="RedBeanPHP ORM">RedBeanPHP</a> &#8211; RedBean is an ORM that I keep coming back to because it is so darn easy to use.  Foreign keys require more effort, but the ease of use is worth the effort.</li>
<li><a href="http://wixel.net/product-posts/open-source/gump-a-class-for-php-input-validation/" title="GUMP - A Class for PHP Input Validation">GUMP</a> &#8211; <a href="https://github.com/Wixel/GUMP" title="GUMP on github">GUMP</a> is a class for PHP input validation by the folks at <a href="http://wixel.net/" title="Wixel">Wixel.net</a>.  It easy to use and has a good selection of basic validators.  It makes a nice complement for Formed as opposed to including a validator in it myself.</li>
<li><a href="http://jquery.com/" title="jQuery">jQuery</a> &#8211; The Javascript library.  Write less, do more.</li>
<li>Other bits or random code I created for the site.  One stand out is Monster, the http cookie managing class.</li>
</ul>
<p>The Results:</p>
<p>Let me start by saying that I do not intend to criticize anyone&#8217;s code.  All of the solutions that I used did their job as advertised and did it well.  What I&#8217;m providing is my perspective of how doing that job added to or detracted from the ease of creating my web application.</p>
<p>The Good:</p>
<p>GluePHP was a great front controller.  It performed exactly as expected and did a really great job.  It handled query string parameters via regular expressions and just plain worked.  Rain.TPL was equally compelling.  It was super easy to use, fast and did a great job helping me lay out templates.  I did experience a problem with query string parameters buried in sensible URL&#8217;s without the ?, but it was user error.  I&#8217;ll explain that more below.  960 Grid System continued to be a programmers friend as it is just so easy to use.  I can&#8217;t say enough good things about that little CSS Framework.</p>
<p>The Not as Good:</p>
<p>RedBeanPHP is a solution that continues to vex me.  I keep coming back to it because it is so darn cool, but it does have some limitations that are frustrating.  RedBean excels at dehydrating and hydrating objects for easy database storage.  What it does not excel at is referential integrity.  I does not handle foreign keys.  You can do it yourself, but this means managing decisions about cascading deletes on your own.  The whole point of an ORM is hide all the mechanics of that from the programmer.  RedBean does not quite see it that way.  That&#8217;s why I contend that the ORM label is somewhat miss-leading.  I expect my ORM to not create intersection tables by default for every join I ask it to make.  RedBean does that.  The lack of referential integrity is partially what leads to RedBean&#8217;s coolest feature, programming the DB on the fly in code rather than writing SQL.  It&#8217;s that same lack of true ORM design time metadata that prevents it from building foreign keys.  RedBean gives you tools to help with this, but eventually you realize that you are implementing those features yourself.  For me the ORM of choice question is still outstanding, but if you need an object hydrator / dehydrator then you should look no further than RedBean.  At that function it is the BOMB!</p>
<p>My understanding of the Rain.TPL was not as good as it should have been.  I was having a problem with clean URL&#8217;s and the WYSIWYG features with Rain.TPL.  I posted a question and the following Monday the Rain team provided a great answer.  Unfortunately I wanted to plow ahead so I converted all my links with query strings to hidden form posts to overcome the issue.  It worked and jQuery was excellent as usual in accomplishing this, but it was not an ideal solution.  Having said that I still think Rain.TPL is the most compelling and easiest PHP template engine I&#8217;ve used to date.</p>
<p>The Bad:</p>
<p>The PHP Framework that I&#8217;ve used the most is Kohana.  Right out of the gate I started missing some of the Kohana helper functions.  I had to locate and update an older cookie management class that I re-dubbed Monster.  That plus Formed and RedBean PHP helped me get the authentication working.  Next as I tried to build CRUD operations I started writing my own &#8220;controllers&#8221; which were just objects that go called by the GluePHP class.  This worked fine, but I quickly realized that I was lacking a model.  Since I was trying to be fast I started adding the additional code around calls to RedBean to achieve more model like behavior from methods in my controller classes.  This was a poor architecture, but it was better than writing my own models so that&#8217;s what I went with.  This meant that the solution was not quite as structured as I would have preferred.</p>
<p>The Road Ahead</p>
<p>The project went fast enough and well enough that I think I&#8217;ll try it again.  I have to say that next time I&#8217;ll be looking to find some new combinations that may suite my needs and programming practices better.  I actually did recently create the Formed web site using GluePHP and Rain.TPL.  They continue to work great for rapid site deployment.  For that site I also deployed Alex Gorbatchev&#8217;s excellent Javascript tool <a href="http://alexgorbatchev.com/SyntaxHighlighter/" title="SyntaxHighlighter">SyntaxHighlighter</a>.  This allowed me to create a far more visually appealing and useful Tutorial for the Formed web site.  It&#8217;s still pretty plain right now, but given that the whole site took just an hour or two to put together I&#8217;m very happy with the outcome.</p>
<div class="shr-publisher-1459"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.legendrefamily.org%2Fblog%2F2011%2F06%2Fframework-free-php%2F' data-shr_title='Framework+Free+PHP'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.legendrefamily.org%2Fblog%2F2011%2F06%2Fframework-free-php%2F' data-shr_title='Framework+Free+PHP'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.legendrefamily.org/blog/2011/06/framework-free-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Formed</title>
		<link>http://www.legendrefamily.org/blog/2011/06/formed/</link>
		<comments>http://www.legendrefamily.org/blog/2011/06/formed/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 03:15:30 +0000</pubDate>
		<dc:creator>JJ</dc:creator>
				<category><![CDATA[Formed]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[formed]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.legendrefamily.org/blog/?p=1410</guid>
		<description><![CDATA[Please allow me to introduce Formed, a simple PHP based HTML form generator class. The primary objectives I had when creating Formed were: Simple to Use Customizable using HTML formatting or CSS Self Contained (no framework dependencies) Template Support I created a home site for it in the event that people wanted to try it, [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Please allow me to introduce <a href="http://jjlegendre.com/formed" title="Formed PHP HTML Form Generator">Formed</a>, a simple PHP based HTML form generator class.  The primary objectives I had when creating Formed were:</p>
<ul>
<li>Simple to Use</li>
<li>Customizable using HTML formatting or CSS</li>
<li>Self Contained (no framework dependencies)</li>
<li>Template Support</li>
</ul>
<p>I created a home site for it in the event that people wanted to try it, make suggestions (be nice), provide changes, that kind of thing.  It is not on GitHub because it does not warrant that level of control at this point.  The site is built on Joomla and the template is one of the defaults that I barely modified so it looks funny.  If you go to the link above you can down load the zip file or read the tutorial.  If you are interested check it out and post a comment here.</p>
<p>As a side note, PHP CMS tools must be in a tragic state these days.  Joomla was easy enough to get working, but it is far from intuitive when you first use it.  By contrast Drupal I could not even get working on Apache.  To be fair I did not put much time into either one, but isn&#8217;t that the point of a CMS?  It is a sorry state of affairs.</p>
<div class="shr-publisher-1410"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.legendrefamily.org%2Fblog%2F2011%2F06%2Fformed%2F' data-shr_title='Formed'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.legendrefamily.org%2Fblog%2F2011%2F06%2Fformed%2F' data-shr_title='Formed'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.legendrefamily.org/blog/2011/06/formed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A New PHP Framework</title>
		<link>http://www.legendrefamily.org/blog/2011/05/a-new-php-framework/</link>
		<comments>http://www.legendrefamily.org/blog/2011/05/a-new-php-framework/#comments</comments>
		<pubDate>Sat, 21 May 2011 15:03:55 +0000</pubDate>
		<dc:creator>JJ</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[php framework]]></category>

		<guid isPermaLink="false">http://www.legendrefamily.org/blog/?p=1397</guid>
		<description><![CDATA[One thing I love about the open source community is all you need is another motivated, talented programmer with an opinion and change happens. I just found another new PHP Framework that has waded into the fray (at least from my perspective). It&#8217;s call DOOPHP and it has an interesting take on magic methods. The [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>One thing I love about the open source community is all you need is another motivated, talented programmer with an opinion and change happens.  I just found another new PHP Framework that has waded into the fray (at least from my perspective).  It&#8217;s call <a href="http://www.doophp.com/" title="DOOPHP">DOOPHP</a> and it has an interesting take on magic methods.  The author&#8217;s contention on the about page is that magic methods rob frameworks of performance.  I don&#8217;t know if that&#8217;s worth building a new solution over, but it could be worth a look. Enjoy.</p>
<div class="shr-publisher-1397"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.legendrefamily.org%2Fblog%2F2011%2F05%2Fa-new-php-framework%2F' data-shr_title='A+New+PHP+Framework'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.legendrefamily.org%2Fblog%2F2011%2F05%2Fa-new-php-framework%2F' data-shr_title='A+New+PHP+Framework'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.legendrefamily.org/blog/2011/05/a-new-php-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

