<?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>Andrew Vayanis</title>
	<atom:link href="http://www.vayanis.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vayanis.com</link>
	<description>Developer, Gamer, Thinker</description>
	<lastBuildDate>Wed, 19 May 2010 15:58:46 +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>OS X 10.6 (Snow Leopard) &#8211; using MAMP/PECL to install PHP extensions</title>
		<link>http://www.vayanis.com/2010/05/19/os-x-10-6-snow-leopard-using-mamppecl-to-install-php-extensions/</link>
		<comments>http://www.vayanis.com/2010/05/19/os-x-10-6-snow-leopard-using-mamppecl-to-install-php-extensions/#comments</comments>
		<pubDate>Wed, 19 May 2010 15:48:25 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/?p=88</guid>
		<description><![CDATA[Need help installing PHP extensions for OS X 10.6 (Snow Leopard) using MAMP and the included pecl binary?  Well, you have come to the right place.  If you have tried this on its own, you will notice that none of the extensions pecl builds will work with MAMP.  This is because MAMP [...]]]></description>
			<content:encoded><![CDATA[<p>Need help installing PHP extensions for OS X 10.6 (Snow Leopard) using MAMP and the included pecl binary?  Well, you have come to the right place.  If you have tried this on its own, you will notice that none of the extensions pecl builds will work with MAMP.  This is because MAMP is compiled as a 32-bit binary whereas pecl tries to build 64-bit PHP extensions.</p>
<p>To get pecl working properly, make sure you have <a href="http://developer.apple.com/technologies/tools/xcode.html">Xcode</a> installed on you machine.  Next, you will need to get a copy of MAMP&#8217;s source and prepare it using 32-bit compile flags. You can download the MAMP source from the <a href="http://www.mamp.info/en/downloads/index.html">MAMP download page</a>. Running the .dmg should extract the source. After extracting the source run the following:<br />
<span id="more-88"></span><br />
<code><br />
mkdir /Applications/MAMP/Library/Include/<br />
mv /path/to/extracted/mamp/source/ /Applications/MAMP/Library/Include/<br />
</code> </p>
<p>Next you will want to extract the PHP package and do the following to prepare the package:</p>
<p><code><br />
mv /Applications/MAMP/Library/Include/extracted_php_source/ /Applications/MAMP/bin/php5/include/php/<br />
cd /Applications/MAMP/bin/php5/include/php/<br />
MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=/Applications/MAMP/bin/php5/bin/php-config<br />
</code></p>
<p>Finally, you now can install pecl extensions with the following command:<br />
<code><br />
MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' /Applications/MAMP/bin/php5/bin/pecl install <extension name><br />
</code></p>
<p>And that&#8217;s it! Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2010/05/19/os-x-10-6-snow-leopard-using-mamppecl-to-install-php-extensions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Running 32-bit Apache Tomcat on a 64-bit system with JSVC</title>
		<link>http://www.vayanis.com/2010/02/10/running-32-bit-apache-tomcat-on-a-64-bit-system-with-jsvc/</link>
		<comments>http://www.vayanis.com/2010/02/10/running-32-bit-apache-tomcat-on-a-64-bit-system-with-jsvc/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 22:27:49 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Guides]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/?p=45</guid>
		<description><![CDATA[I recently ran into a java.lang.OutOfMemoryError exception after moving a Tomcat Web Application from a 32-bit system to a 64-bit system.  Not being able to give the JVM more memory, I decided to install a 32-bit JDK on the machine.  Getting a 32-bit Tomcat install working on a 64-bit system gave me a [...]]]></description>
			<content:encoded><![CDATA[<p>I recently ran into a java.lang.OutOfMemoryError exception after moving a Tomcat Web Application from a 32-bit system to a 64-bit system.  Not being able to give the JVM more memory, I decided to install a 32-bit JDK on the machine.  Getting a 32-bit Tomcat install working on a 64-bit system gave me a bit of trouble, so I decided to write this article.</p>
<p>Installing a 32-bit JDK is very easy.  First, download the right package from the sun download site: http://java.sun.com/javase/downloads/index.jsp and extract it.  To extract the .bin file, you need need to make sure to make the .bin file executable.  After that, you can run the file and it should extract itself to the current directory.  You can now use the JDK by referencing it directly or by setting it as an alternative using the appropriate <a href="https://help.ubuntu.com/community/Java">instructions</a>.  For the purpose of this article however, we don&#8217;t need to get into that.  Next, you will need to update your start/stop scripts to take advantage of the new JDK.<br />
<span id="more-45"></span><br />
Unfortunately, you still have more to do because the start/stop scripts use JSVC to control the Tomcat daemon.  If you try to startup tomcat after referencing the new JDK, you will notice that you get an error stating that it cannot locate a valid JVM.  This is because the JSVC that has been installed, is a 64-bit binary and is looking for a 64-bit JVM.  You will now need to recompile JSVC as a 32-bit binary so that you can use it with your 32-bit JDK.  This is where things get a little tricky.  After some googling, I found the following <a href="http://crashingdaily.wordpress.com/2008/11/12/compiling-a-32-bit-jsvc-on-a-64-bit-machine/">instructions.</a>  Unfortunately, these instructions didn&#8217;t work for me as is.</p>
<p>To compile JSVC, you will first you need to download and extract the <a href="http://commons.apache.org/daemon/jsvc.html">JSVC source</a>. Next, make sure you have lib32gcc1 and libc6-dev-i386 installed.  On a Debian system you can do this with the following command:<br />
<code><br />
sudo aptitude install lib32gcc1 libc6-dev-i386<br />
</code><br />
If you do not have the packages installed, aptitude will prompt you to install the packages.  Next, run the following configure commands to configure and build JSVC:<br />
<code><br />
cd /path/to/jsvc/src/native/unix/<br />
CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 LDFLAGS="-L/path/to/32/bit/shared/libraries/" ./configure --with-java=/path/to/32/bit/jdk/ --build=i686-pc-linux-gnu<br />
make<br />
cd native/<br />
gcc -m32 -L/path/to/32/bit/shared/libraries/ -ldl -lpthread jsvc-unix.o libservice.a -o ../jsvc<br />
</code><br />
On a Debian machine the path to your shared libraries might be:<br />
<code><br />
/emul/ia32-linux/usr/lib<br />
</code><br />
By this point, you should have a jsvc binary in your /path/to/jsvc/src/native/unix/ directory.  You can move this where ever you like and reference it from your tomcat start/stop scripts.  Now, your done!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2010/02/10/running-32-bit-apache-tomcat-on-a-64-bit-system-with-jsvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up LAML (Linux, Apache, MySQL, Lua) with MAMP</title>
		<link>http://www.vayanis.com/2010/02/04/setting-up-laml-linux-apache-mysql-lua-with-mamp/</link>
		<comments>http://www.vayanis.com/2010/02/04/setting-up-laml-linux-apache-mysql-lua-with-mamp/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 05:00:04 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Guides]]></category>
		<category><![CDATA[Lua]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/?p=48</guid>
		<description><![CDATA[As a weekend project I decided to set up a LAML, (Linux, Apache, MySQL, Lua) stack on my computer.  I never worked with Lua before, but I figured it wouldn&#8217;t be too hard to get it working with my MAMP setup.  Getting started, I spent some time reading any articles I could find [...]]]></description>
			<content:encoded><![CDATA[<p>As a weekend project I decided to set up a LAML, (Linux, Apache, MySQL, Lua) stack on my computer.  I never worked with Lua before, but I figured it wouldn&#8217;t be too hard to get it working with my MAMP setup.  Getting started, I spent some time reading any articles I could find on the web that talked about setting up or using using Lua for web development.  I quickly ran into the <a href="http://www.keplerproject.org/">Kepler Project</a> which as their website points out:</p>
<blockquote><p>
is an open source platform that brings the power of Lua to web development
</p></blockquote>
<p>While this was my goal, I wanted to start from scratch since I haven&#8217;t had any experience with the language and didn&#8217;t want to learn it on a specific platform just yet.  So, I went on to figure out how to install and configure Lua with MAMP.  To accomplish this yourself, you will need: Xcode, MAMP, Lua, LuaRocks, MAMP source, and mod_fcgid.<br />
<span id="more-48"></span></p>
<h3>Step 1: Install Xcode</h3>
<p>This one is pretty straight forward.  You can easily install Xcode if you have an OS X install DVD.  Otherwise you can download it from the <a href="http://developer.apple.com/technology/xcode.html">Apple Developer Center</a>.</p>
<h3>Step 2: Install Lua</h3>
<p>Installing Lua is also straight forward.  Download the source from <a href="http://www.lua.org/ftp/">Lua&#8217;s FTP site</a>.  I chose the current version (5.1.4).  After extracting the source run the following commands:<br />
<code><br />
cd /path/to/source/<br />
make macosx<br />
sudo make install<br />
</code><br />
This should install the Lua interpreter into your /usr/local/bin/</p>
<h3>Step 3: Install LuaRocks</h3>
<p>To install LuaRocks, you first need to download the <a href="http://luarocks.org/releases/">source</a>.  The current release is 2.0.1.  After downloading the source run the following commands:<br />
<code><br />
cd /path/to/source/<br />
make<br />
sudo make install<br />
</code><br />
This should install luarocks in /usr/local/bin/ .  You can test your installation with:<br />
<code>luarocks help</code><br />
You should be presented with a list of commands to use luarocks.</p>
<h3>Step 4: Install Lua MySQL support</h3>
<p>This part is a little tricky as you need to make sure you have the source for your MAMP installation.  You can download the <a href="http://sourceforge.net/projects/mamp/files/mamp/1.8.2/MAMP_components_1.8.2.dmg.zip/download">MAMP source</a> from the <a href="http://www.mamp.info/en/index.html">MAMP website</a>.  Running the .dmg should extract the source.  After extracting the source run the following:<br />
<code><br />
mkdir /Applications/MAMP/Library/Include/<br />
mv /path/to/extracted/mamp/source/ /Applications/MAMP/Library/Include/<br />
</code><br />
Once you have moved your source over, extract the MySQL package then run the following commands:<br />
<code><br />
cd /Applications/MAMP/Library/include/mysql-5.1.37/<br />
./configure<br />
make<br />
</code><br />
Once you have finished building MySQL, you will want to move the mysqlclient into the current MySQL location:<br />
<code><br />
cp /Applications/MAMP/Library/include/mysql-5.1.37/libmysql/.libs/*.dylib /Applications/MAMP/Library/lib/mysql/<br />
</code><br />
You will now be able to install the luasql-mysql package from luarocks with the following command:<br />
<code><br />
sudo luarocks install luasql-mysql 2.2.0-1 MYSQL_INCDIR=/Applications/MAMP/Library/include/mysql-5.1.37/include MYSQL_LIBDIR=/Applications/MAMP/Library/lib/mysql<br />
</code></p>
<h3>Step 5: Install Lua fcgid wrapper</h3>
<p>This is an easy one:<br />
<code><br />
luarocks install lua wsapi-fcgi 1.1<br />
</code></p>
<h3>Step 6: Install Apache mod_fcgid</h3>
<p>This part was a bit tricky for me since I don&#8217;t have much experience compiling Apache modules.  First, you will need to extract the httpd source, for me this was httpd-2.0.63.tar.gz.  Next, you will want to build Apache into a separate directory.  Use the following to build Apache:<br />
<code><br />
./configure --prefix=/path/to/target/Apache<br />
make<br />
make install<br />
</code><br />
While running the make command, you may get the following error:</p>
<p><code><br />
sendrecv.c:965:2: error: #error APR has detected sendfile on your system, but nobody has written a<br />
sendrecv.c:966:2: error: #error version of it for APR yet. To get past this, either write apr_sendfile<br />
sendrecv.c:967:2: error: #error or change APR_HAS_SENDFILE in apr.h to 0.<br />
</code></p>
<p>Fixing this is simple, all you need to do is edit /Applications/MAMP/Library/include/httpd-2.0.63/srclib/apr/include/apr.h and make the following modifications:<br />
<code><br />
-#define APR_HAS_SENDFILE  1<br />
+#define APR_HAS_SENDFILE  0<br />
</code></p>
<p>I know its taken quite some time now, but you are almost done!  All that&#8217;s left is to build mod_fcgid and configure Apache.  To build mod_fcgid run the following commands:<br />
<code><br />
APXS=/path/to/target/Apache/bin/apxs ./configure.apxs<br />
make<br />
make install<br />
cp /path/to/target/Apache/modules/mod_fcgid.so /Applications/MAMP/Library/modules<br />
</code></p>
<h3>Step 7: Configure Apache for mod_fcgid and Lua</h3>
<p>Now that you have everything built and in place, you just need to configure Apache and then you will be ready to start building Lua web apps!</p>
<p>Open /Applications/MAMP/conf/apache2/httpd.conf with your favorite text editor and add the following to the load modules section:<br />
<code><br />
LoadModule fcgid_module modules/mod_fcgid.so<br />
</code><br />
While you are at it, you can comment out the following lines if you like (I am not sure if it is possonlble to run mod_cgid with mod_fcgid, so I just took them out).<br />
<code><br />
#LoadModule cgi_module modules/mod_cgi.so<br />
#LoadModule cgid_module modules/mod_cgid.so<br />
</code><br />
Next, find the IfModule mod_fcgid directive, and add the following under it:<br />
<code><br />
<IfModule mod_fcgid.c><br />
	AddHandler fcgid-script .lua<br />
	FcgidWrapper /Users/avayanis/.luarocks/bin/wsapi.fcgi .lua<br />
	Options +ExecCGI<br />
</IfModule><br />
</code><br />
Finally, restart Apache through the MAMP application and test it out!  Here is a sample lua script to test out your Lua environment:</p>

<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;">module<span style="color: #66cc66;">&#40;</span>..., package.seeall<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #b1b100;">function</span> run<span style="color: #66cc66;">&#40;</span>wsapi_env<span style="color: #66cc66;">&#41;</span>
    <span style="color: #b1b100;">local</span> headers <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Content-type&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;text/html&quot;</span> <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">function</span> hello_text<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #b1b100;">coroutine.yield</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Hello World!&quot;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #b1b100;">end</span>
    <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">200</span>, headers, <span style="color: #b1b100;">coroutine.wrap</span><span style="color: #66cc66;">&#40;</span>hello_text<span style="color: #66cc66;">&#41;</span>
<span style="color: #b1b100;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2010/02/04/setting-up-laml-linux-apache-mysql-lua-with-mamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intro to Zend Framework Routing</title>
		<link>http://www.vayanis.com/2009/03/20/intro-to-zend-framework-routing/</link>
		<comments>http://www.vayanis.com/2009/03/20/intro-to-zend-framework-routing/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 14:56:28 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/?p=32</guid>
		<description><![CDATA[Edit: I originally started working on this article several months ago, however, as I was editing it, the Zend Framework team released a revamped reference guide that goes through much of what I discuss.  Hopefully though, this still ends up being useful and informative for someone out there.
Edit #2: I don&#8217;t mean for this [...]]]></description>
			<content:encoded><![CDATA[<p>Edit: I originally started working on this article several months ago, however, as I was editing it, the Zend Framework team released a revamped reference guide that goes through much of what I discuss.  Hopefully though, this still ends up being useful and informative for someone out there.</p>
<p>Edit #2: I don&#8217;t mean for this article to be followed verbatim, but rather, used as a guide to understanding Zend Framework&#8217;s routing process.  </p>
<p>Now that I am using ZF for current projects at work, I have taken the opportunity to promote ZF with my colleagues.  One colleague in particular, who has been using <a href="http://www.codeigniter.com">Code Igniter</a>(CI), was somewhat perplexed by ZF&#8217;s seeming complexity, even after reading through the first few sections of the <a href="http://framework.zend.com/manual/en/">Reference Guide</a>.  In particular, he didn&#8217;t understand how ZF handled URIs as it is quite different from CI.  So, I have put together the following, hopefully simple overview, explaining a bit about ZF&#8217;s routing and using it in conjunction with Zend_Config.<br />
<span id="more-32"></span><br />
Out of the box, ZF routes URIs by turning the first segment into the controller and the second segment into the action, unless you have specified a module directory, in which case, the first segment becomes the module, the second segment the controller and the third segment the action.  Any segments beyond that are converted into key-value pairs that are accessible through the front controller&#8217;s request object.</p>
<p>Therefore, something like http://www.vayanis.com/post/view/id/101/title/new-post is translated into a request for the &#8216;post&#8217; controller, and &#8216;view&#8217; action with two request parameters: &#8216;id&#8217; with value &#8216;101&#8242; and &#8216;title with value &#8216;new-post&#8217;.  Accessing these parameters is simple:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_request<span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_request<span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Unfortunately, this default behavior is bad for SEO because it adds unnecessary and useless information to the URI, but like many things in ZF, there is a solution and so I turn to the <a href="http://framework.zend.com/manual/en/zend.controller.router.html">Zend_Controller_Router_Rewrite</a>.<br />
As the documentation states:</p>
<blockquote><p>Zend_Controller_Router_Rewrite is designed to allow for mod_rewrite-like functionality using pure php structures. It is very loosely based on Ruby on Rails routing and does not require any prior knowledge of webserver URL rewriting.</p></blockquote>
<p>So, to simplify this URI, I can create the following route:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Get Front Controller Instance</span>
<span style="color: #000088;">$front</span> <span style="color: #339933;">=</span> Zend_Controller_Front<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Get Router</span>
<span style="color: #000088;">$router</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$front</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRouter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$route</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Controller_Router_Route<span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'post/:id/:title'</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'controller'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'blog'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'action'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span>
    <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$router</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addRoute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$route</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This will shorten the previous, lengthy URI from http://www.vayanis.com/post/view/id/101/title/new-post to http://www.vayanis.com/view/101/new-post</p>
<p>Finally, like most components, if you are not comfortable maintaining your configuration in pure php, you can instead use a INI config file.  The equivalent of the previous example could be defined in an INI config file with the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>production<span style="">&#93;</span></span>
routes.post.route <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;post/:id/:title&quot;</span>
routes.post.defaults.controller <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> blog</span>
routes.post.defaults.action <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> post</span></pre></div></div>

<p>To use the INI with a router, use the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Get Front Controller Instance</span>
<span style="color: #000088;">$front</span> <span style="color: #339933;">=</span> Zend_Controller_Front<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Get Router</span>
<span style="color: #000088;">$router</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$front</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRouter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$router</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addConfig</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Zend_Config_Ini<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'path/to/route/config/file'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'production'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'routes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2009/03/20/intro-to-zend-framework-routing/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Using Subversion with Network Drives in OS X</title>
		<link>http://www.vayanis.com/2008/05/04/using-subversion-with-network-drives-in-os-x/</link>
		<comments>http://www.vayanis.com/2008/05/04/using-subversion-with-network-drives-in-os-x/#comments</comments>
		<pubDate>Mon, 05 May 2008 01:55:05 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/?p=33</guid>
		<description><![CDATA[Ever try to get subversion working between multiple Macs over a home network without WEB Dav or public key authentication over ssh?  Well, that was what I was trying to accomplish over this weekend and it apparently isn&#8217;t as straightforward as I thought.  There seems to be an issue with subversion (SVN) and [...]]]></description>
			<content:encoded><![CDATA[<p>Ever try to get subversion working between multiple Macs over a home network without WEB Dav or public key authentication over ssh?  Well, that was what I was trying to accomplish over this weekend and it apparently isn&#8217;t as straightforward as I thought.  There seems to be an issue with <a href="http://subversion.tigris.org/">subversion (SVN)</a> and apple&#8217;s AFP protocol, something to do with not being able to obtain exclusive locks?  Well, that is all I could find on the problem.  So, if anyone knows how to fix this, I would like to know.  However, I did find another solution on my own, that was just as useful to me as using an AFP mounted drive, but much more versatile.  Intoducing&#8230; <a href="http://code.google.com/p/macfuse/">MacFUSE</a>!<br />
<span id="more-33"></span></p>
<blockquote><p>MacFUSE implements a mechanism that makes it possible to implement a fully functional file system in a user-space program on Mac OS X (10.4 and above).</p></blockquote>
<p>In a nutshell, MacFUSE lets you turn any number of connection interfaces into a fully functional file system.  With the files provided in the link above, you can mount an FTP or SSH login as a network drive, thus solving my issue of using subversion over a network drive.  The best part is, I can now easily access my Mac Pro remotely as well.  Although, now that I think about it, I have never tried to mount a remote drive over AFP so that could have always been possible.</p>
<p>I have to admit this is my new favorite development tool since it makes working remotely much more pleasant.  Instead of opening files one at a time through <a href="http://cyberduck.ch/">Cyberduck</a>, my FTP client, and <a href="http://macromates.com/">Textmate</a>, I can now mount my FTP account as a network drive and create projects with Textmate to edit all my files.  This also happens to be a great solution for all the people wishing for FTP support within Textmate.</p>
<p>Anyhow, I hope this can be of help to someone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2008/05/04/using-subversion-with-network-drives-in-os-x/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Creating Tables with Zend_Form</title>
		<link>http://www.vayanis.com/2008/03/26/creating-tables-with-zend_form/</link>
		<comments>http://www.vayanis.com/2008/03/26/creating-tables-with-zend_form/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 05:47:17 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Zend_Form]]></category>
		<category><![CDATA[Zend_Framework]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/2008/03/26/creating-tables-with-zend_form/</guid>
		<description><![CDATA[I recently published an article trying to shed some light on the Zend_Form component, in particular, when using it with Zend_Config_Ini.  In the article I presented a config I developed while trying to learn Zend_Form myself, but unfortunately realized that using generic elementDecorators comes with a price.

Apparently, using elementDecorators overrides individual element level decorators. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently published an <a href="http://www.vayanis.com/2008/03/17/using-zend_form-with-zend_config/">article</a> trying to shed some light on the <a href="http://framework.zend.com/manual/en/zend.form.html">Zend_Form</a> component, in particular, when using it with Zend_Config_Ini.  In the article I presented a config I developed while trying to learn Zend_Form myself, but unfortunately realized that using generic <em>elementDecorators</em> comes with a price.<br />
<span id="more-29"></span><br />
Apparently, using elementDecorators overrides individual element level decorators.  This leads to some unexpected and annoying results.  For instance, in my previous example, I lose the ability to hide or even add individual attributes to specific elements.  This leaves me with a form that has labels for each element including the submit button:<br />
<img src='http://www.vayanis.com/wp-content/uploads/2008/03/zend_form-table-login-1.png' alt='Zend Form Table Login with all Labels' /></p>
<p>The only way I found to correct this problem is to add decorators to each element individually.  This is highly redundant and hardly ideal, but it gives the control necessary to fix this problem.  It also bloats the config file significantly; previously, the config was 31 lines long, but now it is 47 lines long:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>login<span style="">&#93;</span></span>
<span style="color: #666666; font-style: italic;">; General Form Information</span>
login.action <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;login/submit&quot;</span>
login.method <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;post&quot;</span>
login.id <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;login&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; Form Decorators</span>
login.decorators.elements.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;FormElements&quot;</span>
login.decorators.table.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
login.decorators.table.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;table&quot;</span>
login.decorators.form.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Form&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; Username Element</span>
login.elements.username.type <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;text&quot;</span>
login.elements.username.options.label <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Username:&quot;</span>
login.elements.username.options.required <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> true</span>
login.elements.username.options.validators.alnum.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;alnum&quot;</span>
login.elements.username.options.validators.regex.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;regex&quot;</span>
login.elements.username.options.validators.regex.options.pattern <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;/^[a-z]/i&quot;</span>
login.elements.username.options.validators.strlen.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;StringLength&quot;</span>
login.elements.username.options.validators.strlen.options.min <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;5&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; Username Decorators</span>
login.elements.username.options.decorators.helper <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;ViewHelper&quot;</span>
login.elements.username.options.decorators.tableData.decorator.td <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
login.elements.username.options.decorators.tableData.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;td&quot;</span>
login.elements.username.options.decorators.label.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Label&quot;</span>
login.elements.username.options.decorators.label.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;td&quot;</span>
login.elements.username.options.decorators.tableRow.decorator.tr <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
login.elements.username.options.decorators.tableRow.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;tr&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; Password Element</span>
login.elements.password.type <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;password&quot;</span>
login.elements.password.options.label <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Password:&quot;</span>
login.elements.password.options.required <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> true</span>
login.elements.password.options.validators.strlen.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;StringLength&quot;</span>
login.elements.password.options.validators.strlen.options.min <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;6&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; Password Decorators</span>
login.elements.password.options.decorators.helper <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;ViewHelper&quot;</span>
login.elements.password.options.decorators.tableData.decorator.td <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
login.elements.password.options.decorators.tableData.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;td&quot;</span>
login.elements.password.options.decorators.label.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Label&quot;</span>
login.elements.password.options.decorators.label.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;td&quot;</span>
login.elements.password.options.decorators.tableRow.decorator.tr <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
login.elements.password.options.decorators.tableRow.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;tr&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; Submit Form Element</span>
login.elements.submit.type <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;submit&quot;</span>
login.elements.submit.options.label <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Submit&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; Submit Decorators</span>
login.elements.submit.options.decorators.helper <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;ViewHelper&quot;</span>
login.elements.submit.options.decorators.tableData.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
login.elements.submit.options.decorators.tableData.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;td&quot;</span>
login.elements.submit.options.decorators.label.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Label&quot;</span>
login.elements.submit.options.decorators.label.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;td&quot;</span>
login.elements.submit.options.decorators.label.options.class <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;submit&quot;</span>
login.elements.submit.options.decorators.tableRow.decorator.tr <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
login.elements.submit.options.decorators.tableRow.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;tr&quot;</span></pre></div></div>

<p>Personally, I think this is poor design and feel it may even be a bug, but I will attempt to submit it to ZF&#8217;s issue tracker and see what they say.  Otherwise though, I still feel as though Zend_Form is a great component, and will continue to publish any discoveries I come across.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2008/03/26/creating-tables-with-zend_form/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Using Zend_Form with Zend_Config</title>
		<link>http://www.vayanis.com/2008/03/17/using-zend_form-with-zend_config/</link>
		<comments>http://www.vayanis.com/2008/03/17/using-zend_form-with-zend_config/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 05:35:41 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Guides]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Form]]></category>
		<category><![CDATA[Zend_Form Tables]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/2008/03/17/using-zend_form-with-zend_config/</guid>
		<description><![CDATA[In my previous post Zend Framework, A First Look, I discussed the lacking nature of ZF&#8217;s documentation, in particular, with regards to Zend_Form.  I have since then learned that this is partly due to the fact that Zend_Form is a relatively new component.  However, I   still wanted to make use of [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post <a href="http://www.vayanis.com/2008/03/14/zend-framework-a-first-look/">Zend Framework, A First Look</a>, I discussed the lacking nature of ZF&#8217;s documentation, in particular, with regards to Zend_Form.  I have since then learned that this is partly due to the fact that Zend_Form is a relatively new component.  However, I   still wanted to make use of Zend_Form in my current project and decided to trudge through the learning curve of creating a simple custom login form in conjunction with Zend_Config; the end result being an easy to maintain, custom form and this guide.  Hopefully, this guide will make it easier for anyone else looking to take advantage of this very cool feature.<br />
<span id="more-28"></span><br />
Before I begin talking about how Zend_Form works, I think it is important to explain a bit about Zend_Config and how an INI file is translated into PHP.  As the <a href="http://framework.zend.com/manual/en/zend.config.html">Zend_Config Documentation</a> points out, it makes use of PHP native parse_ini_file, however, this only goes so far as reading in the contents of the file and turning it into a 1 dimensional associative array(2 if a section is provided).  Zend_Config extends this behavior by taking the keys of each association and breaking them down further based upon the specified <em>key separator (default is &#8216;.&#8217;).</em> and turning the remainder into arrays.  In the end, Zend_Config takes a series of declarations such as the following:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">login.elements.username.type <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;text&quot;</span></pre></div></div>

<p>And turns it into:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">Array</span>
<span style="color: #009900;">&#40;</span>
    <span style="color: #009900;">&#91;</span>login<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
        <span style="color: #009900;">&#40;</span>
            <span style="color: #009900;">&#91;</span>elements<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                <span style="color: #009900;">&#40;</span>
                    <span style="color: #009900;">&#91;</span>username<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                        <span style="color: #009900;">&#40;</span>
                            <span style="color: #009900;">&#91;</span>type<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> text
                        <span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span></pre></div></div>

<p>Now, back to Zend_Form.  I think my biggest gripe with the documentation provided for Zend_Form is that it does not explain how anything is working behind the scenes.  For instance, it does not explain that Zend_Form normalizes config statements by prepending &#8217;set&#8217; when making calls to member methods.  This is invaluable as it explains why</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setElementDecorators</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ViewHelper'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>in PHP becomes</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">    elementDecorators.helper <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;ViewHelper&quot;</span></pre></div></div>

<p>in a Zend_Config_Ini.  Internally, elementDecorators tells Zend_Form to call setElementDecorators();  This small example also shows why it is important to know how Zend_Config_Ini actually translates an INI to PHP&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">Array</span>
<span style="color: #009900;">&#40;</span>
    <span style="color: #009900;">&#91;</span>elementDecorators<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
        <span style="color: #009900;">&#40;</span>
            <span style="color: #009900;">&#91;</span>helper<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> ViewHelper
        <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span></pre></div></div>

<p>As we can see this declares an array of decorators to be passed into setElementDecorators();  The keys, in this case &#8220;helper&#8221;, do not necessarily matter as it is only needed to index the array, the values are what matter, as that is what is passed and used within Zend_Form.  Similarly, it is important to know that almost all aspects of form and form elements, excluding form element type, are implemented internally as options.  The following is an example INI file with comments explaining particular sections.</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">    <span style="color: #666666; font-style: italic;">; A basic Form config</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; First level attributes are automatically treated as options.</span>
    <span style="color: #000099;">action</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;login/submit&quot;</span>
    <span style="color: #000099;">method</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;post&quot;</span>
    <span style="color: #000099;">id</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;login&quot;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; Form Decorators</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; Again these decorators are treated as options of the main form.</span>
    decorators.elements.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;FormElements&quot;</span>
    decorators.table.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
    decorators.table.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;table&quot;</span>
    decorators.form.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Form&quot;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; Username Element</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; Form Element Type is specified explicityly, not as an option.</span>
    elements.username.type <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;text&quot;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; Username attributes (Label, Required, and validators are all</span>
    <span style="color: #666666; font-style: italic;">; declared as options).</span>
    elements.username.options.label <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Username:&quot;</span>
    elements.username.options.required <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> true</span>
    elements.username.options.validators.alnum.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;alnum&quot;</span>
    elements.username.options.validators.regex.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;regex&quot;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; Validator parameters such as pattern to regex are also</span>
    <span style="color: #666666; font-style: italic;">; declared as options. I have not looked into it, but I</span>
    <span style="color: #666666; font-style: italic;">; assume this is due to the way Zend_Validate handles its</span>
    <span style="color: #666666; font-style: italic;">; own constructors.</span>
    elements.username.options.validators.regex.options.pattern <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;/^[a-z]/i&quot;</span>
    elements.username.options.validators.strlen.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;StringLength&quot;</span>
    elements.username.options.validators.strlen.options.min <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;5&quot;</span></pre></div></div>

<p>Bringing it all together, the following is the first version of my login form.</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">    <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>login<span style="">&#93;</span></span>
    <span style="color: #666666; font-style: italic;">; General Form Information</span>
    login.action <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;login/submit&quot;</span>
    login.method <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;post&quot;</span>
    login.id <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;login&quot;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; Form Decorators</span>
    login.decorators.elements.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;FormElements&quot;</span>
    login.decorators.table.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
    login.decorators.table.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;table&quot;</span>
    login.decorators.form.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Form&quot;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; Username Element</span>
    login.elements.username.type <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;text&quot;</span>
    login.elements.username.options.label <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Username:&quot;</span>
    login.elements.username.options.required <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> true</span>
    login.elements.username.options.validators.alnum.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;alnum&quot;</span>
    login.elements.username.options.validators.regex.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;regex&quot;</span>
    login.elements.username.options.validators.regex.options.pattern <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;/^[a-z]/i&quot;</span>
    login.elements.username.options.validators.strlen.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;StringLength&quot;</span>
    login.elements.username.options.validators.strlen.options.min <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;5&quot;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; Password Element</span>
    login.elements.password.type <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;password&quot;</span>
    login.elements.password.options.label <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Password:&quot;</span>
    login.elements.password.options.required <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> true</span>
    login.elements.password.options.validators.strlen.validator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;StringLength&quot;</span>
    login.elements.password.options.validators.strlen.options.min <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;6&quot;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">; Submit Form Element</span>
    login.elements.submit.type <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;submit&quot;</span>
    login.elements.submit.options.label <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Submit&quot;</span>
&nbsp;
    login.elementDecorators.viewHelper <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;ViewHelper&quot;</span>
    login.elementDecorators.errors <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Errors&quot;</span>
&nbsp;
    login.elementDecorators.tableData.decorator.td <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
    login.elementDecorators.tableData.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;td&quot;</span>
    login.elementDecorators.tableData.options.class <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;test2&quot;</span>
&nbsp;
    login.elementDecorators.label.decorator <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Label&quot;</span>
    login.elementDecorators.label.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;td&quot;</span>
&nbsp;
    login.elementDecorators.tableRow.decorator.tr <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;HtmlTag&quot;</span>
    login.elementDecorators.tableRow.options.tag <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;tr&quot;</span></pre></div></div>

<p>This creates a login form with a username and password field along with a submit button.  However, instead of being wrapped in a definition list using definition titles for labels and definition data for input fields, I have wrapped the labels and input fields within a table similar to the google login form.  Notice though, that I have sectioned this form using <em>[login]</em>.  Tthis is so that I can define all my necessary forms in one forms.ini file and load each form by section.  I have also prepended each declaration with <em>login.</em> as a way to keep my form definitions organized and easy to read (to me at least).  </p>
<p>Concluding this guide, I would like to reiterate, how useful I think Zend_Form is as it solves one of the most tedious process for any PHP project; form creation and validation.  I hope it continues to evolve and mature, and I hope others find it as handy as I have.  Although, if anyone has an easier solution, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2008/03/17/using-zend_form-with-zend_config/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Zend Framework, A First Look</title>
		<link>http://www.vayanis.com/2008/03/14/zend-framework-a-first-look/</link>
		<comments>http://www.vayanis.com/2008/03/14/zend-framework-a-first-look/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 14:32:16 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Form]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/2008/03/14/zend-framework-a-first-look/</guid>
		<description><![CDATA[Having used Code Igniter for some small projects at work, I recently decided to take the time to acquaint myself with the Zend Framework(ZF) so that I could build my own comparison between two of the most, in my opinion, developed and used PHP frameworks.  While I love the flexibility and functionality offered by [...]]]></description>
			<content:encoded><![CDATA[<p>Having used <a href="http://www.codeigniter.com">Code Igniter</a> for some small projects at work, I recently decided to take the time to acquaint myself with the <a href="http://framework.zend.com">Zend Framework</a>(ZF) so that I could build my own comparison between two of the most, in my opinion, developed and used PHP frameworks.  While I love the flexibility and functionality offered by ZF, I have become very frustrated and annoyed with some of their documentation.  Even though it is detailed and expansive, it is no where near complete and somewhat frustrating to use.<br />
<span id="more-27"></span><br />
Zend_Form is a great example of this incomplete documentation.  Conceptually, I think the Zend_Form is great. It offers very useful, and much needed functionality for creating and validating forms within pages and although it offers 4 pages of documentation and highlights many features, it barely touches upon one of its most useful features: the ability to create a form by passing the constructor a Zend_Config_Ini object.  In its simplest form this amounts to the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$loginForm</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Form<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Zend_Config_Ini<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/path/to/form/config'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'login'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><em>This will create a Zend_Form object by passing it a Zend_Config_Ini object.</em></p>
<p>Unfortunately, when you decide to build a custom form using Zend_Config, the documentation on how this actually works, is extremely sparse.  There are three examples of using the Zend_Config, however, they are not commented and there is no explanation as to how it works, there is only a weak reference to PHP object oriented code from which to draw conclusions from.  Maybe, I am too used to the <a href="http://java.sun.com/javase/6/docs/api/">Java API documentation</a>.</p>
<p>Anyways, after a few days with ZF, it has become apparent to me, that ZF is a very well written, powerful, extensible, and versatile PHP framework.  However, due to its incomplete documentation, I would argue that its&#8217; learning curve is fairly high, much higher than Code Igniter&#8217;s.  In time though, I am sure the ZF developers will realize this, and make the effort to provide better documentation.  In the meantime though, I am going to continue to use ZF and hopefully, take it upon myself to provide some insight; a Zend_Form tutorial using Zend_Config is already in the works.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2008/03/14/zend-framework-a-first-look/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Starcraft 2 &#8211; Terran Gameplay Trailer</title>
		<link>http://www.vayanis.com/2007/10/14/starcraft-2-terran-gameplay-trailer/</link>
		<comments>http://www.vayanis.com/2007/10/14/starcraft-2-terran-gameplay-trailer/#comments</comments>
		<pubDate>Sun, 14 Oct 2007 06:13:52 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Starcraft]]></category>
		<category><![CDATA[Starcraft 2]]></category>
		<category><![CDATA[Terran]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/2007/10/14/starcraft-2-terran-gameplay-trailer/</guid>
		<description><![CDATA[I am not sure if it wasn&#8217;t publicized or if I just missed it, but the Starcraft 2, Terran gameplay trailer has arrived (officially on Sept. 13th).  Even though my favorite race is Zerg, I was still excited to view this video.  I mean, after watching the first gameplay trailer highlighting the Protoss, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.starcraft2.com" title="Starcraft 2 Logo"><img src="http://www.vayanis.com/wp-content/uploads/2007/05/starcraft2_logo.thumbnail.jpg" title="Starcraft 2 Logo" alt="Starcraft 2 Logo" align="left" /></a>I am not sure if it wasn&#8217;t publicized or if I just missed it, but the Starcraft 2, Terran gameplay trailer has arrived (officially on Sept. 13th).  Even though my favorite race is Zerg, I was still excited to view this video.  I mean, after watching the first gameplay trailer highlighting the Protoss, who wouldn&#8217;t be excited.</p>
<p>Since I don&#8217;t play the game as much as I did when it first game out, I have no business trying to analyze the flaws of the original compared to what Blizzard has done and is doing with the sequel.  Therefore, I will stick to enumerating the new additions found in this latest gameplay trailer.<br />
<span id="more-25"></span></p>
<h4>Highlights</h4>
<ol>
<li>The Terran <em>Command Center</em> now doubles as an scv transport.  This gives Terrans unprecedented mobility when trying to rebuild.</li>
<li>Terran buildings now have modular addons.  Each addon, provides special functionality.  In particular, the <em>Reactor</em> allows buildings such as barracks to double their output capacity.</li>
<li>The new detector, the <em>Sensor Tower</em>, upgrades into a radar tower which has a much larger range and allows players to detect enemies in the fog of war.</li>
<li><em>Battlecruisers</em> (and possibly all major units) are upgraded individually.  This means you must spend resources per <em>Battlecruiser</em> to give them your choice between the old Yammator Canon and the new Plasma array.</li>
<li>The <em>Viking</em> is the new <em>Valkyrie</em>.  It deals area of effect (AOE) damage to capital airships, but thats not all.  It can also transform into a ground assault unit.</li>
<li>The <em>Banshee</em> is the new <em>Wraith</em>.  It is an air unit with the ability to cloak, but unlike the <em>Wraith</em>, it is armed with AOE missiles (This seems a bit too much considering the new Viking, so I wonder if it is only an Air to Ground attack unit).</li>
<li>As was seen in the original gameplay trailer, the <em>Reaper</em> is a new light ground unit with the ability to traverse terrain obstacles.  However, this new trailer highlights the <em>Reaper&#8217;s</em> new armament: demolition charges.  These demolition charges are basically land mines with timers.</li>
<li>The Terran <em>Command Center</em> now has the ability to transform into a planetary fortress, giving it a heavy artillery canon for defending against enemies.</li>
<li>The <em>Thor</em> is the new Terran heavy siege unit.  It looks like a cross between a <em>Battlecruiser</em> and a <em>Siege Tank</em> as it has both, powerful laser canons and a siege mode.</li>
<li>Replacing the <em>Vulture</em> is the <em>Cobra</em>, a fast ground attack vehicle armed with a rail gun.</li>
<li>Last, but not least, are the <em>Ghosts</em>.  However, <em>Ghosts</em> are no longer weak attack units.  They come with a new &#8220;sniper&#8221; attack that is a slow and high damage (one shot against marines).  In addition to the traditional nukes, <em>Ghosts</em> can call down drop pods which are basically paratroopers.  This should make base raids and sieges particularly interesting.</li>
</ol>
<p>Since this is the third time I have seen the gameplay trailer, I must admit, I am impressed with the direction of Starcraft 2.  Although it stays true to the original in terms of gameplay, this sequel adds many new dynamics to the game.  Each race we have seen so far looks like they will have many more options for building effective armies.  Micromanagement will again most likely separate good players from great players, and as I said in <a href="http://www.vayanis.com/2007/05/31/starcraft-2-no-longer-a-rumor/">my last post</a>, terrain will probably be a big part of the game.  All we need now, is the Zerg&#8217;s gameplay trailer so that we can marvel in what will be Starcraft 2.</p>
<h4>Trailer Download</h4>
<p><a href="http://starcraft2.com/movies.xml">Blizzard&#8217;s Starcraft 2 movie page</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2007/10/14/starcraft-2-terran-gameplay-trailer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sending POST requests with PHP</title>
		<link>http://www.vayanis.com/2007/08/28/sending-post-requests-with-php/</link>
		<comments>http://www.vayanis.com/2007/08/28/sending-post-requests-with-php/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 16:13:06 +0000</pubDate>
		<dc:creator>Andrew Vayanis</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.vayanis.com/2007/08/28/sending-post-requests-with-php/</guid>
		<description><![CDATA[I recently found myself writing a REST web service, which, in my opinion, is the easiest way to create a web service, for a project at work.  Using XML.com&#8217;s How to Create a REST protocol as my Guide, I went to work.  However, when I tried to create a service to update some [...]]]></description>
			<content:encoded><![CDATA[<p>I recently found myself writing a REST web service, which, in my opinion, is the easiest way to create a web service, for a project at work.  Using XML.com&#8217;s <a href="http://www.xml.com/pub/a/2004/12/01/restful-web.html">How to Create a REST protocol</a> as my Guide, I went to work.  However, when I tried to create a service to update some data, I wasn&#8217;t sure how to send my data in a POST request using PHP.  After some stumbling around, I found what I was looking for on <a href="http://netevil.org/blog/2006/nov/http-post-from-php-without-curl">Wez Furlong&#8217;s blog</a> which led me to PHP&#8217;s documentation on <a href="http://www.php.net/manual/en/wrappers.http.php">HTTP and HTTPS wrappers</a>.</p>
<p>The following is a code snippet from the HTTP and HTTPS documentation that shows how to easily send data using HTTP POST:<br />
<span id="more-24"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$postdata</span> <span style="color: #339933;">=</span> <span style="color: #990000;">http_build_query</span><span style="color: #009900;">&#40;</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'var1'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'some content'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'var2'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'doh'</span>
    <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$opts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http'</span> <span style="color: #339933;">=&gt;</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'method'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'POST'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'header'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Content-type: application/x-www-form-urlencoded'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'content'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$postdata</span>
    <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$context</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">stream_context_create</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$opts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://example.com/submit.php'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$context</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Quick Explanation</h3>
<ol>
<li><a href="http://us.php.net/http_build_query">http_build_query</a>: Generates an URL-encoded string from an associative array.  Example: array(&#8216;key1&#8242; => &#8216;value1&#8242;, &#8216;key2&#8242; => &#8216;value2&#8242;) becomes &#8220;key1=value1&#038;key2=value2&#8243;
<p>This properly encodes the data for the post transaction.</p>
</li>
<li><a href="http://us.php.net/manual/en/function.stream-context-create.php">stream_context_create</a>: Creates and returns a resource to a stream context from an associative array of arrays in the format <em>$arr['wrapper']['option'] = $value</em>
<p>This creates a linear output stream to be sent during the request transmission.</p>
</li>
<li><a href="http://us3.php.net/manual/en/function.file-get-contents.php">file_get_contents</a>: Acts exactly like file(); except that it reads an entire file into a string.
<p>This requests a file resource and puts the result into a string.</p>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.vayanis.com/2007/08/28/sending-post-requests-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
