<?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>Albert Fama &#187; Project: Udid</title>
	<atom:link href="http://albertfama.com/category/udid/feed/" rel="self" type="application/rss+xml" />
	<link>http://albertfama.com</link>
	<description>Freelance Web Programmer - specializing in PHP &#38; MySQL</description>
	<lastBuildDate>Fri, 20 Nov 2009 16:06:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Application Directory Structure</title>
		<link>http://albertfama.com/content/application-directory-structure/</link>
		<comments>http://albertfama.com/content/application-directory-structure/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 05:50:35 +0000</pubDate>
		<dc:creator>Albert Fama</dc:creator>
				<category><![CDATA[Content]]></category>
		<category><![CDATA[Project: Udid]]></category>
		<category><![CDATA[directory structure]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://obnexus.net/?p=47</guid>
		<description><![CDATA[In our last installment we created the directory structure we will be using for the development environment. Which was:
udid
&#124;
&#124;-&#62; project
&#124;    &#124;-&#62; branches
&#124;    &#124;-&#62; tags
&#124;    &#124;-&#62; trunk
&#124;         &#124;-&#62; public_html
&#124;         &#124;-&#62; Udid
&#124;
&#124;-&#62; simpletest
Today we will be adding a directory structure for the actual application itself, which means we will be working in the udid/project/trunk/Udid directory. Just as a refresher the public_html directory [...]]]></description>
			<content:encoded><![CDATA[<p>In our last <a title="Development Environment Setup" href="/content/development-enviroment-setup/" target="_self">installment</a> we created the directory structure we will be using for the development environment. Which was:</p>
<p><code>udid<br />
|<br />
|-&gt; project<br />
|    |-&gt; branches<br />
|    |-&gt; tags<br />
|    |-&gt; trunk<br />
|         |-&gt; public_html<br />
|         |-&gt; Udid<br />
|<br />
|-&gt; simpletest</code></p>
<p>Today we will be adding a directory structure for the actual application itself, which means we will be working in the udid/project/trunk/Udid directory. Just as a refresher the public_html directory is our document root and all our PHP code will be stored outside the root in the &#8216;Udid&#8217; directory.</p>
<p>There is one thing I want to mention before we really get into it. As a general rule I like to define one class per file, this is not a hard and fast rule I adhere to, but for the most part one file = one class. Given this I will use the terms &#8216;class&#8217; and &#8216;file&#8217; almost interchangeable for this post.</p>
<p>OK now that that is out of the way&#8230;There are two directories I include in ALL my project and they are:</p>
<ul>
<li>Documents &#8211; this will hold all developer documentation for the project; code documentation, &#8216;to do&#8217; lists, notes, etc.</li>
<li>UnitTests &#8211; This of course will hold all the unit tests for the application code.</li>
</ul>
<p>So now our Udid directory looks like:<br />
<code>Udid<br />
|<br />
|-&gt; Documents<br />
|-&gt; UnitTests</code></p>
<p>Now it is time to make some design decision about the structure of the application code itself. The directory structure really should be looked upon as an organizational task, i.e. What is the best way to organize the files we will be creating? The organization needs to make sense to you or your team of developers. One way to test yourself when you are deciding on a structure is to attempt to explain it to someone (if no one is available then write it down). If you find yourself going back over parts of the structure or having trouble finding the words to truly explain everything, then it is probably time to go back and try to reorganize. (I guess this post will be a good test for me, huh?)</p>
<p>So here goes&#8230;</p>
<p>One of my pet peeves about many PHP applications is that the PHP, HTML, and CSS are completely muddled together. I have to admit the PHP community in general has been getting better at the separation of presentation and business logic, but in many personal project that I&#8217;ve seen this is still an issue. For this project we will be using a template system where we define actual HTML templates. Since we will need a place to hold these template files I create the directory &#8216;Templates&#8217; beneath &#8216;Udid&#8217;.</p>
<p>I also know there will be generic classes we need to define which are not a part of any one section of the application, but are used by multiple aspects of the application such as database classes, iterators, an &#8216;emailer&#8217; etc. These classes are also not limited to this one application, but can be used over and over again in project after project. I often think of these classes as books in a library, available to everyone. Consequently I will call the directory which holds these classes the &#8216;Library&#8217;.</p>
<p>Finally we will need a place to store all the core components of our application and I&#8217;ve decided to call this storage area the: &#8216;Core&#8217;. Honestly I&#8217;m not crazy about this name, in the past I&#8217;ve used; Engine, Backend, etc. but I don&#8217;t really like them either so for this project we are calling it &#8216;Core&#8217;.</p>
<p>We have now added three other directories and the current structure looks like this:</p>
<p><code>Udid<br />
|<br />
|-&gt; Core<br />
|-&gt; Documents<br />
|-&gt; Library<br />
|-&gt; Templates<br />
|-&gt; UnitTests</code></p>
<p>We have one last directory to address and the base application structure will be complete. That directory is the &#8216;Core&#8217;. We cannot just start creating files in the &#8216;Core&#8217; without some sort of organization or we&#8217;ll end up with an application core which consists of a long list of files with no organization except for maybe some naming conventions. Since this is where the majority of our development time will be spent, we need to define some parameters about where files should exist.</p>
<p>For this project we will be using the <a href="http://www.tonymarston.net/php-mysql/model-view-controller.html" title="tonymarston.net: Model View Controller"  target="_self">Model View Controller</a> (MVC) design pattern. This is an organizational pattern to help separate different parts of the application code. As with all design patterns there is a lot programming theory associated with it and there is no way I can fully explain it here. If you are not familiar with this design pattern I urge you to search the net for more information. For our purposes the basic idea of each section is:</p>
<ul>
<li>Model &#8211; Contains application data and business logic. Objects which represent the data, and the processes to change that data.</li>
<li>View &#8211; Extracts data from the model and shapes it for presentation.</li>
<li>Controller &#8211; Receives requests and directs it for proper processing. Basically interpreting the request for the Model and View.</li>
</ul>
<p>Since we will be using this pattern I have decided to create one directory for each section below &#8216;Core&#8217;. These will hold the files associated to each section. Now some may argue that the &#8216;Templates&#8217; directory should be located below &#8216;View&#8217;, but I disagree. I want a place for templates that can easily be found, and is not located within the application code itself. I use this reasoning because I want other people who may not be PHP programmers to be able to find the templates and alter the display of the application.</p>
<p>There is one final directory I would like to include and that is a directory to hold <a href="http://phpdoc.org/" title="phpDocumentor" >phpDocumentor</a>. We will use this to generate documentation for the code. This directory will be stored beneath the top &#8216;udid&#8217; directory.</p>
<p>We have finally completed the development and application structure:</p>
<p><code>udid<br />
|<br />
|-&gt; project<br />
|    |-&gt; branches<br />
|    |-&gt; tags<br />
|    |-&gt; trunk<br />
|         |-&gt; public_html<br />
|         |-&gt; Udid<br />
|              |-&gt; Core<br />
|              |    |-&gt; Controller<br />
|              |    |-&gt; Model<br />
|              |    |-&gt; View<br />
|              |<br />
|              |-&gt; Documents<br />
|              |-&gt; Library<br />
|              |-&gt; Templates<br />
|              |-&gt; UnitTests<br />
|<br />
|-&gt; simpletest<br />
|-&gt; phpdoc</code></p>
<p>We can now import this directory structure to SVN and export our working copy.</p>
<p>Thanks for reading. Until next time&#8230;</p>

                            <div id="aspdf">
                                <a href="http://albertfama.com/wp-content/plugins/as-pdf/generate.php?post=47">
                                    <span>&nbsp;</span>
                                </a>
                            </div>
                        ]]></content:encoded>
			<wfw:commentRss>http://albertfama.com/content/application-directory-structure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Development Environment Setup</title>
		<link>http://albertfama.com/content/development-enviroment-setup/</link>
		<comments>http://albertfama.com/content/development-enviroment-setup/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 18:29:52 +0000</pubDate>
		<dc:creator>Albert Fama</dc:creator>
				<category><![CDATA[Content]]></category>
		<category><![CDATA[Project: Udid]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://obnexus.net/?p=46</guid>
		<description><![CDATA[Before we get into the directory structure we will be using for this project, I wanted to let you know I have decided on a project name. The basic idea for the application I&#8217;m building is to create a hierarchical storage system, hence the name:
UDID &#8211; User Designed/Defined Information Directory
(Of course it is an acronym, [...]]]></description>
			<content:encoded><![CDATA[<p>Before we get into the directory structure we will be using for this project, I wanted to let you know I have decided on a project name. The basic idea for the application I&#8217;m building is to create a hierarchical storage system, hence the name:</p>
<p>UDID &#8211; User Designed/Defined Information Directory<br />
(Of course it is an acronym, you expected something else?)</p>
<p>There is a legitimate reason for naming the project before even setting up the development area. The project will be stored under the &#8216;Udid&#8217; directory, and all of the class names will reflect the position of the file within the project&#8217;s directory structure. I will explain more about this when we get into writing classes and actually coding, but if you would like more information about this type of setup you can read about the <a href="http://framework.zend.com/" title="Zend Framework" >Zend Framework</a> <a href="http://framework.zend.com/manual/en/coding-standard.naming-conventions.html" title="Zend Framework naming conventions" >naming conventions for classes</a>.</p>
<p>OK now we have a name and it&#8217;s time to setup the directory structure. First we create the &#8216;udid&#8217; directory and beneath that we create a &#8216;project&#8217; directory; such as:<br />
<code><br />
udid<br />
|-&gt; project<br />
</code><br />
The &#8216;project&#8217; directory will hold all the files directly associated to the project. The reason I have created this directory and did not just store the project code within &#8216;udid&#8217;, is because we will be using some third party applications to help with development and I do not want that third party code to actually be associated to the project code. For example we will be using <a href="http://www.lastcraft.com/simple_test.php" title="Simple Test" >Simple Test</a> for unit testing. We will be placing Simple Test within &#8216;udid&#8217;, but not within &#8216;project&#8217;. So now we have:<br />
<code><br />
udid<br />
|-&gt; project<br />
|-&gt; simpletest<br />
</code><br />
As you know we will be using SVN to store the code, so we are going to be using what I learned as the traditional setup for a SVN project, not because it is the traditional way, but because I&#8217;ve used it before and it has worked well for me. This structure is:<br />
<code><br />
project<br />
|-&gt; branches<br />
|-&gt; tags<br />
|-&gt; trunk<br />
</code><br />
These three directories have very specific purposes:</p>
<ul>
<li><strong>branches</strong>: Experimental development branches. Branches are used when you decide to make some dramatic changes to the code base, but your not really sure how it is going to work out, so you do not want to code within the &#8216;trunk&#8217; but you may want to merge the code within the trunk at a later time.</li>
<li><strong>tags</strong>: This directory is used to store the project at certain milestones, i.e. version releases.</li>
<li><strong>trunk</strong>: Main development thread</li>
</ul>
<p>So this is what our directory structure looks like so far:<br />
<code><br />
udid<br />
|<br />
|-&gt; project<br />
|  |-&gt; branches<br />
|  |-&gt; tags<br />
|  |-&gt; trunk<br />
|<br />
|-&gt; simpletest<br />
</code><br />
OK, for the rest of this post we will be working in the &#8216;trunk&#8217; to setup the actual directory structure for the project code&#8230;</p>
<p>At some point a long time ago I got into the habit of creating a subdomain for each new project I work on, this I find convenient because the subdomain&#8217;s document root is its own and is not cluttered with other directories, files, etc. As an added bonus the document root can be anywhere on the system. Consequently the directories below &#8216;trunk&#8217; look like this:<br />
<code><br />
trunk<br />
|-&gt; public_html<br />
|-&gt; Udid<br />
</code><br />
Obviously &#8216;public_html&#8217; is the document root, and &#8216;Udid&#8217; will store all the back-end PHP code. Notice the PHP code will be stored outside the document root (where a browser is unable to access it directly). I prefer to setup my projects this way as an added security measure. For more information about the security aspects of this; check out <a href="http://shiflett.org" title="Chris Shiflett PHP and Web Application Security" >Chris Shiflett</a>&#8217;s article: <a href="http://shiflett.org/articles/secure-design" title="shiflett.org: Security Corner: Secure Design" >Security Corner: Secure Design</a> (be sure to read the comments).</p>
<p>For now &#8216;public_html&#8217; will remain empty and &#8216;Udid&#8217; will hold the directory structure for the application. So this will be the development directory structure we&#8217;ll be using&#8230;<br />
<code><br />
udid<br />
|<br />
|-&gt; project<br />
|    |-&gt; branches<br />
|    |-&gt; tags<br />
|    |-&gt; trunk<br />
|         |-&gt; public_html<br />
|         |-&gt; Udid<br />
|<br />
|-&gt; simpletest<br />
</code><br />
Please note, I have still not imported the project into SVN, you can actually do the import as soon as you have the first directory created, but I like to wait until I have the basic structure of the application set, which brings us to the topic of the next post. What is the directory structure of the application itself; or what directories will be created below Udid: &#8216;udid-&gt;project-&gt;trunk-&gt;Udid&#8217;?</p>
<p>I will post this structure in the next few days, and import the project into SVN, so we can finally get down to some code! Thanks for reading.</p>

                            <div id="aspdf">
                                <a href="http://albertfama.com/wp-content/plugins/as-pdf/generate.php?post=46">
                                    <span>&nbsp;</span>
                                </a>
                            </div>
                        ]]></content:encoded>
			<wfw:commentRss>http://albertfama.com/content/development-enviroment-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting a New Project</title>
		<link>http://albertfama.com/content/starting-a-new-project/</link>
		<comments>http://albertfama.com/content/starting-a-new-project/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 18:18:17 +0000</pubDate>
		<dc:creator>Albert Fama</dc:creator>
				<category><![CDATA[Content]]></category>
		<category><![CDATA[Project: Udid]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[requirements]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://obnexus.net/?p=45</guid>
		<description><![CDATA[Greetings once again; I am currently in the design phase of a new project. I thought it could prove to be an interesting set of blog entries if I loosely documented the progress here at Obnexus. I will try to relate all experiences as the project is created. 
Even if we try to account for [...]]]></description>
			<content:encoded><![CDATA[<p>Greetings once again; I am currently in the design phase of a new project. I thought it could prove to be an interesting set of blog entries if I loosely documented the progress here at Obnexus. I will try to relate all experiences as the project is created. </p>
<p>Even if we try to account for all aspects in the design phase, I know there will be situations where decisions made early on will have negative effects later down the road. I will document everything as it happens, because I find that I learn more from mistakes, and hopefully you will to. </p>
<p>I will mainly be working on this project solo, which means I will not only be dealing with PHP and MySQL, but also HTML, CSS, JavaScript, etc. Since I believe many developers work alone I hope that this will interest most readers.</p>
<p>I personally like to start a project with a name, simply because it gives the project an identity, but&#8230; In this case I cannot decide on an appropriate name so I am going to skip this step for the moment and move onto some actual code design, one of the most important and exciting steps.</p>
<p>First let&#8217;s set down some general guidelines: </p>
<ul>
<li>Version Control: Subversion (SVN)</li>
<li>PHP Version: The project will be written in PHP5 and will not support PHP4. Let&#8217;s face it PHP4 is dead and if your server is still running 4 you NEED to upgrade. </li>
<li>MySQL Version: I will be using MySQL 5, again if your not on 5, what are you waiting for?</li>
<li>HTTP Server Platform: Apache</li>
<li>Browser Support: Firefox, Internet Explorer, AOL Browser, Netscape, Opera, Safari. This is just a list off the top of my head, basically we are going to attempt to support as many browsers as possible.</li>
</ul>
<p>Again these are just general guidelines; eventually the project will be able to support multiple database servers, different HTTP server platforms, etc. Initially these are our targets for support; no reason to bog the development process down with attempting to support everything under the sun, but&#8230; Since we want the project to be as flexible as possible, we will need to account for this NOW in our framework design.</p>
<p>OK, now that we have our guidelines; the next step will be to start coding right? Wrong, next we will decide on a directory structure, and create the SVN repository to hold our project.</p>
<p>I hope you are as excited as I am to get this thing underway, please check back soon.</p>

                            <div id="aspdf">
                                <a href="http://albertfama.com/wp-content/plugins/as-pdf/generate.php?post=45">
                                    <span>&nbsp;</span>
                                </a>
                            </div>
                        ]]></content:encoded>
			<wfw:commentRss>http://albertfama.com/content/starting-a-new-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
