<?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>GS Design &#187; Programing</title>
	<atom:link href="http://www.gsdesign.ro/blog/category/programing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gsdesign.ro/blog</link>
	<description>Just another developer blog</description>
	<lastBuildDate>Thu, 06 Jan 2011 22:28:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Database design example for a configurable product eshop</title>
		<link>http://www.gsdesign.ro/blog/database-design-example-for-a-configurable-product-eshop/</link>
		<comments>http://www.gsdesign.ro/blog/database-design-example-for-a-configurable-product-eshop/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 22:28:20 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[database design]]></category>
		<category><![CDATA[eshop]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=449</guid>
		<description><![CDATA[I was building an e-shop and one of the requiremens was to have configurable products. The configurable parts will need to have different prices and stocks from the main product.  Also the shop must be able to move products from one category to another. So i started thinking of a database structure that will enable [...]]]></description>
			<content:encoded><![CDATA[<p>I was building an e-shop and one of the requiremens was to have configurable products.<br />
The configurable parts will need to have different prices and stocks from the main product.  Also the shop must be able to move products from one category to another.</p>
<p>So i started thinking of a database structure that will enable me to accomplish this. As i started to research i also posted a question on <a href="http://stackoverflow.com/q/2645958/65503">stackoverflow</a> to see what others had in mind.</p>
<p><span id="more-449"></span></p>
<h3>The design</h3>
<p>After a bit of thought i came up with this design.<br />
<a href="http://www.gsdesign.ro/blog/wp-content/uploads/2010/12/screenshot_001.jpeg"><img class="aligncenter size-full wp-image-450" title="screenshot_001" src="http://www.gsdesign.ro/blog/wp-content/uploads/2010/12/screenshot_001.jpeg" alt="" width="389" height="420" /></a></p>
<h3>Design Details</h3>
<p><strong>Products have an id_configuration</strong><br />
A configurable products actually is a collection of products witch have the same id_configuration (witch is auto-generated).</p>
<p><strong>Features linked to products</strong><br />
Rather then categories, which seems more naturally to me. This enables me to easily move products between categories.</p>
<p><strong>Product features values is stored in the link table</strong><br />
I decided to store the feature value for a product in the link table. This helps with more simple queries and also it means that you don&#8217;t have to insert all the options in the feature options table (think of features that have different values for all products)</p>
<p><strong>Name and Label for features</strong><br />
The name is used internally in the admin section and Label is used in the site front-end. This is useful for features with same name. Ex: Size for clothes, size for hardisks etc.</p>
<p><strong> Filterable flag on features </strong><br />
A Yes/No flag that shows witch filters are filtrable.</p>
<h3>Examples of use</h3>
<p><strong>Selecting products</strong><br />
The most important thing is how do we select products, and how do we only show one product for the configurable ones. For this we use GROUP BY.<br />
<code class="prettyprint"><br />
SELECT * FROM `products`<br />
GROUP BY CASE `products`.`configurable` WHEN 'yes' THEN `products`.`id_configuration` ELSE `products`.`id` END<br />
</code></p>
<p><strong>Filtering products</strong><br />
The bellow example shows the query for a single filter/feature (with id 38) and 2 values selected:<br />
<code class="prettyprint"><br />
SELECT * FROM `products`<br />
WHERE `id` IN (SELECT id_product FROM `product-features` WHERE `id_feature` = 38 AND `value` IN ('Test value', 'New Value') GROUP BY id_product HAVING COUNT(*) >= 1)<br />
GROUP BY CASE `products`.`configurable` WHEN 'yes' THEN `products`.`id_configuration` ELSE `products`.`id` END<br />
</code></p>
<p><strong>Get active filters</strong><br />
After you have a list of filter products you will want to print out a list of filters that are applicable to this list, since not all are available to the current selected products.<br />
<code class="prettyprint"><br />
SELECT `id_feature` FROM `product-features`<br />
WHERE `id_product` IN (SELECT `id` FROM `products` WHERE ___YOUR_CONDITIONS____) GROUP BY `id_feature`<br />
</code><br />
<em>Notice that i left out the GROUP BY from the product subselect.</em></p>
<p><strong>Associate count of products for a filter</strong><br />
Its very useful to show the count of products for a certain value of a filter. The bellow query is how you can select that count for one filter.<br />
<code class="prettyprint"><br />
SELECT *, COUNT(*) AS `count` FROM (<br />
    SELECT *<br />
    FROM `product-features`<br />
    WHERE<br />
        `id_product` IN (SELECT `id` FROM `products` WHERE ___YOUR_CONDITIONS____) AND<br />
        `id_feature` = 36<br />
) AS `tbl` GROUP BY `value`<br />
</code><br />
<em>Notice that i left out the GROUP BY from the product subselect.</em></p>
<h3>Conclusions</h3>
<p>I think this database model works best for what i wanted and it has all the flexibility i needed:<br />
- it allows for any 2 products to group as configurable<br />
- you can add promotions and separate images for each variation<br />
- have separate stocks on each variation (witch make more sense to me)<br />
- get sales report cumulate or separate on each variation.</p>
<p>Hope you like this approach and i await you comments on it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/database-design-example-for-a-configurable-product-eshop/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Error: svn attempt to write a readonly database, commit failed</title>
		<link>http://www.gsdesign.ro/blog/error-svn-attempt-to-write-a-readonly-database-commit-failed/</link>
		<comments>http://www.gsdesign.ro/blog/error-svn-attempt-to-write-a-readonly-database-commit-failed/#comments</comments>
		<pubDate>Tue, 09 Nov 2010 14:07:20 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[php advanced]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=446</guid>
		<description><![CDATA[After upgrading our server subversion to 1.6.2 on a new repo i run into this error when commiting: svn attempt to write a readonly database commit failed Although if i looked at the repo the commited files were there. After hunting Google a bit, I found the problem to be with the &#8220;/svn/repopath/db/rep-cache.db&#8221; file that [...]]]></description>
			<content:encoded><![CDATA[<p>After upgrading our server subversion to 1.6.2 on a new repo i run into this error when commiting:</p>
<blockquote><p>
svn attempt to write a readonly database<br />
<strong>commit failed</strong>
</p></blockquote>
<p>Although if i looked at the repo the commited files were there.</p>
<p>After hunting Google a bit, I found the problem to be with the <strong>&#8220;/svn/repopath/db/rep-cache.db&#8221;</strong> file that did not have write permissions for the user subversion uses.<br />
After fixing permissions, committing went perfectly with no errors. </p>
<p>Hope it helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/error-svn-attempt-to-write-a-readonly-database-commit-failed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Access Dropbox.com behind corporate / company firewall</title>
		<link>http://www.gsdesign.ro/blog/access-dropbox-com-behind-corporate-company-firewall/</link>
		<comments>http://www.gsdesign.ro/blog/access-dropbox-com-behind-corporate-company-firewall/#comments</comments>
		<pubDate>Wed, 19 May 2010 08:05:52 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[hosts]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=435</guid>
		<description><![CDATA[If you find yourself one morning with your dropbox client not connecting to the server, and you trace the problem to the company/ISP ( or country if your in China :-p ) firewall then you can put the kind words for them to the side a little and try the following. Most of the firewalls [...]]]></description>
			<content:encoded><![CDATA[<p>If you find yourself  one morning with your dropbox client not connecting to the server, and you trace the problem to the company/ISP ( or country if your in China :-p ) firewall then you can put the kind words for them to the side a little and try the following.<br />
Most of the firewalls block the main IP for dropbox.com 174.36.30.70 but the alternate IP is open <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So add this to your hosts:<br />
<code>174.36.30.71 www.dropbox.com</code></p>
<p>Hope it works for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/access-dropbox-com-behind-corporate-company-firewall/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>php adwords api library</title>
		<link>http://www.gsdesign.ro/blog/php-adwords-api-library/</link>
		<comments>http://www.gsdesign.ro/blog/php-adwords-api-library/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 17:45:13 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[php classes]]></category>
		<category><![CDATA[adword]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=425</guid>
		<description><![CDATA[Recently i posted on google code a library we developed to interact with Adwords Api from php. Php Adwords API Library was developed by Hyperactive team for an internal project, since we didn&#8217;t like options available and felt we could do something that would be easier to work with, at least for us. We made [...]]]></description>
			<content:encoded><![CDATA[<p>Recently i posted on google code a library we developed to interact with Adwords Api from php.<br />
<strong>Php Adwords API Library</strong> was developed by <a href="http://www.hyperactive.ro/">Hyperactive team</a> for an internal project, since we didn&#8217;t like <a href="http://code.google.com/intl/ro-RO/apis/adwords/docs/clients.html">options available</a> and felt we could do something that would be easier to work with, at least for us. We made it public so that others looking for a php library to interact with adwords api would have more options to chose from ( plus free testing for us :-p ).</p>
<p>The project can be found here:<br />
<a href="http://code.google.com/p/php-adwords-api/">http://code.google.com/p/php-adwords-api/</a></p>
<p>It is still a work in progress and does not yet support all the services and functions of the API, but we hope to add more services as soon as possible. And if you need a certain service or function please dont hesitate to add a ticket on google code and request it.</p>
<p>You will find examples of usage in the folder examples of the library.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/php-adwords-api-library/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PDF Generation with Zend Framework</title>
		<link>http://www.gsdesign.ro/blog/pdf-generation-with-zend-framework/</link>
		<comments>http://www.gsdesign.ro/blog/pdf-generation-with-zend-framework/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 18:54:46 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[zend framework]]></category>
		<category><![CDATA[generation]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=402</guid>
		<description><![CDATA[Guest Post by: Jonathan Maron has been working in the web application conceptualization and development space since 1996. His current position is with an international company, specialized in the production of word processing components. Being an advocate of the FOSS movement, Jonathan promotes the use of Open Source software and rejects the notion of reinventing [...]]]></description>
			<content:encoded><![CDATA[<div style="background-color:#F8F8EE;padding:4px;"><img src="http://a1.twimg.com/profile_images/94865980/39d66a8cf.7605677.jpg" alt="Jonathan Maron" align="left" height="120" style="margin-right:5px;" /><em>Guest Post by:</em><br />
<strong>Jonathan Maron</strong> has been working in the web application conceptualization and development space since 1996. His current position is with an international company, specialized in the production of word processing components. Being an advocate of the FOSS movement, Jonathan promotes the use of Open Source software and rejects the notion of reinventing the wheel, preferring to develop with established frameworks.</div>
<p>Generating print-ready well-formatted PDF documents with PHP is not an easy task. Traditionally, there are two main approaches to PDF generation with PHP. Given sufficient time and patience, both partially get the job done, but still leave a lot to be desired:</p>
<p><strong>HTML-to-PDF</strong>: This approach is widely used in mainstream applications. Here an HTML document is programmatically created and converted to a PDF, using one of the many open source libraries <sup><a href="#foot-01">1</a></sup>. Since HTML, however, is not a page-oriented format (as is PDF), it is impossible to perform a 1-to-1 mapping between HTML and PDF. Typical word processing file format features, such as header and footers, orphans and widows or even page numbers can simply not be represented in HTML.<br />
<span id="more-402"></span></p>
<h2>Table of contents</h2>
<ul>
<li><a href="#A-completely-new-approach">A completely new approach</a></li>
<li><a href="#Introducing-LiveDocx">Introducing LiveDocx</a></li>
<li><a href="#Templates-and-documents">Templates and documents</a></li>
<li><a href="#Using-LiveDocx">Using LiveDocx</a>
<ul>
<li><a href="#Creating-a-template-in-Microsoft--Word-2007">Creating a template in Microsoft® Word 2007</a></li>
<li><a href="#Assigning-scalar-data-types-in-LiveDocx">Assigning scalar data types in LiveDocx</a></li>
<li><a href="#Assigning-compound-data-types-in-LiveDocx">Assigning compound data types in LiveDocx</a></li>
<li><a href="#Generating-image-files-with-LiveDocx">Generating image files with LiveDocx</a></li>
</ul>
</li>
<li><a href="#Deploying-LiveDocx-in-your-own-applications">Deploying LiveDocx in your own applications</a></li>
<li><a href="#Learn-more">Learn more</a>
<ul>
<li><a href="#LiveDocx-in-PHP-5">LiveDocx in PHP 5</a></li>
<li><a href="#LiveDocx-SOAP-service">LiveDocx SOAP service</a></li>
</ul>
</li>
<li><a href="#Footnotes">Footnotes</a></li>
</ul>
<p><strong>Programmatic</strong>: This approach offers total control of the resulting PDF. However, it requires that the x and y coordinates of every line of text, every geometrical shape and graphic be set from program code <sup><a href="#foot-02">2</a></sup>. Not only is this an extremely time-consuming solution, but is also very brittle: Every time a graphical designer changes the layout of a document, a programmer must re-work his or her program code.</p>
<p><a name="A-completely-new-approach"></a></p>
<h2>A completely new approach</h2>
<p>In this article, the author presents an entirely new, third approach. It relies on templates being created in a WYSIWYG environment, such as Microsoft® Word or Open Office, and then being populated with data in PHP. The resulting document can be saved not only to PDF, but also DOCX, DOC and RTF.</p>
<p>Before we delve into a technical discussion on the inner workings of this new approach, let us first take a look at a practical example. The following PHP 5 code illustrates PDF generation, in which the merge fields <em>software</em>, <em>licensee</em> and <em>company</em> in the template <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/license-agreement-template.docx">template.docx</a> <small>[46.7 KB]</small> are populated with scalar data in PHP. The resulting document <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/license-agreement-document.pdf">document.pdf</a> <small>[104.7 KB]</small> is created and written to disk.</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showCodeTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Service_LiveDocx_MailMerge<span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'username'</span> =&gt; <span style="color:#FF0000;">'yourUsername'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'password'</span> =&gt; <span style="color:#FF0000;">'yourPassword'</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">setLocalTemplate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'template.docx'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'software'</span>, <span style="color:#FF0000;">'Magic Graphical Compression Suite v1.9'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'licensee'</span>, <span style="color:#FF0000;">'Henry Smith'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'company'</span>,&nbsp; <span style="color:#FF0000;">'Megasoft Co-operation'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">createDocument</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$document</span> = <span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">retrieveDocument</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'pdf'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">file_put_contents<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'document.pdf'</span>, <span style="color:#0000FF;">$document</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/unset"><span style="color:#000066;">unset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$phpLiveDocx</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The code demonstrated in this article will be shipped with the <a href="http://is.gd/3Qo5v">Zend Framework 1.10</a> when it becomes available. Although at the time of writing, there is no official release date, 1.10 is expected to release in Q4 2009. In the meantime, you can check the components out of the <a href="http://is.gd/3RHxJ">Standard Incubator</a> SVN repository.</p>
<p><a name="Introducing-LiveDocx"></a></p>
<h2>Introducing LiveDocx</h2>
<p><a href="http://is.gd/3QmRf">LiveDocx</a> is a <a href="http://is.gd/3Qn3m">SOAP</a>-based document generation service, based on the market-leading, word processing component <a href="http://is.gd/3QmUe">TX Text Control .NET</a>. LiveDocx allows word processing templates to be populated in any programming language that supports SOAP. The resulting document can be saved to any supported format. This article, however, concentrates on using LiveDocx in PHP 5.</p>
<p>The components of the Zend Framework implementation of LiveDocx are located at <em>/Zend/Service/LiveDocx/</em> in the standard Zend Framework distribution file. It is possible to use LiveDocx directly with the PHP 5 <a href="http://is.gd/3QmK5">SoapClient</a>, without the Zend Framework, and with the third party library <a href="http://is.gd/3QmMu">NuSOAP</a>. The NuSOAP approach even allows LiveDocx to be used in PHP 4. This article, however, concentrates on the official Zend Framework components in PHP 5.</p>
<p><a name="Templates-and-documents"></a></p>
<h2>Templates and documents</h2>
<p>Throughout this article, we refer to the terms <em>templates</em> and <em>documents</em>. It is important to understand the difference between the two.</p>
<p><strong>Templates</strong>: The term <em>template</em> is used to refer to the input file, containing formatting and text fields. Templates can be in any one of the following file formats:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Office_Open_XML">DOCX</a> - Office Open XML Format</li>
<li><a href="http://en.wikipedia.org/wiki/DOC_%28computing%29">DOC</a> - Microsoft® Word DOC Format</li>
<li><a href="http://en.wikipedia.org/wiki/Rich_Text_Format">RTF</a> - Rich Text Format</li>
<li><a href="http://www.textcontrol.com/">TXD</a> - TX Text Control® Format</li>
</ul>
<p>Templates can be stored either <em>locally</em> on the client machine (the one from which the SOAP request is initiated) or <em>remotely</em> on the backend server. The decision on which one you should use depends upon the kind of application you are developing.</p>
<p>If you store the templates locally, you have to transfer the template together with the data that should be populated on every request. In the case that the template remains the same on every request, this approach is very inefficient. It would be better to upload the template to the backend server once and then reference it on all subsequent requests. This way, only the data that should be populated is transfered from the client to the backend server. Most applications, using LiveDocx fall into this category.</p>
<p>On the other hand, if you have a template that is constantly changing, or an application in which you enable end-users to upload templates, you may consider storing templates locally and transfer them every request. This approach, is obviously slower, as every request contains the template itself, in addition to the data to populate it.</p>
<p><strong>Documents</strong>: The term <em>document</em> is used to refer to the generated output file that contains the template file, populated with data - i.e. the finished document. Documents can be saved in any one of the following file formats:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Office_Open_XML">DOCX</a> - Office Open XML Format</li>
<li><a href="http://en.wikipedia.org/wiki/DOC_%28computing%29">DOC</a> - Microsoft® Word DOC Format</li>
<li><a href="http://en.wikipedia.org/wiki/Xhtml">HTML</a> - XHTML 1.0 Transitional Format</li>
<li><a href="http://en.wikipedia.org/wiki/Rich_Text_Format">RTF</a> - Rich Text Format</li>
<li><a href="http://en.wikipedia.org/wiki/Portable_Document_Format">PDF</a> - Acrobat® Portable Document Format</li>
<li><a href="http://www.textcontrol.com/">TXD</a> - TX Text Control Format</li>
<li><a href="http://en.wikipedia.org/wiki/Text_file">TXT</a> - ANSI Plain Text</li>
</ul>
<p>In addition to the above word processing file formats, documents can also be saved to the following image file formats:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/BMP_file_format">BMP</a> - Bitmap Image Format</li>
<li><a href="http://en.wikipedia.org/wiki/GIF">GIF</a> - Graphics Interchange Format</li>
<li><a href="http://en.wikipedia.org/wiki/Jpg">JPG</a> - Joint Photographic Experts Group Format</li>
<li><a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics">PNG</a> - Portable Network Graphics Format</li>
<li><a href="http://en.wikipedia.org/wiki/Tagged_Image_File_Format">TIFF</a> - Tagged Image File Format</li>
<li><a href="http://en.wikipedia.org/wiki/Windows_Metafile">WMF</a> - Windows Meta File Format</li>
</ul>
<p><a name="Using-LiveDocx"></a></p>
<h2>Using LiveDocx</h2>
<p>In this section, we are going to look at the entire process of creating a document using LiveDocx from scratch.</p>
<p><a name="Creating-a-template-in-Microsoft--Word-2007"></a></p>
<h3>Creating a template in Microsoft® Word 2007</h3>
<p>The first step in any LiveDocx project is the creation of a template. To do this, you can use either Open Office or Microsoft® Word. For the purpose of this article, we are going to use Microsoft® Word 2007. For instructions on using Open Office, please take a look at the <a href="http://is.gd/3Sps0">LiveDocx Blog</a>.</p>
<p><a href="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-dialog_zoom.png"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-dialog_zoom-300x197.png" alt="msword-dialog_zoom" title="msword-dialog_zoom" width="300" height="197" class="alignright size-medium wp-image-406" /></a></p>
<p>Start off by creating a new file in Microsoft® Word 2007 and save the template file as <em>template.docx</em>.</p>
<p>You can then start to compose the template, inserting text, graphics and merge fields with the <em>Field</em> dialog box, shown to the right.</p>
<p>After a while, you will have a template, which contains images, text and a number of merge fields. The merge fields are represented by <em>{ MERGEFIELD name }</em> and will be populated with scalar data in the next step. The follow screenshot of the template in Microsoft® Word 2007 illustrates how your template may look:</p>
<p><a href="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-basic-template_zoom.png"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-basic-template_zoom-300x225.png" alt="msword-basic-template_zoom" title="msword-basic-template_zoom" width="300" height="225" class="aligncenter size-medium wp-image-407" /></a></p>
<p>Save the template <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/license-agreement-template.docx">template.docx</a> <small>[46 KB]</small> when you are done.</p>
<p><a name="Assigning-scalar-data-types-in-LiveDocx"></a></p>
<h3>Assigning scalar data types in LiveDocx</h3>
<p>Now that we have the template file, the next step is to populate it with data. In the following example, we are going to assign scalar data types - in this case strings - to the template.</p>
<div class="igBar"><span id="lphp-9"><a href="#" onclick="javascript:showCodeTxt('php-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-9">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Service_LiveDocx_MailMerge<span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'username'</span> =&gt; <span style="color:#FF0000;">'yourUsername'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'password'</span> =&gt; <span style="color:#FF0000;">'yourPassword'</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">setLocalTemplate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'template.docx'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'software'</span>, <span style="color:#FF0000;">'Magic Graphical Compression Suite v1.9'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'licensee'</span>, <span style="color:#FF0000;">'Henry Smith'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'company'</span>,&nbsp; <span style="color:#FF0000;">'Megasoft Co-operation'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'date'</span>,&nbsp; &nbsp; &nbsp;<span style="color:#FF0000;">'October 10, 2009'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'time'</span>,&nbsp; &nbsp; &nbsp;<span style="color:#FF0000;">'14:12:01'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'city'</span>,&nbsp; &nbsp; &nbsp;<span style="color:#FF0000;">'Frankfurt'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'country'</span>,&nbsp; <span style="color:#FF0000;">'Germany'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">createDocument</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$document</span> = <span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">retrieveDocument</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'pdf'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">file_put_contents<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'document.pdf'</span>, <span style="color:#0000FF;">$document</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/unset"><span style="color:#000066;">unset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$phpLiveDocx</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>For many applications, in particular those in which PDF files are used of archiving purposes, you may wish to set the meta data of the PDF file. You can do this, by specifying an associative array with the meta data that should be embedded into the PDF file. The <em>setDocumentProperties()</em> method must be called before <em>createDocument()</em>:</p>
<div class="igBar"><span id="lphp-10"><a href="#" onclick="javascript:showCodeTxt('php-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-10">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$documentProperties</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF0000;">'title'</span>&nbsp; &nbsp; =&gt; <span style="color:#FF0000;">'Magic Graphical Compression Suite v1.9'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF0000;">'author'</span>&nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'Megasoft Co-operation'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF0000;">'subject'</span>&nbsp; =&gt; <span style="color:#FF0000;">'Magic Graphical Compression Suite v1.9'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF0000;">'keywords'</span> =&gt; <span style="color:#FF0000;">'Graphics, Magical, Compress, Suite, License'</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">setDocumentProperties</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$documentProperties</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The resulting document <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/license-agreement-document.pdf">document.pdf</a> <small>[104 KB]</small> is written to disk and can now be opened in your favorite PDF reader, such as the shipped <em>Document Viewer</em> in Ubuntu:</p>
<p><a href="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-basic-document_zoom2.png"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-basic-document_zoom2-300x240.png" alt="msword-basic-document_zoom" title="msword-basic-document_zoom" width="300" height="240" class="aligncenter size-medium wp-image-411" /></a></p>
<p><a name="Assigning-compound-data-types-in-LiveDocx"></a></p>
<h3>Assigning compound data types in LiveDocx</h3>
<p>In addition to the scalar data types, which were assigned to the template in the previous example, you can also assign compound data types, such as an associative array. Consider the template <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/telephone-bill-template.doc">template.doc</a> <small>[20.5 KB]</small> and the resulting document <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/telephone-bill-document.pdf">document.pdf</a> <small>[77.6 KB]</small>. In particular, take a look at the following section of the template (click to enlarge):</p>
<p><a href="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-complex-template_zoom.png"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-complex-template_zoom-300x225.png" alt="msword-complex-template_zoom" title="msword-complex-template_zoom" width="300" height="225" class="aligncenter size-medium wp-image-412" /></a></p>
<p>The section of the template between the bookmarks<br />
<img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-bookmark.png" alt="msword-bookmark" title="msword-bookmark" width="8" height="15" class="alignnone size-full wp-image-413" /><br />
 and <img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-bookmark.png" alt="msword-bookmark" title="msword-bookmark" width="8" height="15" class="alignnone size-full wp-image-413" /> is repeated in the final document to produce rows of a table. One sub-array of the following associate array is used for each row.</p>
<p>Using the following PHP 5 code, we are going to populate the template with an associative array of telephone connection data. For clarity, this example shows only the part in which an associative array is assigned. The instantiation of LiveDocx and the document creation and retrievable processes are identical to the previous examples and have been omitted:</p>
<div class="igBar"><span id="lphp-11"><a href="#" onclick="javascript:showCodeTxt('php-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-11">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// instantiate LiveDocx </span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$billConnections</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_number'</span>&nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'+11 (0)222 333 441'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_duration'</span> =&gt; <span style="color:#FF0000;">'00:01:01'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fee'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'1.15'</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_number'</span>&nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'+11 (0)222 333 442'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_duration'</span> =&gt; <span style="color:#FF0000;">'00:01:02'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fee'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'1.15'</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_number'</span>&nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'+11 (0)222 333 443'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_duration'</span> =&gt; <span style="color:#FF0000;">'00:01:03'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fee'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'1.15'</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_number'</span>&nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'+11 (0)222 333 444'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_duration'</span> =&gt; <span style="color:#FF0000;">'00:01:04'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fee'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'1.15'</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'connection'</span>, <span style="color:#0000FF;">$billConnections</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// create and retrieve document </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The resulting document contains the following table with the data from the assigned associate array (click to zoom):</p>
<p><a href="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/docviewer-complex-template_zoom.jpg"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/docviewer-complex-template_zoom-212x300.jpg" alt="docviewer-complex-template_zoom" title="docviewer-complex-template_zoom" width="212" height="300" class="aligncenter size-medium wp-image-416" /></a></p>
<p><a name="Generating-image-files-with-LiveDocx"></a></p>
<h3>Generating image files with LiveDocx</h3>
<p>In addition to the word processing file formats listed above that are supported by LiveDocx, you can also save the resulting documents as one or more image files. For this purpose, <em>Zend_Service_LiveDocx_MailMerge</em> offers the methods <em>getAllBitmaps()</em> and <em>getBitmaps()</em>:</p>
<div class="igBar"><span id="lphp-12"><a href="#" onclick="javascript:showCodeTxt('php-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-12">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// instantiate LiveDocx </span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// get all bitmaps </span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// (zoomFactor, format) </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$bitmaps</span> = <span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">getAllBitmaps</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">100</span>, <span style="color:#FF0000;">'png'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Similarly, it is possible to retrieve images for pages in a specific range:</p>
<div class="igBar"><span id="lphp-13"><a href="#" onclick="javascript:showCodeTxt('php-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-13">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// get just bitmaps in specified range </span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// (fromPage, toPage, zoomFactor, format) </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$bitmaps</span> = <span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">getBitmaps</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">2</span>, <span style="color:#CC66CC;color:#800000;">2</span>, <span style="color:#CC66CC;color:#800000;">100</span>, <span style="color:#FF0000;">'png'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Note that <em>zoomFactor</em> parameter. This is a per cent value, in the range of 10% to 400%. These methods are ideally suited to generating thumbnail images of the created document, for example, to display in the browser as a preview.</p>
<p>The actual image files can be written to disk by iterating through the <em>$bitmaps</em> array. There is one page of binary data per record in the array:</p>
<div class="igBar"><span id="lphp-14"><a href="#" onclick="javascript:showCodeTxt('php-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-14">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// write to disk </span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// (one page per record) </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$bitmaps</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$pageNumber</span> =&gt; <span style="color:#0000FF;">$bitmapData</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$filename</span> = <a href="http://www.php.net/sprintf"><span style="color:#000066;">sprintf</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'documentPage%d.png'</span>, <span style="color:#0000FF;">$pageNumber</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; file_put_contents<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$filename</span>, <span style="color:#0000FF;">$bitmapData</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/printf"><span style="color:#000066;">printf</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Written %d bytes to disk as %s.%s'</span>, <a href="http://www.php.net/filesize"><span style="color:#000066;">filesize</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$filename</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#0000FF;">$filename</span>, PHP_EOL<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><a name="Deploying-LiveDocx-in-your-own-applications"></a></p>
<h2>Deploying LiveDocx in your own applications</h2>
<p>The code, which constitutes the PHP 5 implementation of LiveDocx, shipped in the Zend Framework, is released under the <a href="http://is.gd/3RMhL">New BSD license</a> and thus may be deployed, modified and redistributed in most projects, according to that terms of the license. The actual LiveDocx SOAP server, however, is proprietary software. There are three ways in which the SOAP service can be deployed in your own applications.</p>
<ol>
<li style="padding-bottom: 0.8em;"> <strong>Free public server</strong><br />
For the vast majority of applications, developers choose this approach. The default LiveDocx server that is referenced in the Zend Framework components is the free public server. It may be used in your own applications completely free of charge. <a href="http://is.gd/3QlkN">Sign up</a> for a LiveDocx account.</li>
<li style="padding-bottom: 0.8em;"> <strong>Premium hosted server</strong><br />
In the case that your application generates several thousand documents per hour, you may consider paying a small monthly fee to have access to your own personal LiveDocx server. In association with leading hosting providers, you can rent such a premium hosted server.</li>
<li> <strong>Local licensed server</strong><br />
In the case that your application generates more than about ten thousand documents her hour, you may consider installing a LiveDocx server in your local network. Having direct access in a local gigabit network is by far the fastest way of deploying LiveDocx.</li>
</ol>
<p><a name="Learn-more"></a></p>
<h2>Learn more</h2>
<p style="margin-bottom: 0px;">This article has scratched the surface of what you can do with LiveDocx. If you would like to learn more about this new powerful document generation platform, please take a look at the following resources:</p>
<p><a name="LiveDocx-in-PHP-5"></a></p>
<h3 style="font-size: 1em;">LiveDocx in PHP 5</h3>
<ul>
<li><a href="http://is.gd/3YySX">phpLiveDocx blog</a>.</li>
<li><a href="http://is.gd/3YyTT">phpLiveDocx technical articles</a>.</li>
</ul>
</div>
<div><a name="LiveDocx-SOAP-service"></a></p>
<h3 style="font-size: 1em;">LiveDocx SOAP service</h3>
<ul>
<li><a href="http://is.gd/3YyV8">LiveDocx blog</a>.</li>
<li><a href="http://is.gd/3YyXM">LiveDocx API reference</a>.</li>
</ul>
<p>Please do not hesitate to <a href="http://is.gd/3Yz3L">contact the author</a> or <a href="http://is.gd/3Yz56">request technical support</a> in the support forum (free of charge) at any time.</p>
<p><a name="Footnotes"></a></p>
<h2>Footnotes</h2>
<p><a name="foot-01"></a><small>[1]</small><br />
<a href="http://is.gd/3SsCE">domPDF</a>, <a href="http://is.gd/3SsPF">HTML 2 (F)PDF</a>, <a href="http://is.gd/3SsS3">HTML_ToPDF</a>, <a href="http://is.gd/3SsUM">mPDF</a> etc.</p>
<p><a name="foot-02"></a><small>[2]</small> <a href="http://is.gd/3SsWJ">Zend_Pdf</a>, <a href="http://is.gd/3SsYi">PDFlib</a>, <a href="http://is.gd/3St08">FPDF</a>, <a href="http://is.gd/3St1W">Cpdf</a> etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/pdf-generation-with-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replication / Mirroring as Master-master with Subversion using svnsync</title>
		<link>http://www.gsdesign.ro/blog/replication-mirroring-as-master-master-with-subversion-using-svnsync/</link>
		<comments>http://www.gsdesign.ro/blog/replication-mirroring-as-master-master-with-subversion-using-svnsync/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 20:29:38 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[php advanced]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svk]]></category>
		<category><![CDATA[svnsync]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=398</guid>
		<description><![CDATA[For me it all started when my VPS had an error and all my SVN repos were lost. Plus even though i had purchased a backup system from the hosting company that was suppose to do a full server backup automatic and incrementally, i only had a backup from 20 days earlier because the system [...]]]></description>
			<content:encoded><![CDATA[<p>For me it all started when my VPS had an error and all my SVN repos were lost. Plus even though i had purchased a backup system from the hosting company that was suppose to do a full server backup automatic and incrementally, i only had a backup from 20 days earlier because the system failed at that point in time and didnt run since.</p>
<p>But enough with my problems, at that point i decided to make a copy of my repos from the remote server to my local machine.<br />
And i would commit into the local one and it should automaticly sync to the remote one. Plus it would need to do this both ways and in real time since i had some external people commiting in the remote server. Easier said then done i camed to find out.</p>
<h3>The reasons why</h3>
<p>Well for me there are 3 main reasons:<br />
1. as a backup system ( dont want to be put in the 20 days old backup situation again )<br />
2. for faster commits and updates<br />
3. independent of the internet connection ( it hasnt failed in quite a while, but just in case, or for the times its a bit slow )</p>
<h3>The alternatives</h3>
<p>It seems that this topic is a bit popular, and there are a few places on the internet where people are interested in this. You can check out <a href="http://stackoverflow.com/questions/148625/how-to-get-master-master-replication-with-subversion">this question on stackoverflow</a> for one.</p>
<p><strong>1. Git-SVN</strong><br />
This is one alternative that a lot of people have been recommended. The benefits they are you get the best out of both worlds, you can still use the Subversion in the main repo, but you get the power of GIT for your local copy.<br />
Although this sounds very cool, i am more of a GUI guy and really enjoy the subversion integration in my IDE ( <a href="http://www.gsdesign.ro/blog/netbeans-review/">Netbeans</a> ) so i would have to pass this options.</p>
<p><strong>2. SVK</strong></p>
<blockquote><p>
svk is a decentralized version control system built with the robust Subversion filesystem. It supports repository mirroring, disconnected operation, history-sensitive merging, and integrates with other version control systems, as well as popular visual merge tools.
</p></blockquote>
<p>At first i read <a href="http://lajavaloca.wordpress.com/2008/06/03/using-svk-to-synchronize-svn-repositories/">this article</a> about SVK and it seemed to be what i was looking for. But after playing with it for a while i saw that i would need to have a single repo where all my comits would go and that would be synced to several outside repos. But i was looking for a way to have the exact replica of what it is on the remote server so in the case of a failure i could restore them from my backup.</p>
<p>If you are still interested in this you can also read <a href="http://svk.bestpractical.com/view/UsingSVKAsARepositoryMirroringSystem">this</a> and <a href="http://developer.mindtouch.com/User:PeteE/Synchronizing_SVN_Repositories_With_Svk">this</a>.</p>
<p><strong>3. svnsync + webdav proxy</strong><br />
I knew about svnsync but it only supports read-only copies of your repo. But after reading a small comment on stackoverflow i started looking and find out you can have read-write copies using svnsync and webdav proxy.<br />
What is basicly happening is that your local copy handles the read operations and it forwards the commits to the main repo.</p>
<p>There are a few tricky parts on this solution, that involve the locks and updating of all the replicas of the main repo. This are done by a series of hooks in the main repo.<br />
If youre interested in this solution you can find information about implementing it in this articles:<br />
<a href="http://www.tty1.net/blog/2007-08-26-subversion-proxy_en.html">Subversion transparent proxy with svnsync + webdav proxy</a><br />
<a href="http://www.rvo-consulting.com/2008/02/21/subversion-diy-write-through-proxy/">subversion diy write through proxy</a><br />
<a href="http://www.slideshare.net/normanmaurer/apacheconeusvnreplication">Subversion on-the-fly replication</a></p>
<h3>conclusion</h3>
<p>Honestly i don't have one yet <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> , but i plant to try using svnsnyc and see how that goes.<br />
I hope you got a big picture of what your options are and now you can decide what suits you best.</p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/replication-mirroring-as-master-master-with-subversion-using-svnsync/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Optimizing Zend Routing</title>
		<link>http://www.gsdesign.ro/blog/optimizing-zend-routing/</link>
		<comments>http://www.gsdesign.ro/blog/optimizing-zend-routing/#comments</comments>
		<pubDate>Wed, 06 May 2009 20:47:05 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[php advanced]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[routing]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=379</guid>
		<description><![CDATA[After playing with zend framework for a while, and reading left and right, i came to the conclusion that i need to find a way to optimize the Routing in my application. If you havent notice by now, the routing in Zend takes quite a while, and it increases with the number of routes you [...]]]></description>
			<content:encoded><![CDATA[<p>After playing with zend framework for a while, and reading left and right, i came to the conclusion that i need to find a way to optimize the Routing in my application.<br />
If you havent notice by now, the routing in Zend takes quite a while, and it increases with the number of routes you have, and with the number of routes that use Regular Expressions.</p>
<p>The easiest way to optimise it would be to reduce the number of rules that use regular expressions and the number of rules all together. But for SEO reasons that is not always possible.</p>
<p><span id="more-379"></span></p>
<h3>Current Situation</h3>
<p><strong>Info:</strong> I have my routes wrote in INI files.</p>
<p>In my application i have started to have quite a few rules, so i have thought i would break them into separate files and include only the rules that i need for the section i am in. While that sounds like a plan, its not that simple ... i still need to have all the routes on page generation, because i have links point to a different section, so i need all the routes.</p>
<h3>Solution</h3>
<p>The solution that i came with is to write a plugin that will include some routes routeStartup and the rest on routeShutdown.</p>
<h4>Step 1 - Routes files</h4>
<p>To make this work, you need to have a directory where to store the routes ini files.<br />
I have placed it in my application config dir. I recommend having a default one that is always included. Here is an example of a routing file:</p>
<div class="igBar"><span id="lphp-18"><a href="#" onclick="javascript:showCodeTxt('php-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-18">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">lang_default.type&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span style="color:#FF0000;">"GSD_Controller_Router_Route_Language"</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">lang_default.route&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color:#FF0000;">":language/:controller/:action/*"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">lang_default.defaults.module&nbsp; &nbsp; &nbsp;= <span style="color:#000000; font-weight:bold;">default</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">lang_default.defaults.controller = index</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">lang_default.defaults.action&nbsp; &nbsp; &nbsp;= index</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">lang_default.defaults.language&nbsp; &nbsp;= ro</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">lang_default.reqs.language&nbsp; &nbsp; &nbsp; &nbsp;= <span style="color:#FF0000;">"(ro|en)"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>Step 2 - Bootstraping the plugin</h4>
<p>I have a simple bootstrap class that i wrote about, and i overwrote the setupRoutes method, but you can port this to your own setup with ease if you have used plugins before.</p>
<div class="igBar"><span id="lphp-19"><a href="#" onclick="javascript:showCodeTxt('php-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-19">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public <a href="http://www.php.net/static"><span style="color:#000066;">static</span></a> <span style="color:#000000; font-weight:bold;">function</span> setupRoutes<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$plugin</span> = <span style="color:#000000; font-weight:bold;">new</span> GSD_Controller_Plugin_Router<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$plugin</span>-&gt;<span style="color:#006600;">setDir</span><span style="color:#006600; font-weight:bold;">&#40;</span>self::<span style="color:#0000FF;">$root</span> . <span style="color:#FF0000;">'/application/config/routes/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$plugin</span>-&gt;<span style="color:#006600;">setDefault</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'default.ini'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; self::<span style="color:#0000FF;">$frontController</span>-&gt;<span style="color:#006600;">registerPlugin</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$plugin</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>In the code you see that i add a default file that is included everytime. just because some routes are 90% used.</p>
<h4>Step 3 - The actual plugin</h4>
<p>Here it is, full and uncensored :</p>
<div class="igBar"><span id="lphp-20"><a href="#" onclick="javascript:showCodeTxt('php-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-20">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * Front Controller Plugin</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> *</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @uses&nbsp; &nbsp; &nbsp; &nbsp;Zend_Controller_Plugin_Abstract</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @category&nbsp; &nbsp;GSD</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @package&nbsp; &nbsp; GSD_Controller</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @subpackage Plugins</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> GSD_Controller_Plugin_Router extends Zend_Controller_Plugin_Abstract</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#0000FF;">$_dir</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#0000FF;">$_default</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#0000FF;">$_request</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#0000FF;">$_initialConfig</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#0000FF;">$_remainingConfig</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> routeStartup<span style="color:#006600; font-weight:bold;">&#40;</span>Zend_Controller_Request_Abstract <span style="color:#0000FF;">$request</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// define some routes (URLs)</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$router</span> = Zend_Controller_Front::<span style="color:#006600;">getInstance</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">getRouter</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">setRequest</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$request</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$config</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">getInitial</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$router</span>-&gt;<span style="color:#006600;">addConfig</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$config</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> routeShutdown<span style="color:#006600; font-weight:bold;">&#40;</span>Zend_Controller_Request_Abstract <span style="color:#0000FF;">$request</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$router</span> = Zend_Controller_Front::<span style="color:#006600;">getInstance</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">getRouter</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$config</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">getRemaining</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$router</span>-&gt;<span style="color:#006600;">addConfig</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$config</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> setDir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$dir</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_dir = <span style="color:#0000FF;">$dir</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> setDefault<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$default</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/is_array"><span style="color:#000066;">is_array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$default</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_default = <a href="http://www.php.net/array_merge"><span style="color:#000066;">array_merge</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;_default, <span style="color:#0000FF;">$default</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_default<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$default</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> setRequest<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$request</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_request = <span style="color:#0000FF;">$request</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> getInitial<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;_initialConfig == <span style="color:#000000; font-weight:bold;">null</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">parseIniDir</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;_initialConfig;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> getRemaining<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;_remainingConfig == <span style="color:#000000; font-weight:bold;">null</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">parseIniDir</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;_remainingConfig;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#000000; font-weight:bold;">function</span> parseIniDir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$files</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">getFiles</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_default;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_default<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">determineInitial</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_initialConfig = <span style="color:#000000; font-weight:bold;">new</span> Zend_Config<span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_remainingConfig = <span style="color:#000000; font-weight:bold;">new</span> Zend_Config<span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/is_array"><span style="color:#000066;">is_array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$files</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$files</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$file</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$routerFile</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">compilePath</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$file</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/in_array"><span style="color:#000066;">in_array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$file</span>, <span style="color:#0000FF;">$this</span>-&gt;_default<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_initialConfig-&gt;<span style="color:#006600;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">new</span> Zend_Config_Ini<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$routerFile</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_remainingConfig-&gt;<span style="color:#006600;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">new</span> Zend_Config_Ini<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$routerFile</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#000000; font-weight:bold;">function</span> getFiles<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color:#000066;">is_dir</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;_dir<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$dir</span> = <span style="color:#000000; font-weight:bold;">new</span> DirectoryIterator<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;_dir<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$files</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$dir</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$fileInfo</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<span style="color:#0000FF;">$fileInfo</span>-&gt;<span style="color:#006600;">isDot</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#0000FF;">$fileInfo</span>-&gt;<span style="color:#006600;">isFile</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$files</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$fileInfo</span>-&gt;__toString<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$files</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#000000; font-weight:bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#000000; font-weight:bold;">function</span> getOtherRoutes<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$routes</span>-&gt;<span style="color:#006600;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">new</span> Zend_Config_Ini<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$routerFile</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#000000; font-weight:bold;">function</span> determineInitial<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;_request<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$uri</span> = <span style="color:#0000FF;">$this</span>-&gt;_request-&gt;<span style="color:#006600;">getRequestUri</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$base</span> = <span style="color:#0000FF;">$this</span>-&gt;_request-&gt;<span style="color:#006600;">getBasePath</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">'/'</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$request</span> = <a href="http://www.php.net/str_replace"><span style="color:#000066;">str_replace</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$base</span>, <span style="color:#FF0000;">''</span>, <span style="color:#0000FF;">$uri</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$requestParts</span> = <a href="http://www.php.net/explode"><span style="color:#000066;">explode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/'</span>, <span style="color:#0000FF;">$request</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$lang</span> = <span style="color:#0000FF;">$requestParts</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$section</span> = <span style="color:#0000FF;">$requestParts</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color:#000066;">empty</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$section</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#0000FF;">$section</span> == <span style="color:#FF0000;">'user'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#FF0000;">'user.ini'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#000000; font-weight:bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; protected <span style="color:#000000; font-weight:bold;">function</span> compilePath<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$file</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;_dir . <span style="color:#FF0000;">'/'</span> . <span style="color:#0000FF;">$file</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>In there you can see that the plugin reads all the ini files and at first only includes the ones from the default route you specify in bootstrap, and the one determined in the method <strong>determineInitial</strong>. I left there a small part of my method to give you an example of how i detect wich file to include based on the URL.</p>
<p>After routing, the routeShutdown is fired and all the rest of the routes are added into the router.</p>
<h3>Final words</h3>
<p>I think that cutting down on the number of routes at routing really speeds up your application, especially if its one with high trafic. All those regular expressions really make a mark in your server load.<br />
PS: Load test your application, i had a wake up call about this a few weeks ago.</p>
<p>Unfortunately i am really short on time so i didn't do some comparations to see what improvements you get. If you have the time and do it out of curiosity i would appreciate if you would post a comment with your results ( i take critics well ... at least i like to think so <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' />  )</p>
<p>Awaiting curiously your comments.<br />
Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/optimizing-zend-routing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL Database versioning strategy</title>
		<link>http://www.gsdesign.ro/blog/mysql-database-versioning-strategy/</link>
		<comments>http://www.gsdesign.ro/blog/mysql-database-versioning-strategy/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 22:23:11 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Programing]]></category>
		<category><![CDATA[project management]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[version-control]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=374</guid>
		<description><![CDATA[IF you just got into versioning your code then you are probably really happy with your acomplishment. But do you have your database versioned ? This is the questioned asked in this here by Jeff Atwood and also asked by a lot of users on stackoverflow. After reading a lot on this topic i decided [...]]]></description>
			<content:encoded><![CDATA[<p>IF you just got into versioning your code then you are probably really happy with your acomplishment.<br />
But do you have your database versioned ? This is the questioned asked in this <a href="http://www.codinghorror.com/blog/archives/001050.html">here</a> by Jeff Atwood and also asked by a lot of users on <a href="http://stackoverflow.com/search?q=database+versioning">stackoverflow</a>.</p>
<p>After reading a lot on this topic i decided on a strategy on how to keep my database under version control.<br />
As a warning it isn't the most easy strategy and it really takes some discipline from all the developers.<br />
<span id="more-374"></span></p>
<h3>The strategy</h3>
<p>The main ideea is to have a folder with this structure in your project base path<br />
/__DB<br />
----/changesets<br />
--------/1123<br />
----/data<br />
----/tables</p>
<p>Now who the whole thing works is that you have 3 folders:<br />
<strong>Tables</strong><br />
Holds the table create query. I recommend using the naming "table_name.sql".</p>
<p><strong>Data</strong><br />
Holds the table insert data query. I recommend using the same naming "table_name.sql".<br />
<em>Note: Not all tables need a data file, you would only add the ones that need this initial data on project install.</em></p>
<p><strong>Changesets</strong><br />
This is the main folder you will work with.<br />
This holds the change sets made to the initial structure.  This holds actually folders with changesets.<br />
For example i added a folder 1123 wich will contain the modifications made in revision 1123 ( the number is from your code source control ) and may contain one or more sql files.</p>
<p>I like to add them grouped into tables with the naming xx_tablename.sql - the xx is a number that tells the order they need to be runned, since sometimes you need the modification runned in a certain order.</p>
<p><strong>Note:</strong><br />
When you modify a table, you also add those modifications to table and data files ... since those are the file s that will be used to do a fresh install.</p>
<p>This is the main ideea.</p>
<h3>Improvements you can do</h3>
<p>This is the basic ideea of how i version my database structure. I am sure this is not the perfect way of versioning your database but this is the own that works for me.<br />
If you want you can modify the structure and add 2 subfolder for each changeset : up &#038; down ... and this way you could have a way of upgrading and downgrading your database.</p>
<h3>Automation</h3>
<p>Since running those queries manually isn't so enjoyable i wrote a small class to automate the process a little.<br />
The class is posted on <a href="http://solomongaby.users.phpclasses.org/">phpclasses.org</a> and is available for download <a href="http://solomongaby.users.phpclasses.org/browse/package/5277.html">here</a>.<br />
<strong>Warning:</strong> The class is still in beta, so be careful when first using it. and always backup <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>The main idea is that the class saves the last changeset runned in mysql and always checks if there are any new change sets. When you see any commits with database change sets you access /__DB/index.php and the class does the upgrade for you.</p>
<p>I await your comments<br />
Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/mysql-database-versioning-strategy/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Current Zend View Path Helper</title>
		<link>http://www.gsdesign.ro/blog/current-zend-view-path-helper/</link>
		<comments>http://www.gsdesign.ro/blog/current-zend-view-path-helper/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 11:33:04 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[zend framework]]></category>
		<category><![CDATA[zend view]]></category>
		<category><![CDATA[zend view helpers]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=372</guid>
		<description><![CDATA[Many times when i use Zend_View i have to include view files that are in the same directory, and i am forced to type in the same path over again. Which is and isnt so much work, but during development i often have to place those files in a different folder or rename one of [...]]]></description>
			<content:encoded><![CDATA[<p>Many times when i use Zend_View i have to include view files that are in the same directory, and i am forced to type in the same path over again. Which is and isnt so much work, but during development i often have to place those files in a different folder or rename one of the folders. In witch case i would be forced to change those path i gave in the view file.</p>
<p>This is why i wrote a small View_Helper to return the current view folder.<br />
Unfortunately this will not work on a <a href="http://www.gsdesign.ro/blog/tag/zend-framework/">Zend framework</a> out of the box, it will require some modifications to Zend_View_Abstract.</p>
<p>I have placed the code on <a href="http://www.zfsnippets.com/">ZF Snippets website</a>, a project that i really like, and i would ask you to place any comments and suggestions for this helper on that webpage.</p>
<p>[<a href="http://www.zfsnippets.com/snippets/view/id/51">ZF Snippets code</a>]</p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/current-zend-view-path-helper/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Cron jobs in Zend Framework</title>
		<link>http://www.gsdesign.ro/blog/cron-jobs-in-zend-framework/</link>
		<comments>http://www.gsdesign.ro/blog/cron-jobs-in-zend-framework/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 22:25:31 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[zend framework]]></category>
		<category><![CDATA[con jobs]]></category>
		<category><![CDATA[zend bootstrap]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=369</guid>
		<description><![CDATA[Recently i had to implement a cronjob for a website that was build with zend framework, and to be honest i haven't done this before. I did some googling and as a lot of times with zend framework there arent to many resources about this topic. I did find some topics on stackoverflow.com about it [...]]]></description>
			<content:encoded><![CDATA[<p>Recently i had to implement a cronjob for a website that was build with zend framework, and to be honest i haven't done this before. I did some googling and as a lot of times with zend framework there arent to many resources about this topic.</p>
<p>I did find some topics on <a href="http://stackoverflow.com/search?q=cron+zend+framework">stackoverflow.com</a> about it ( found out about zend cli proposal wich sounds interesting ) but not really an answer. So i decided to go ahead and try a solution on my own.<span id="more-369"></span></p>
<p>I wrote a while ago about my implementation of the <a href="http://www.gsdesign.ro/blog/zend-framework-bootstrap-file-class/">bootstrap file</a> and although that doesn't look to impressive that helped me to build an easy init for the backup files.</p>
<p>So first of all i must tell you that i added a folder in my root folder ( same level with library ) called crons.<br />
In it i added a file called init.php in witch i "start" the zend machine. I only call some methods from the bootstrap class since you don't really need all the zend machine.</p>
<div class="igBar"><span id="lphp-22"><a href="#" onclick="javascript:showCodeTxt('php-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-22">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$time</span> = <a href="http://www.php.net/microtime"><span style="color:#000066;">microtime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$memory</span> = <a href="http://www.php.net/memory_get_usage"><span style="color:#000066;">memory_get_usage</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">require</span> <span style="color:#FF0000;">'../application/bootstrap.php'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Bootstrap::<span style="color:#006600;">setupEnvironment</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Bootstrap::<span style="color:#006600;">setupRegistry</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Bootstrap::<span style="color:#006600;">setupConfiguration</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Bootstrap::<span style="color:#006600;">setupDatabase</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Bootstrap::<span style="color:#006600;">setupTranslation</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/register_shutdown_function"><span style="color:#000066;">register_shutdown_function</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'__shutdown'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> __shutdown<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/global"><span style="color:#000066;">global</span></a> <span style="color:#0000FF;">$time</span>, <span style="color:#0000FF;">$memory</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$endTime</span> = <a href="http://www.php.net/microtime"><span style="color:#000066;">microtime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$endMemory</span> = <a href="http://www.php.net/memory_get_usage"><span style="color:#000066;">memory_get_usage</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">Time ['</span> . <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$endTime</span> - <span style="color:#0000FF;">$time</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">'] Memory ['</span> . <a href="http://www.php.net/number_format"><span style="color:#000066;">number_format</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$endMemory</span> - <span style="color:#0000FF;">$memory</span><span style="color:#006600; font-weight:bold;">&#41;</span> / <span style="color:#CC66CC;color:#800000;">1024</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">'Kb]'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>As you see i added some extra lines to do some little debugging of the cronjobs.</p>
<p>To add a cronjob you place a file in the crons folder you just created and you just include the init file and then you are on your way to code the cron functionality.</p>
<p>Cheers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/cron-jobs-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

