<?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>Midstride Solutions &#187; mvc</title>
	<atom:link href="http://blog.midstride.com/tag/mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.midstride.com</link>
	<description>Powerful, simple &#38; easy to use.</description>
	<lastBuildDate>Sat, 18 Apr 2009 20:21:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>5 tips and tools to develop php applications fast</title>
		<link>http://blog.midstride.com/2008/09/09/5-tips-to-develop-php-applications-fast/</link>
		<comments>http://blog.midstride.com/2008/09/09/5-tips-to-develop-php-applications-fast/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 05:00:15 +0000</pubDate>
		<dc:creator>andre</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php frameworks]]></category>
		<category><![CDATA[rapid application development]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://blog.midstride.com/?p=19</guid>
		<description><![CDATA[In this post, I will discuss 5 tips and tools that the php community has provided to speed up development time and improve code quality.  These should help you out if you don't already know them, but if you do I would like to hear what you use to speed up your development time.]]></description>
			<content:encoded><![CDATA[<p>When web applications like <a href="http://www.basecamphq.com/" target="_blank">basecamp</a> started appearing, a lot of attention started turning to <a href="http://www.rubyonrails.org/" target="_blank">Ruby on Rails</a>.  Suddenly small groups of technically driven people could release powerful applications in a month or two.  With this awareness, the usability standards for web applications increased and so did the technical challenges for web developers and designers.  This movement sort of left php developers in the dust for a while.  While CakePHP and other frameworks came to the rescue, it didn&#8217;t seem like the php community wanted to match Ruby on Rails.  If anything, php has been looking to retain its strong foundations of being built upon a powerful, easy to use library and integrating new &#8220;web 2.0&#8243; like ideas to do more than Ruby on Rails.</p>
<p>In this post, I will discuss 5 tips and tools that the php community has provided to speed up development time and improve code quality.  These should help you out if you don&#8217;t already know them, but if you do I would like to hear what you use to speed up your development time.</p>
<p><span id="more-19"></span></p>
<ol>
<li><strong>Framework with the Model View Controller (MVC):<br />
</strong>This is old news, the MVC pattern is an industry accepted pattern to improve the organization and overall quality of your code.  Put your database code in the model layer, visual UI code in the view, and business application logic in the controller.  If you don&#8217;t know the MVC layer, you really should.</p>
<blockquote><p>My choice: <a href="http://framework.zend.com/manual/en/zend.controller.html" target="_blank">Zend Framework</a><br />
Why?  Easy to pick and choose what you want to use; strong momentum behind it; good documentation.</p></blockquote>
<p>Resources:<br />
<a href="http://framework.zend.com/manual/en/zend.controller.html" target="_blank">http://framework.zend.com/manual/en/zend.controller.html</a><br />
<a href="http://www.cakephp.org/" target="_blank">http://www.cakephp.org</a><br />
<a href="http://www.symfony-project.org/" target="_blank">http://www.symfony-project.org</a><br />
<a href="http://codeigniter.com/" target="_blank">http://codeigniter.com/</a></li>
<li><strong>AJAX Frameworks:</strong><br />
Also old news, you should become familiar with a common AJAX framework.  Scriptaculous, mootools, jquery, and dojo to name a few&#8230; these frameworks can all do similar things and will make your clients go ooh and ahh.  Actually, these days AJAX interaction is become standard.  Being a Zend developer, I would suggest acquainting yourself with the Dojo framework.  It&#8217;s probably the largest and most complex of them all but is very powerful.</p>
<blockquote><p>My choice: <a href="http://dojotoolkit.org/ " target="_blank">Dojo<br />
</a>Why?  Zend has adopted it into the zend framework; easy to extend; large resource of reusable widgets to use.</p></blockquote>
<p>Resources:<br />
<a href="http://en.wikipedia.org/wiki/Ajax_framework" target="_blank">http://en.wikipedia.org/wiki/Ajax_framework</a><br />
<a href="http://www.phpframeworks.com/" target="_blank">http://www.phpframeworks.com/</a><br />
<a href="http://mootools.net/" target="_blank">http://mootools.net/</a><br />
<a href="http://jquery.com/" target="_blank">http://jquery.com/</a><br />
<a href="http://script.aculo.us/" target="_blank">http://script.aculo.us/</a><br />
<a href="http://www.prototypejs.org/">http://www.prototypejs.org/</a><br />
<a href="http://dojotoolkit.org/ " target="_blank">http://dojotoolkit.org/ </a></li>
<li><strong>Integrated Development Environment (IDE):<br />
</strong> I won&#8217;t go into much detail here, if you&#8217;re developing objected oriented code or using a lot of libraries you should get a good IDE.  Eclipse PDT is my favourite because it&#8217;s free and has some very useful plugins to extend it.  My basic requiremnts are resource/file management of libraries, auto completion, basic syntax validation, and basic debugging tools.</p>
<blockquote><p>My choice:  <a href="http://www.eclipse.org/pdt/" target="_blank">Eclipse PDT</a><br />
Why?  It&#8217;s free and provides all the basic features an IDE should have.</p></blockquote>
<p>Resources:<br />
<a href="http://www.eclipse.org/pdt/" target="_blank">http://www.eclipse.org/pdt/</a><br />
<a href="http://www.zend.com/en/products/studio/" target="_blank">http://www.zend.com/en/products/studio/</a><br />
<a href="http://www.ibm.com/developerworks/opensource/library/os-php-ide/index.html" target="_blank">http://www.ibm.com/developerworks/opensource/library/os-php-ide/index.html</a></li>
<li><strong>Database Creation/Management Software</strong>:<br />
Managing a database schema can become tedious error prone thing to do.  If you don&#8217;t have a dedicated database team, and in many cases are the web and database developer, then you should be doing more than handling your schema in mysql (or your database of choice).  MySql has recently released workbench, a database management software that is really powerful.  I prefer DBDesigner 4 right now because it&#8217;s simple to use and feeds into <a href="http://propel.tigris.org/" target="_blank">propel db</a> well.  But I plan on moving over to workbench in the near future as it&#8217;s really the continuation of DBDesigner.</p>
<blockquote><p>My choice: <a href="http://fabforce.net/dbdesigner4/ " target="_blank"> DBDesigner</a>, but not for long.<br />
Why?  It&#8217;s simple to manage your database schema visually and exports well.</p></blockquote>
<p>Resources:<br />
<a href="http://dev.mysql.com/workbench/" target="_blank">http://dev.mysql.com/workbench/</a><br />
<a href="http://fabforce.net/dbdesigner4/ " target="_blank">http://fabforce.net/dbdesigner4/ </a></li>
<li><strong>Object Relational Mapping (ORM)</strong>:<br />
If you don&#8217;t know what this is, it&#8217;s basically a way of mapping your database tables to objects.  It&#8217;s so you don&#8217;t have to think about how to connect your logic/business code to the database.  Also, if you use tools like Propel DB you don&#8217;t have to code this as it generates it all for you.  While your application may not perform as well as with straight SQL, you will code faster and you can find ways to tweak bottle neck cases.</p>
<blockquote><p>My choice:  <a href="http://propel.tigris.org/" target="_blank">Propel DB<br />
</a>Why?  It&#8217;s easy to use and integrate into the zend framework; There aren&#8217;t many other options.</p></blockquote>
<p>Resources:<br />
<a href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank">http://en.wikipedia.org/wiki/Object-relational_mapping</a><br />
<a href="http://propel.tigris.org/" target="_blank">http://propel.tigris.org/ </a></li>
</ol>
<h2>Wrap Up / Further thoughts</h2>
<p>I hope this was useful for you.  Everyone has their own combination that works for them, and in a lot of cases the company forces you to use one.  Where I work, we can use whatever combination we want and I know there are many.  I would like to hear what your setup is like, what IDE, framework, and OS works for you and why?</p>
<p>Comment/Get the links for this post here:<br />
<script src="http://www.buncholinks.com/widget/script/i/59/k/305ff773469a6fcd760e059d2c266b2c" type="text/javascript"></script></p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/share_save?sitename=Midstride%20Solutions&amp;siteurl=http%3A%2F%2Fblog.midstride.com%2F&amp;linkname=5%20tips%20and%20tools%20to%20develop%20php%20applications%20fast&amp;linkurl=http%3A%2F%2Fblog.midstride.com%2F2008%2F09%2F09%2F5-tips-to-develop-php-applications-fast%2F"><img src="http://blog.midstride.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="5 tips and tools to develop php applications fast";
		a2a_linkurl="http://blog.midstride.com/2008/09/09/5-tips-to-develop-php-applications-fast/";
						    </script>
    <script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>

	</p>]]></content:encoded>
			<wfw:commentRss>http://blog.midstride.com/2008/09/09/5-tips-to-develop-php-applications-fast/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>Integrating AJAX/Dojo into the Zend MVC in 8 steps.</title>
		<link>http://blog.midstride.com/2008/08/26/integrating-ajaxdojo-into-the-zend-mvc-in-8-steps/</link>
		<comments>http://blog.midstride.com/2008/08/26/integrating-ajaxdojo-into-the-zend-mvc-in-8-steps/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 04:39:23 +0000</pubDate>
		<dc:creator>andre</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://blog.midstride.com/?p=7</guid>
		<description><![CDATA[If you have been following the Zend Framework at all, you'll know that Dojo has been selected as the UI library to be adopted into the Zend Framework. The question is what does this exactly mean? ]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p><a href="http://blog.midstride.com/wp-content/uploads/2008/09/zend_dojo.jpg"><img class="alignnone size-thumbnail wp-image-14 alignleft" style="float: left;" title="zend_dojo" src="http://blog.midstride.com/wp-content/uploads/2008/09/zend_dojo-150x118.jpg" alt="" width="150" height="118" /></a>If you have been following the <a href="http://framework.zend.com/" target="_blank">Zend Framework</a> at all, you&#8217;ll know that <a href="http://dojotoolkit.org/">Dojo </a>has been selected as the UI library to be adopted into the Zend Framework.  The question is what does this exactly mean?  I&#8217;m still trying to figure out how they are going to use dojo, but right now with release 1.6 you can create dojo widgets (e.g. &#8211; date pickers, currency boxes, specialized buttons etc&#8230;) in code with the Zend_Dojo object.   That being said, you still need to learn a few more things to create a useful and reusable AjAX framework with Zend.<br />
<span id="more-7"></span></p>
<h3>The Goal</h3>
<p>This tutorial will explain how to create a reusable UI AJAX layer with dojo that communicates to the Zend controller class.  I&#8217;ll provide some basic code that will show you one way of creating a reusable framework that makes it easier to organize your javascript/ajax and controller layer.</p>
<h3>Prerequisites</h3>
<p>Before you proceed, you&#8217;ll need to read up on how to setup the Zend MVC framework.</p>
<ul>
<li><a href="http://framework.zend.com/manual/en/zend.controller.html">Zend Framework with a MVC structure</a></li>
<li><a href="http://dojotoolkit.org/downloads">Dojo framework</a></li>
</ul>
<h3>The Steps</h3>
<p>1. Setup the Zend Framework and a MVC structure</p>
<p>2. Create the controller class file (e.g. &#8211; MidstrideController.php)</p>
<p>3. Create the view folder &#8220;midstride&#8221; in the view/scripts directory.</p>
<p>4. Create the file &#8220;index.phtml&#8221; in the midstride views/scripts folder.</p>
<p>5. Create an empty javascript file called ajaxmethods.js and place it in your javascript folder.</p>
<p><em><strong>-check up-<br />
</strong></em>Your file structure should look something like this now:</p>
<p>-/application/controller/MidstrideController.php<br />
-/application/views/scripts/midstride/index.phtml<br />
-/www/javascript/ajaxmethods.js<br />
-/www/scriptslib/dojo-release-1.1.1</p>
<p>Where application is your MVC folder and www is the directory for your assets and index.php bootstrap file.</p>
<p>5. Add the javascript code to the header of index.phtml</p>
<pre class="programlisting"> <code>
<span style="color: #000000;">
&lt;script type="text/javascript" src="&lt;?php echo $this-&gt;baseUrl; ?&gt;/javascript/ajaxmethods.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript" src="&lt;?php echo $this-&gt;baseUrl;?&gt;/scriptslib/dojo-release-1.1.1/dojo/dojo.js"         djConfig="parseOnLoad: true"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;

dojo.require("dojo.parser");

&lt;/script&gt;

</span>
</code></pre>
<p>In this case, the baseUrl is a short cut variable defined in your controller class<br />
e.g. &#8211; $this-&gt;view-&gt;baseUrl = $this-&gt;_request-&gt;getBaseUrl();   //gets the root of your application</p>
<p>6. Add some sample form information to index.phml</p>
<pre class="programlisting"> <code>
<span style="color: #000000;">
&lt;div id="status_message"&gt;&lt;!-- ajax messages go here--&gt;&lt;/div&gt;

&lt;form id="ajax_form"&gt;

&lt;input type="text" name="test_input" value="12345" /&gt;

&lt;input id="submit_button" type="submit"

value="submit"

onclick="formPost('&lt;?php echo $this-&gt;baseUrl ?&gt;/midstride/ajaxcall',"ajax_form","ajax_loader","submit_button") /&gt;

&lt;div id="ajax_loader" class="ajax_loader" style="display:none;"  /&gt;

&lt;/form&gt;

</span>
</code></pre>
<p>This form will call the javascript function &#8220;formPost&#8221; with the id of the ajax loader which is currently hidden.  The next step is to define the javascript function which will do the ajax call.</p>
<p>7. Code a reusable javascript ajax function</p>
<pre class="programlisting"> <code>
<span style="color: #000000;">
function formPost(destinationUrl, formId, loaderId, submitId)

{

var useAjaxLoader= true;

var hideSubmitAction = true;

if (loaderId===undefined) {     useAjaxLoader = false; }

if (submitId===undefined) {     hideSubmitAction  = false; }

var postParams = { url: destinationUrl,

load: function(data) {

dojo.eval(data);

//hide ajax loader

if (useAjaxLoader)    { dojo.byId(loaderId).style.display = "none";}

if (hideSubmitAction) { dojo.byId(submitId).style.display = "";} },

error: function(data) { console.debug("An error occurred: ", data); },

form: formId,

timeout: 4000,

headers: { "X-Requested-With": "XMLHttpRequest" }

};

//show ajax loader

if (hideSubmitAction) {dojo.byId(submitId).style.display = "none";}

if (useAjaxLoader)    {dojo.byId(loaderId).style.display = "";} //block

dojo.xhrPost(postParams);

}

</span>
</code></pre>
<p>There&#8217;s a lot going on in this code but it&#8217;s not that complex.  In short:</p>
<ul>
<li>destinationUrl = the HTTP address you want to call (a controller action method).</li>
<li>formId = the id of the form that is making the call.</li>
<li>loaderId = the id of the ajax loader (optional)</li>
<li>submitId = the id of the submit button (optional)</li>
</ul>
<p>The loaderId and submitId are used to show a loading icon and hide the submit button.  This provides the nice ajax feedback and makes sure the user doesn&#8217;t click twice.</p>
<p>The destinationUrl is the same address as in the GET or POST URL.  We need to pass the formId so that the parameters can be passed.  I&#8217;ll explain at the end other ways of passing parameters.</p>
<p>8.  Create some sample php code in the controller class &#8220;MidstrideController.php&#8221;</p>
<pre class="programlisting"> <code>
<span style="color: #000000;">
[in MidstrideController.php]

public function ajaxcallAction()

//only handle ajax calls

if ($this-&gt;_request-&gt;isXmlHttpRequest())

{

//don't render the page - no view script is needed{

$this-&gt;_helper-&gt;viewRenderer-&gt;setNoRender();

//json is the intermediate language to pass messages between the server and client

$jsonData = "";  //initialize to nothing
//get the parameter as normal

$testValue = $this-&gt;_request-&gt;getParam("test_value");

//prepare a fancy highlight response back

$jsonData =  "var highlight = dojo.animateProperty(

{

node: 'status_message',duration: 500,

properties: {

color:         { start: 'white', end: 'black' },

backgroundColor:{ start: '#fffecc', end: '#ffffff' }

}

});highlight.play();"

$this-&gt;_response-&gt;appendBody($jsonData);

}

}

</span>
</code></pre>
<p>This action method listens for the ajax called made by the javascript function.  It only deals with <strong>XmlHttpRequests (AJAX)</strong> and then sets the controller to not render anything.  The no rendering option means you don&#8217;t need to create a view (phtml) script.  Next, you just handle the form data as you would normally and prepare a JSON response to send back.  In this case, I&#8217;ve prepared a dojo animation to make a nice highlight on a status box.  In practice, you may not want to include any javascript in your controller class, as this is technically UI logic that could be in the ajax (JS) layer.  I prefer including dojo javascript because I don&#8217;t like writing javascript <img src='http://blog.midstride.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>The last call <strong>$this-&gt;_response-&gt;appendBody($jsonData)</strong> returns a javascript string which is evaluated in your javascript function by <strong>dojo.eval(data)</strong>.</p>
<h3>You&#8217;re done</h3>
<p>That&#8217;s it!  You now have a simple way of making ajax calls and keeping your main logic in the controller layer, where it should be.   If you wanted to  pass more parameters to the controller class, you would have to modify the formPost() function to have this:</p>
<blockquote><p>contentParams =  { &#8220;paramOne&#8221;:&#8221;1&#8243;,&#8221;paramTwo&#8221;:&#8221;2  };</p></blockquote>
<p>and then pass this to the var post params like:</p>
<blockquote><p>var postParams { content:contentParams, &#8230;other parameters}</p></blockquote>
<p>This can be useful when you have hidden values or other non traditional form inputs to pass in.</p>
<h3>Pros</h3>
<p>-8 steps to a reusable ajax layer.<br />
-You can easily customize the ajax post effects with dojo&#8217;s large animation library.<br />
-A very customizable and flexible framework for any project.</p>
<h3>Cons</h3>
<p>-Technical level:  It can take a while to learn the MVC and Dojo library.</p>
<h3>Conclusion</h3>
<p>That wraps up my first article on AJAX and the Zend Framework.  Future upcoming AJAX articles will discuss how to integrate Zend in scenarios where you want a real progress bar, modal popups, and captcha services.  Please let me know if you have any comments or questions.</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/share_save?sitename=Midstride%20Solutions&amp;siteurl=http%3A%2F%2Fblog.midstride.com%2F&amp;linkname=Integrating%20AJAX%2FDojo%20into%20the%20Zend%20MVC%20in%208%20steps.&amp;linkurl=http%3A%2F%2Fblog.midstride.com%2F2008%2F08%2F26%2Fintegrating-ajaxdojo-into-the-zend-mvc-in-8-steps%2F"><img src="http://blog.midstride.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Integrating AJAX/Dojo into the Zend MVC in 8 steps.";
		a2a_linkurl="http://blog.midstride.com/2008/08/26/integrating-ajaxdojo-into-the-zend-mvc-in-8-steps/";
						    </script>
    <script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>

	</p>]]></content:encoded>
			<wfw:commentRss>http://blog.midstride.com/2008/08/26/integrating-ajaxdojo-into-the-zend-mvc-in-8-steps/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
