<?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>mikhail panchenko / blog &#187; framework</title>
	<atom:link href="http://mihasya.com/blog/category/framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://mihasya.com/blog</link>
	<description>good things now come in packages of three</description>
	<lastBuildDate>Sat, 14 Jan 2012 07:28:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Project ADD</title>
		<link>http://mihasya.com/blog/project-add/</link>
		<comments>http://mihasya.com/blog/project-add/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 03:59:42 +0000</pubDate>
		<dc:creator>mihasya</dc:creator>
				<category><![CDATA[dev]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[ked]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://mihasya.com/blog/?p=42</guid>
		<description><![CDATA[Just had another &#8220;AWESOME&#8221; idea today that fits nicely with my desire to create something that can stay with an app as it grows. Once ked_core functionality is more or less finalized (sooner rather than later), I&#8217;m going to start hacking up a pecl extension that will mimic ked_core&#8217;s behavior perfectly, thus allowing the developer [...]]]></description>
			<content:encoded><![CDATA[<p>Just had another &#8220;AWESOME&#8221; idea today that fits nicely with my desire to create something that can stay with an app as it grows. Once <strong>ked_core</strong> functionality is more or less finalized (sooner rather than later), I&#8217;m going to start hacking up a <strong>pecl extension</strong> that will mimic ked_core&#8217;s behavior perfectly, thus allowing the developer to simply comment out the <strong>require_once</strong> statement in <strong>index.php</strong> having installed the extension, maintaining the exact same behavior, but with less overhead, since the framework&#8217;s core will now be compiled.</p>

<p>As Crowley put it, that is overkill. I know. But I need to learn how to write PHP extensions <img src='http://mihasya.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p>I realize that I&#8217;ve started more projects in the last month than I have in the last 2 years. I am going to prioritize things a little bit &#8211; I want to focus on <strong>ked_duffel</strong> (the SVN delivery system) to start out, then once that&#8217;s functional use it to update mihasya.com&#8217;s framework files, then tinker with the framework a little bit, using duffel to test it on mihasya.com.</p>

<p>Once I&#8217;m happy with its functionality, I&#8217;ll start compiling a pecl skeleton and trying to fill it out, making heavy use of my rollover minutes &#8211; to call <a href="http://rcrowley.org">Crowley</a> with dumb C questions.</p>

<p>Of course, all of this is going to have to wait a little bit &#8211; I realized recently that nearly two weeks had passed without me having done any paid work. Someone has to pay for Crowley&#8217;s lapdances, so I am going to dedicate a bit more time to Yahoo! stuff in the coming couple of weeks.</p>
]]></content:encoded>
			<wfw:commentRss>http://mihasya.com/blog/project-add/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionless Views: The Quest For Perfection</title>
		<link>http://mihasya.com/blog/actionless-views-the-quest-for-perfection/</link>
		<comments>http://mihasya.com/blog/actionless-views-the-quest-for-perfection/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 06:33:20 +0000</pubDate>
		<dc:creator>mihasya</dc:creator>
				<category><![CDATA[dev]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[ked]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://mihasya.com/blog/?p=39</guid>
		<description><![CDATA[The idea here is being able to route ked_core to a static template w/o executing any action or having defined one. For example, if you want your header to just be static HTML and want that in a separate header.tpl file, there&#8217;s no reason you should have to define controller-&#62;header() just to access that. I [...]]]></description>
			<content:encoded><![CDATA[<p>The idea here is being able to route ked_core to a static template w/o executing any action or having defined one. For example, if you want your header to just be static HTML and want that in a separate <strong>header.tpl</strong> file, there&#8217;s no reason you should have to define <strong>controller-&gt;header()</strong> just to access that.</p>

<p>I went through several iterations on this code (some of it is in svn, though not all &#8211; I had to start the repository over b/c I forgot to add trunk/ branches/ and tags/ <img src='http://mihasya.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  ) so here is my approximate thought process.</p>

<h4>Step 1: Check the .tpl exists</h4>

<p>I should have had this check anyway, but before I did not realize the need &#8211; there needed to be an action defined for the view to be rendered anyway, so I focused on that, and that seemed to take care of itself. The following line would just throw an Exception
<pre>$reflector = new ReflectionMethod($this, $action);</pre>
which would then just be handled and displayed nicely with ked&#8217;s exception handler.</p>

<p>But now I really do need to actually handle this on its own, since the action might not even exist &#8211; WHAT WILLS WAE DO THARN?!</p>

<p><strong>The Wrong Way:</strong>
<pre>if (ked::$smarty-&gt;template_exists($tpl)) { ...</pre>
No. That is clearly a file system operation that will be run every single time, even though we know that 99% of the time, unless the developer is a total and complete dunce, the template is there. Then there&#8217;s the additional fs read to load the template.</p>

<p><strong>The Right Way:</strong></p>

<p>The right way looks sort of hackish, but bear with me. Smarty is really dumb about how $smarty-&gt;display() works. It never returns anything. If it fails to load the template, it prints a warning. Can&#8217;t really check to see if it succeeded in any robust way, so this will do:
<pre>...
ob_start();
ked::$smarty-&gt;display($tpl);
$viewContent = ob_get_contents();
ob_end_clean();
if (!$this-&gt;_skipAssign) ked::$smarty-&gt;clear_all_assign();
if (strpos($viewContent, "&lt;b&gt;Warning&lt;/b&gt;:  Smarty error: unable to read resource:")!==false)
  throw new kedException('The view "'.$this-&gt;_view.'" was not found')
...</pre>
I just check for the presence of the warning and throw an exception if it&#8217;s there. Now, normally, I am not a fan of throwing exceptions, but in this spot it&#8217;s ok, and I&#8217;ll explain later why. The short explanation: because we&#8217;re not catching it.</p>

<h4>Step 2: Make _execute Not Choke On Absent Action</h4>

<p><strong>The Wrong Way:</strong></p>

<p>This is where I originally threw an exception, but a comment by <a href="http://cowsandmilk.net/">David Hall</a> made me pause.
<pre>...
try {
  $reflector = new ReflectionMethod($this, $action);
} catch (Exception $e) {
  $this-&gt;_skipAssign = true; //tell _render to skip smarty-&gt;assign related steps for this.
  return false;
}
...</pre>
So here, we just try to create a <a href="http://us.php.net/reflection">ReflectionMethod</a> as we normally would for the action, but if we see an exception, we just return; out of _execute and go on to _render. It&#8217;s sort of sloppy (because what if ReflectionMethod&#8217;s __construct() threw an exception for some other reason) and the real problem is this: we are creating and catching an exception in framework code. Every time an actionless view is called, this will happen. David pointed out that the exception is itself an object and can be quite heavy.</p>

<p><strong>The Right Way:</strong></p>

<p>This caused me to revert to my original intuition for how to do this:
<pre>...
if (!method_exists($this, $action)) {
  $this-&gt;_skipAssign = true; //tell _render to skip smarty-&gt;assign related steps for this.
  return false;
}
...</pre>
We just check if the method exists; if not, we set a variable that tells _render to forego assigning template variables that would have been set in the action had it existed and return false. (Right now, just returning would suffice, but I feel a disturbance in the force that tells me that this false value will come in handy somewhere down the line).</p>

<h4>Step 3 (bonus): Make _render More Efficient</h4>

<p>I alluded to this in an earlier code snippet: now that we can know for sure if an action has been executed, we can do this:
<pre>...
ob_start();
ked::$smarty-&gt;display($tpl);
$viewContent = ob_get_contents();
ob_end_clean();
if (!$this-&gt;_skipAssign) ked::$smarty-&gt;clear_all_assign();
if (strpos($viewContent, "&lt;b&gt;Warning&lt;/b&gt;:  Smarty error: unable to read resource:")!==false)
  throw new kedException('The view "'.$this-&gt;_view.'" was not found');
$this-&gt;viewContent = $viewContent;
$this-&gt;_skipAssign = false; //reset this to make sure subsequent actions don't get tainted
...</pre>
We check the bool we set earlier and forego template var assignment if it&#8217;s set to true. Once again, the exception is fine because we&#8217;re not catching it, and this is meant for exceptional cases that are supposed to grind our application to a halt. Unlike the case in _execute, this wont&#8217; be called every time there&#8217;s an actionless view &#8211; just in the case of an error.</p>

<h4>What Did We Gain From All This?</h4>

<p>Well, I listened to a bunch of really fucking good music on my ipod while doing this, so that&#8217;s good enough for me. But seriously, I also ordered like 6 <a href="http://www.threadless.com">Threadless</a> shirts.</p>

<p>Also, as a side benefit, the framework now supports actionless views without any extra file system operations. It is also wise enough not to bother assigning template variables if the template is static. You also don&#8217;t have to define anything special in the controller (in fact, nothing at all is needed there) or in the template to accomplish it &#8211; just put the static .tpl file in the right folder under inc/tpl/views.</p>

<p>I also used the word &#8220;tainted&#8221; in the comments&#8230; which is pretty close to &#8220;taint&#8221;&#8230; which is the area between the ass and the balls. That&#8217;s a wrap on the day.</p>
]]></content:encoded>
			<wfw:commentRss>http://mihasya.com/blog/actionless-views-the-quest-for-perfection/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>So What Happened Last Night?</title>
		<link>http://mihasya.com/blog/so-what-happened-last-night/</link>
		<comments>http://mihasya.com/blog/so-what-happened-last-night/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 15:38:59 +0000</pubDate>
		<dc:creator>mihasya</dc:creator>
				<category><![CDATA[dev]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[ked]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://mihasya.com/blog/?p=37</guid>
		<description><![CDATA[Fail, that&#8217;s what happened. A big fat sack of fail. So as I was working on mihasya.com, I was simultaneously tinkering with ked_core &#8211; a natural thing to happen, since mihasya.com is a test for how ked_core actually does when used in practice (it kicks ass, fyi). I got the idea to permit actionless views [...]]]></description>
			<content:encoded><![CDATA[<h4>Fail, that&#8217;s what happened. A big fat sack of fail.</h4>

<p>So as I was working on <strong>mihasya.com</strong>, I was simultaneously tinkering with <strong>ked_core</strong> &#8211; a natural thing to happen, since <strong>mihasya.com</strong> is a test for how <strong>ked_core</strong> actually does when used in practice <strong>(it kicks ass, fyi)</strong>. I got the idea to permit actionless views (more on how, once again, I did that better than you later), so I got all excited and immediately hacked up the code. So now I had this code that was directly applicable to <strong>mihasya.com</strong> (a lot of the inner pages don&#8217;t do much, so don&#8217;t need a controller function defined) in the <a href="http://svn.mihasya.com/ked_core">ked_core svn</a>, but not on the site.</p>

<p><strong>The problem is</strong>: now that ked just ships as a big hunk of folders with the internal files and the site&#8217;s own files mixed in, the separation gets tricky. Also, my blog/ folder (the WordPress install) had to go under <strong>mihasya.ked/www/blog</strong>, as that was what my <strong>mihasya.com</strong> folder was symlinked to&#8230; Long story short, I straight up deleted <strong>mihasya.ked</strong>. That was fine, I thought, because I still had all that code in svn&#8230;.  OOOOPS. Thank goodness for database storage.</p>

<h4>Where This Leaves an Ambitious Mother F@#$%#</h4>

<p>Well, this is a problem I gots ta solve. It&#8217;s plagued me for years, as applications come shipped in huge tarballs that just extract like they&#8217;re kings of the world. If you want to selectively update something, you have to cp files one at a time. Fuck that.</p>

<p>How do I elegantly, and from within the framework, permit the developer to upgrade ked files, but not affect his own? This could be solved easily by some sort of package manager like apt or rpm, but we don&#8217;t have that luxury. Or rather, I won&#8217;t give myself that luxury. This will be solved with bash, php, and svn in the spirit of minimalistic requirements. After all, it has to work on Dreamhost <img src='http://mihasya.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<h4>What I Intend To Do</h4>

<p>This is how it&#8217;s goin down, homegirls: I am going to write a shell script which will fetch a special file from a predetermined svn location (the repository doesn&#8217;t have to be static, as I&#8217;m sure ked will have thousands of mirrors as it sweeps the market <img src='http://mihasya.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ) The file will contain a listing of files which are internal to ked. It will probably just look something like this:
<pre>...
inc/controllers/internal
inc/core
inc/tpl/layouts/internal
...</pre>
The script will check the internal files on the repository for updates (including a self-update), download them to a separate copy (to avoid messing up your own .svn folders, if any are present) and copy them into your own dev tree.</p>

<p>One problem I&#8217;m already seeing before I even start hacking this up is that <strong>www/index.php</strong> contains configuration information that I refuse to move into a conf file (extra file read) that might get overwritten in this way, but I can probably figure out a way to handle that without quite developing a full blown package manager variable manipulation deal. Or maybe I&#8217;ll just do that. Cuz I can, son!</p>

<p>Stay tuned for more on this and other ked shenanigans.</p>
]]></content:encoded>
			<wfw:commentRss>http://mihasya.com/blog/so-what-happened-last-night/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ked_core update</title>
		<link>http://mihasya.com/blog/ked_core-update/</link>
		<comments>http://mihasya.com/blog/ked_core-update/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 05:16:44 +0000</pubDate>
		<dc:creator>mihasya</dc:creator>
				<category><![CDATA[framework]]></category>
		<category><![CDATA[ked]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://mihasya.com/blog/?p=30</guid>
		<description><![CDATA[Basics All code for ked_core and my other projects can now be found here. Slight change in nomenclature (aka stuff I hate) &#8211; the package that contains the framework itself will now be called ked_core, to accomodate future projects like ked_pdo and ked_auth that will play nicely with the framework. Those will have to wait [...]]]></description>
			<content:encoded><![CDATA[<h4>Basics</h4>

<p>All code for <code>ked_core</code> and my other projects can now be found <a href="http://svn.mihasya.com/">here</a>.</p>

<p>Slight change in nomenclature (aka stuff I hate) &#8211; the package that contains the framework itself will now be called <code>ked_core</code>, to accomodate future projects like <code>ked_pdo</code> and <code>ked_auth</code> that will play nicely with the framework. Those will have to wait until I un-dumbass myself by doing some more reading. And just completely stop giving a fuck about school and dedicate all my time to hacking.</p>

<h4>Some General Thoughts</h4>

<p>I&#8217;ve decided I can&#8217;t call it an MVC framework &#8211; because I don&#8217;t believe in models in the way Rails does. I don&#8217;t think an application has to be based around a model. Just because Rails has a built in implementation is not a good reason, to me, to use one. I have legitimately written an application that was very useful, but used NO database whatsoever. Anyone is free to use a 3rd party model implementation or write their own, but ked won&#8217;t require one by default.</p>

<h4>Change in Goals/Scope</h4>

<p>So as I was fucking around with the code, I decided to stop and revisit my goal: building a framework that can follow a site as it grows from something completely tiny hosted on something like Dreamhost to a massively scaled site with its own farm. For that two things are needed: leanness (least possible number of required operations and disk reads/writes per page load) and maintainability. The overall goal is now to be able to just download a ked skeleton to any host with PHP5 (I&#8217;m using my 5.95/mo Dreamhost account as a benchmark; if it works there but not on your host, kill yourself), then be able to grow it from there and move it to any other host near seamlessly. The changes to the core are as follows:</p>

<ul>
    <li>ked will now only run through a single <code>index.php</code> file, which will then load all the appropriate files for all the controllers. It ends up actually being 1 fewer include per page, thus one fewer fs operation. I realize that isn&#8217;t a big deal if APC is involved with opcode caching, but remember &#8211; every little bit counts.
<ul>
    <li>no apache configuration needed beyond <code>RewriteRules</code> in .htaccess.</li>
</ul>
</li>
    <li>ked now also supports grouping controllers/views into folders. Naming your controller <code>admin_mainController</code> adn placing it into <code>/ked_app_root/inc/controllers/admin/main.php</code> will work. Your views can then go into <code>/ked_smarty_dir/templates/admin/main/viewName.tpl</code>.</li>
    <li>Similar functionality for layouts.</li>
    <li>ked_core is still probably ~100 lines of actual code. Everything uses single quotes and only basic string operations &#8211; no regular expressions except in my <code>print_r</code> wrapper <code>dump()</code>. There are minimal advanced functions used &#8211; one instance of reflection, I believe.</li>
</ul>

<p>My general stance on what <code>ked</code> will/won&#8217;t do also changes, so it will INDEED now wipe your ass for you for the sake of maintainability.</p>

<ul>
    <li><code>ked</code> will generate controller/view skeletons for you via a webbased control panel (pending user permission limitations &#8211; to be investigated)
<ul>
    <li>if <code>PEAR_DocBlockGenerator</code> is installed, it will use that to generate docblocks for those skeletons</li>
</ul>
</li>
    <li><code>ked</code> will support phpUnit integration (but obviously won&#8217;t require it) as well as svn hooks to automatically run the unit testing and append test failure notices to the -m msg, citing who committed the failing code.</li>
</ul>

<h4>To Be Done:</h4>

<ul>
    <li>the basic <code>ked_admin</code> package for skeleton generation/management (which will, btw, use ked_core <img src='http://mihasya.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</li>
    <li>rewriting mihasya.com to use ked_core to demonstrate TEH POWAERS, hence its presence in my subversion tree &#8211; you&#8217;ll be able to compare the original tree with the ked&#8217;d tree.</li>
    <li>investigating integration with PEAR_DocBlockGenerator, phpDoc, phpUnit, Subversion, and my taint.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mihasya.com/blog/ked_core-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Writing (another) MVC Framework</title>
		<link>http://mihasya.com/blog/writing-another-mvc-framework/</link>
		<comments>http://mihasya.com/blog/writing-another-mvc-framework/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 04:41:54 +0000</pubDate>
		<dc:creator>mihasya</dc:creator>
				<category><![CDATA[dev]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[ked]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://mihasya.com/blog/?p=27</guid>
		<description><![CDATA[Over the past couple of weeks, I was hacking up an MVC framework, mostly for my personal use. I am gonna post the code once I&#8217;m done, however. I have decided to go back basically to the drawing board with it, and don&#8217;t feel like starting right now (on &#8220;vacation&#8221; in SF) so I&#8217;ll just [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past couple of weeks, I was hacking up an MVC framework, mostly for my personal use. I am gonna post the code once I&#8217;m done, however. I have decided to go back basically to the drawing board with it, and don&#8217;t feel like starting right now (on &#8220;vacation&#8221; in SF) so I&#8217;ll just write about it instead.</p>

<h3>Why? Aren&#8217;t there enough?</h3>

<p>Yes, but I can never quite get what I want. Here&#8217;s a breakdown of my reasons.</p>

<h4>Complexity/Usability</h4>

<p><a href="http://www.cakephp.org/">Cake</a> does too much. <a href="http://framework.zend.com/">Zend</a> is a little more lean, but does things in a dumb way that requires lots of typing for really simple things (Zend:RD Frameworks::YUI:JS Libraries), <a href="http://www.symfony-project.com/">Symfony</a> just just didn&#8217;t appeal. There&#8217;s actually a pretty good feature comparison for 10 frameworks <a href="http://www.phpit.net/article/ten-different-php-frameworks/">here</a>. My basic complaint is that they all have too many checks for features. I think I just disagree with the use of the word &#8220;framework&#8221;</p>

<p>I&#8217;m a big fan of the <a href="http://www.37signals.com/">37signals</a> guys and their general design/development philosophies. However, I think that with Rails they&#8217;ve strayed from their own philosophy of doing less, at least from the point of view of an external developer. From their perspective, it&#8217;s fine because they build Rails to do EXACTLY what they need, so it works great for them. But for a developer starting to develop his own application, Rails is the Microsoft Office of frameworks, and all the PHP frameworks followed Rails into intense complexity, even calling themselves &#8220;ports&#8221; of Ruby on Rails.</p>

<p>I&#8217;m all for not solving the same problem twice. But I don&#8217;t think very many problems are ever the <em>same </em>in the strict sense.</p>

<h4>Scale/Performance</h4>

<p>The more built in features your framework has built in, the more difficult it is to &#8220;stray&#8221; from the framework. Cal Henderson (OH SNAP, NAME DROP!) writes in <a href="http://www.amazon.com/exec/obidos/ASIN/0596102356">his book</a> on scalable websites about striking a balance between OGF (One Giant Function) and OOP.</p>

<blockquote> As you move further right [towards OOP], you gain maintainability at the expense of flexibility. As you move left, you lose the maintainability but gain flexibility. As you move too far out to either edge, optimizing your application becomes harder, while architecture becomes easier. (13)</blockquote>

<p>Cal classifies things like Rails towards the right; in my opinion Rails along with PHP clones like &#8220;PHP On Trax&#8221; <img src="http://mihasya.com/blog/wp-includes/js/tinymce/plugins/emotions/images/smiley-undecided.gif" alt="Undecided" title="Undecided" border="0" /> fall way too far to the right.</p>

<p>Relatedly, this causes a concern for scale. Sure, it&#8217;s nice to be able to develop your application quickly and save the $$ and time (so, once again, $$) from your development budget, but you gotta remember &#8211; servers cost money, and your application will need servers for as long as it&#8217;s live. If you are lucky and your app takes off, you will very quickly realize that every extra little bit of overhead adds up. If your framework just decides to load sqlite on every page view even though you aren&#8217;t using it, you&#8217;re going to notice (I&#8217;m sure there IS a way to turn this off, but Rails would not function until I installed the sqlite3 gem despite the fact that my entire database.ini was mysql). Every file read/write ends up counting.</p>

<p>My goal in creating this framework was to balance usefulness with performance. It does what I think are crucial things to rapid development, but everything that the most basic application ever can live without is left to plugins. If your application doesn&#8217;t use databases, you don&#8217;t have to define any database confs.</p>

<p>Also, features like &#8220;AJAX&#8221; are not appropriate to a PHP framework. A PHP framework should facilitate PHP development. Not write JS code. Not rewrite URL&#8217;s (hello, mod_rewrite), etc.</p>

<h4>Ease of Installation</h4>

<p>I&#8217;ve only had to install Rails, Cake, and Zend and was just underwhelmed by how much work it took just to get things started. In my interpretation of it, a rapid development framework should allow for a quick start. If it takes me days just to get the damn thing to &#8220;Hello, World!&#8221; it&#8217;s really not worth it.</p>

<h4>Dogfood: The Best Reason</h4>

<p>The other frameworks just don&#8217;t suit my needs. I&#8217;m about to knock out a couple of quick freelance projects before I fully transition from student to &#8220;real person&#8221;; one is very small and simple with minimal db interaction and a tiny CMS component. The other is quite a bit more complex, with a fairly elaborate hierarchy of pages. The first one obviously doesn&#8217;t fit the bill for any of the existing frameworks. The second seems like it (I initially was planning to use Cake when the project was first discussed last spring) but actually messing around with cake proved that I would absolutely hate doing an entire project in it. I needed something simple that I could use over and over on projects of varying complexity without taxing the simpler ones with excess complexity.</p>

<h3>So Tell Me More!</h3>

<p>OK OK! Here&#8217;s a little info on the yet-unwritten barebones mvc framework.</p>

<h4>The Basics</h4>

<p>My baby is due in about 2 weeks. She&#8217;s going to weigh in at about 300 lines, probably including doc blocks. Yup. No more. I agree with Crowley&#8217;s assessment: if it breaches 300, start cutting back. That is exactly what happened. I was getting a little trigger happy with the plugin system and just starting confusing myself. &#8220;Uh oh,&#8221; I thought. &#8220;If I&#8217;m confused, how will an outside user feel trying to figure this out? Actually fuck em &#8211; if I&#8217;m confused, I&#8217;ve written a bad framework, because it should satisfy me first and foremost.&#8221;</p>

<p>I&#8217;m going to name it <strong>Ked</strong>. Why that name? Because it&#8217;s short easy to type &#8211; 2 of the letters are on home row. Just try it: ked ked ked ked::dispatch ked::$settings&#8230; it just rolls off the fingers.</p>

<p>There is, however, a metaphoric component &#8211; I didn&#8217;t get three liberal arts majors for nothing. Keds are my favorite type of footwear. They are very basic, they are comfortable as fuck, they are good for most situations in life (well, if you&#8217;re a programmer and don&#8217;t have to dress up for work, anyway), and they will rarely let you down. They are perfectly designed to fulfill a very simple function &#8211; cover your feet as you walk around. You can, however, put diamonds or Gucci fabric on your keds if your needs call for it. They&#8217;ll still be keds, and will still serve their basic<em> telos </em>but will now also serve as a fashion accessory. If you went to high school in the 2000&#8242;s, you just think keds are cool no matter what, but that&#8217;s neither here nor there.</p>

<p>This framework will aim to be the ked of frameworks &#8211; dependable and simple, yet perfect for its one function and extensible to fill whatever other role you need it to.</p>

<p>The goal is to <em>require</em> as little work for every page view as possible, allowing developers to add additional functionality on a per-controller and even per-action basis.</p>

<h4>So what&#8217;ll it do?</h4>

<p>Well, here&#8217;s a list of things it <strong>won&#8217;t</strong> do:</p>

<ul>
    <li>Make you a mayonnaise sandwich</li>
    <li>Interpret and route pretty URLs. Use mod_rewrite, it&#8217;s faster.</li>
    <li>Write your XHTML/CSS and JavaScript for you</li>
    <li>Load a bunch of code to handle databases that you don&#8217;t use on every load</li>
    <li>Make you type 2 lines of code to do something dumb like set a template variable.</li>
    <li>Make you change your Apache config. Though using some Apache settings is recommended from a performance stand point, Ked will run on anything that runs a reasonable configuration of PHP5.1+ (5.0 might work, but I haven&#8217;t thought about it)</li>
    <li>Wipe your sysadmin&#8217;s ass by being backwards compatible to PHP4. Ked will use some very new and cutting edge tricks to make your life easier. If you are on a host that still runs PHP4, find a new host. Adding checks for PHP4 fail will inevitably inflate the otherwise trim code base.</li>
</ul>

<p>Fine, here&#8217;s what it <strong>WILL</strong> do:</p>

<ul>
    <li>Separate logic from presentation (DUH) and direct traffic appropriately</li>
    <li>Provide an easy way of passing variables. $this-&gt;var in the controller will bind to {$var} in the Smarty template (don&#8217;t worry, not all $this-&gt; variables will be accessible from Smarty)</li>
    <li>Use Smarty. Smarty rules. Don&#8217;t fight it. Though someone is welcome to write a plugin that allows Ked to run w/o Smarty.</li>
    <li>Uhhh&#8230; oh yeah, allow some funky plugin interaction.</li>
</ul>

<p>Pretty short list huh? Yup. It&#8217;s a ked.</p>
]]></content:encoded>
			<wfw:commentRss>http://mihasya.com/blog/writing-another-mvc-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

