<?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"
	>

<channel>
	<title>Developer Tutorials' Webmaster Blog &#187; php tips</title>
	<atom:link href="http://www.developertutorials.com/blog/tag/php-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.developertutorials.com/blog</link>
	<description>Keeping webmasters up-to-date on technology.</description>
	<pubDate>Fri, 04 Jul 2008 04:00:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>PHP-friendly web services/APIs for quick mashups</title>
		<link>http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/</link>
		<comments>http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 05:57:39 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[mashups]]></category>

		<category><![CDATA[php tips]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/</guid>
		<description><![CDATA[If you want to build a useful app quickly, you can&#8217;t go past a mashup. Take data from someone else&#8217;s service, come up with a useful way to mix it up and present it to your users in an innovative manner. Even better, as my recent PHP Site Search tutorial showed, you can build a [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to build a useful app quickly, you can&#8217;t go past a mashup. Take data from someone else&#8217;s service, come up with a useful way to mix it up and present it to your users in an innovative manner. Even better, as my recent PHP Site Search tutorial showed, you can build a mashup in just a few lines of code. But how do you find useful web services/APIs, and how do you process the data they provide?</p>
<h3>Finding APIs/web services</h3>
<p>Finding APIs and web services is really quite easy. If you regularly use a web application - for example, I&#8217;ve often used Twitter - check if the application provides an API (Twitter has quite a comprehensive one). Next, if you&#8217;re looking for data on a particular topic, try searching for it. A quick search for &#8220;map api&#8221; returns all kinds of useful results. Finally, if you just want to take a look at the internet&#8217;s available APIs, head to <a href="http://www.programmableweb.com/" target="_blank" rel="external nofollow">Programmable Web</a>; they have by far the most comprehensive database available, and it&#8217;s fully searchable.</p>
<h3>Handling API output</h3>
<p>The easiest way is a really PHP-friendly APIs that provides serialized PHP. You can just fetch the URL with <a href="http://developertutorials.com/php-manual/function.file-get-contents.html" target="_blank">file_get_contents()</a>, and run the output through <a href="http://developertutorials.com/php-manual/function.unserialize.html" target="_blank">unserialize()</a>; in two lines of code, you have your data ready to work with.</p>
<p>However, most APIs won&#8217;t offer serialized PHP output; some might offer JSON, or JavaScript Object Notation, which is somewhat like PHP&#8217;s serialized data (although JSON is integrated in the JavaScript language). Others offer XML gateways, while some even provide SOAP, a (rather complicated) means for computers to talk to each other natively. You really have three options:</p>
<p>1. Interpret the output of the API or web service with a PHP-based parser, such as an XML parser (which you can easily find on phpclasses.org) or a SOAP client (try nusoap).<br />
2. Use PHP sample code provided by the API/web service owner - e.g. <a href="http://code.google.com/apis/checkout/samples/Google_Checkout_Sample_Code_PHP.html" target="_blank">this Google Checkout PHP sample</a>. Some even <a href="http://www.maxmind.com/app/php" target="_blank" rel="external nofollow">provide PECl extensions</a>.<br />
3. Use a third-party library to access the service. For example, people have written PHP classes that allow you to interact with the Flickr API. <a href="http://www.phpclasses.org/browse/class/33.html" target="_blank">PHP Classes.org has hundreds of these</a>, and others are just a web search away.</p>
<h3>Some PHP-friendly APIs</h3>
<p>Of course, if you just want to get started right now and quickly add some functionality to your application, try these:</p>
<ul>
<li><a href="http://recaptcha.net/plugins/php/">reCAPTCHA PHP library</a>: add effective CAPTCHA to your application in pure PHP</a> with reCAPTCHA</li>
<li><a href="http://developer.yahoo.com/php/">Yahoo PHP developer center</a>: Yahoo! provides some very useful search APIs that you can probably use. Also see my <a href="http://developertutorials.com/tutorials/php/php-site-search-made-easy-8-03-30/page1.html" target="_blank">PHP Site Search Made Easy</a> tutorial making use of these APIs.</li>
<li><a href="http://www.flickr.com/services/api/response.php.html" target="_blank">Flickr Services with PHP Response</a></li>
</ul>
<p>Have a look through these APIs and you could be building a mashup quickly in no time.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d104').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d104" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/&amp;title=PHP-friendly+web+services%2FAPIs+for+quick+mashups" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/&amp;title=PHP-friendly+web+services%2FAPIs+for+quick+mashups" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/&amp;title=PHP-friendly+web+services%2FAPIs+for+quick+mashups" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/&amp;title=PHP-friendly+web+services%2FAPIs+for+quick+mashups" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d104').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The ultimate PHP web development environment, part 2</title>
		<link>http://www.developertutorials.com/blog/php/the-ultimate-php-web-development-environment-part-2-98/</link>
		<comments>http://www.developertutorials.com/blog/php/the-ultimate-php-web-development-environment-part-2-98/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 03:37:49 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[php tips]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/the-ultimate-php-web-development-environment-part-2-98/</guid>
		<description><![CDATA[In part 1 of this series, I looked at the web browsers and (Windows) IDEs. Today I&#8217;m going to look at a local development server and its PHP configuration, as well as some of the IDEs/editors available for Linux, especially the cross-platform options.

Local development server
Now, when developing your applications, you can&#8217;t simply keep uploading to [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.developertutorials.com/blog/php/ultimate-php-web-development-environment-software-part-1-78/" target="_blank">part 1 of this series</a>, I looked at the web browsers and (Windows) IDEs. Today I&#8217;m going to look at a local development server and its PHP configuration, as well as some of the IDEs/editors available for Linux, especially the cross-platform options.</p>
<p><span id="more-98"></span></p>
<h3>Local development server</h3>
<p>Now, when developing your applications, you can&#8217;t simply keep uploading to your web host&#8217;s server for testing. Having a local development server with PHP and MySQL is invaluable; whether it&#8217;s on your local machine or a seperate box (I use an old P4). Configuring all the applications under Windows can be a real pain, but luckily there are some all-in-one installers that make it easy:</p>
<p><strong>WampServer</strong><br />
<a href="http://www.wampserver.com/en/index.php" target="_blank">WampServer</a> is by far the best option for Windows; it comes with Apache, PHP, MySQL and phpMyAdmin all ready and configured. Best of all, you can manage multiple versions of Apache, PHP and MySQL, and it supports easy switching out of the box, to closely replicate your production environment.</p>
<p><strong>XAMPP Lite</strong><br />
While WampServer is certainly very powerful and effective, I personally use <a href="http://www.apachefriends.org/en/xampp-windows.html#646" target="_blank">XAMPP Lite</a>, as it offers the usual Apache/PHP/MySQL, phpMyAdmin, and best of all, it&#8217;s entirely portable - I can pop it on a USB stick and take it to another machine if needed. The XAMPP control panel is also simple and effective.</p>
<p><strong>DIY</strong><br />
Thanks to the wide availability of online tutorials in this area, setting up your own Apache/PHP/MySQL server isn&#8217;t as hard as it used to be. If you really want to roll your own WAMP, take a look at <a href="http://www.php-mysql-tutorial.com/install-apache-php-mysql.php" target="_blank">one</a> <a href="http://www.webcheatsheet.com/php/install_and_configure.php" rel="external nofollow" target="_blank">of</a> <a href="http://www.apachemysqlphp.com/" target="_blank">these</a> tutorials.</p>
<p>If you&#8217;re on a Linux box, you can probably just install Apache, PHP and MySQL from your package manager. If you&#8217;re running Ubuntu, <a href="http://mysql-apache-php.com/lamp_server.htm" target="_blank" rel="external nofollow">try this guide</a>.</p>
<h3>PHP Configuration</h3>
<p>Seeing as you won&#8217;t be running a production web server from your local development setup, you might as well configure it to best suit development. With a few of these simple changes, you can tweak your PHP setup to best suit you. Load up your PHP.ini file and have a read through these suggestions.</p>
<p><strong><em>short_open_tag = On</em></strong><br />
If you&#8217;re working with view files written for a PHP framework, or just generally open source PHP applications, chances are you&#8217;ll need to enable this directive. When it comes to PHP tags, &lt;?php is the standard, and &lt;? is widely accepted but not always available. Save yourself a lot of hassle by enabling this directive.</p>
<p><strong><em>implicit_flush = On</em></strong><br />
When you make a call to echo() or print(), or put a HTML block between PHP code blocks, PHP doesn&#8217;t always output it automatically. Setting implicit_flush to On forces it to do so. This is a great help for debugging; the moment something happens, you&#8217;ll see it in your browser/console window. (I believe PHP-CLI enables this by default.) However, <em>by no means enable this on a production server</em>, as it has serious performance implications.</p>
<p><strong><em>docref_root = &#8220;/phpmanual/&#8221;</em> and <em>docref_ext = .html</em></strong><br />
Do yourself a favour and <a href="http://www.php.net/docs.php" target="_blank">grab a copy of the PHP manual</a>, pop it on your local development server and point docref_root to it. Enable docref_ext as .html as well; whenever you see a PHP error, it&#8217;ll link to your readily-accessible local copy of the manual. An invaluable debugging tool.</p>
<p><strong><em>memory_limit</em></strong><br />
Depending on how you want to manage your resource usage on your local machine, set memory_limit to either 16M or some reasonably high amount (a quarter of RAM is appropriate; mine is set to 128M on a 512mb RAM box). If you have fairly resource intensive scripts, setting memory_limit to a high value should help avoid problems later on; if you&#8217;re on a constrained shared host and need to get used to not being able to use a lot of memory, set it fairly low - 16M or maybe 32M at the most. Remember that you can usually override this within your scripts using ini_set(&#8217;memory_limit&#8217;, &#8216;xxxM&#8217;);</p>
<h3>Linux IDEs/editors</h3>
<p>When it comes to php editors on Linux, there aren&#8217;t too many real Linux options. Luckily, however, some of the best cross platform editors work far better on Linux than on Windows (quite possibly as a result of Linux OSes being typically more efficient than Windows on the same hardware). Here are some of the best options.</p>
<h4>Eclipse</h4>
<p>Eclipse is pretty much the gold standard for IDEs. It&#8217;s entirely open source and heavily customisable, so much so that some professional IDEs are built on top of Eclipse, as we&#8217;ll see in a moment. Eclipse was built with Java in mind, but thanks to its powerful plugin system, Zend provides the <a href="http://www.zend.com/en/community/pdt" target="_blank">PHP Development Tools (PDT) for Eclipse</a>, which can transform your Eclipse IDE into a fully-fledged PHP development environment.</p>
<h4>Zend Studio for Eclipse</h4>
<p>Well, bring on the Eclipse derivatives. Next up is <a href="http://www.zend.com/en/products/studio/" target="_blank">Zend Studio for Eclipse</a>, the successor to the old Zend Studio (which was actually rather powerful, albeit terribly underperforming). With ZSE, the IDE is almost managable for Windows, and certainly an option for developers on Linux boxes. Zend advertises it as the most powerful IDE for PHP, and they&#8217;re probably right; the feature set is more or less unmatched from any other general cross-platform PHP IDE, although interestingly PhpED on Windows does come close. To identify the differences between ZSE and just PDT on Eclipse, Zend <a href="http://www.zend.com/en/products/studio/compare" target="_blank">provides a comparison table</a>.</p>
<h4>Aptana</h4>
<p><a href="http://www.aptana.com/php/" target="_blank">Aptana PHP Development Environment</a> is yet another Eclipse derivative; the Aptana-provided PHP plugin has one of the best editing systems for PHP, and is very helpful when bashing out code and identifying syntax errors. Interestingly, it&#8217;s a general plugin for Aptana&#8217;s derivative of Eclipse, and you can also install their RadRails plugin alongside to quickly switch between PHP and RoR. If you don&#8217;t want to download Aptana&#8217;s editor and already have Eclipse, you can install Aptana itself as a plugin on top of Eclipse.</p>
<h4>General editors</h4>
<p>Of course, for quick hacks you can&#8217;t go past a simple text editor. I usually work with Gnome, so I always keep gedit handy, and gphpedit is useful; for KDE, there&#8217;s Quanta and a few alternatives. You don&#8217;t really need autocomplete and other code intelligence in your spare editor; syntax highlighting will help you put together hacks quickly and effectively.</p>
<h3>That&#8217;s all, folks!</h3>
<p>And that&#8217;s all for part two of our series on the ultimate php web development environment. In part 3, we&#8217;ll take a look at setting up a linux server to help with your PHP web development, from the usual LAMP to samba shares, a local SVN server to webmin for web-based server administration. If you liked this part of the series, please <a href="http://www.developertutorials.com/blog/php/feed">subscribe to our PHP RSS feed</a> to keep up to date on our latest PHP articles.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d98').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d98" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/the-ultimate-php-web-development-environment-part-2-98/&amp;title=The+ultimate+PHP+web+development+environment%2C+part+2" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/the-ultimate-php-web-development-environment-part-2-98/&amp;title=The+ultimate+PHP+web+development+environment%2C+part+2" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/the-ultimate-php-web-development-environment-part-2-98/&amp;title=The+ultimate+PHP+web+development+environment%2C+part+2" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/the-ultimate-php-web-development-environment-part-2-98/&amp;title=The+ultimate+PHP+web+development+environment%2C+part+2" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d98').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/the-ultimate-php-web-development-environment-part-2-98/feed/</wfw:commentRss>
		</item>
		<item>
		<title>5 PEAR gems: free php scripts that will help you code quicker</title>
		<link>http://www.developertutorials.com/blog/php/free-open-source-pear-package-gems-90/</link>
		<comments>http://www.developertutorials.com/blog/php/free-open-source-pear-package-gems-90/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 09:30:01 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Akismet]]></category>

		<category><![CDATA[PEAR]]></category>

		<category><![CDATA[php tips]]></category>

		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/free-open-source-pear-package-gems-90/</guid>
		<description><![CDATA[PEAR, the PHP Extension and Application Repository, contains hundreds of freely available packages that can be reused in your application. Packages usually come with various functionality within one or more classes, and the PEAR coding standards make sure packages follow the same general style for ease of implementation. Best of all; they&#8217;re all entirely open [...]]]></description>
			<content:encoded><![CDATA[<p>PEAR, the PHP Extension and Application Repository, contains hundreds of freely available packages that can be reused in your application. Packages usually come with various functionality within one or more classes, and the PEAR coding standards make sure packages follow the same general style for ease of implementation. Best of all; they&#8217;re all entirely open source, from MIT to GPL.</p>
<p>However, many of these packages are bloated, slow and full of specialised features that you may never want to use. Sifting through the repository is also a challenge; a basic category system is in place, but it&#8217;s hard to tell what you want when you don&#8217;t know what&#8217;s available. Here are some gems from the PEAR repository that you could really find useful.<br />
<span id="more-90"></span><br />
<strong>1. <a href="http://pear.php.net/package/Services_Akismet" target="_blank">Services_Akismet: Deal with spam once and for all</a></strong><br />
When it comes to dealing with comment spam, you can&#8217;t go past Akismet. It powers just about every Wordpress blog out there, including this one; it also has an API web service that allow it to be used in any other web application, and Services_Akismet takes advantage of this. Best of all, it&#8217;s free for personal or commercial use.</p>
<p><strong>2. <a href="http://pear.php.net/package/HTTP_Request/" target="_blank">HTTP_Request: Perform complex HTTP requests</a></strong><br />
Sure, there are many web services to hook into and web pages to download, but how do you access them all? Some times you need to go a little beyond basic file_get_contents; make HTTP requests with sessions attached, upload files, do some basic authentication, maybe even work with a proxy. HTTP_Request will help you do all this and more in a matter of a few lines of code.</p>
<p><strong>3. <a href="http://pear.php.net/package/Archive_Tar/" target="_blank">Archive_Tar</a></strong><br />
When maintaining a big web application, you&#8217;ll often find your server filling up with cache files, archives and data dumps. Storing these effectively is very important to maintaining the performance of your server; if you don&#8217;t access them frequently, the best way to achieve this is with Archive_Tar. Similar to creating a .tar tarball and compressing it with GZip on your machine, Archive_Tar will allow your web server to compress large files quickly and effectively.</p>
<p><strong>4. <a href="http://pear.php.net/package/Spreadsheet_Excel_Writer" target="_blank">Spreadsheet_Excel_Writer</a></strong><br />
When creating MS Office files programmaticaly, you often have to rely on having a Windows server with the actual Office products installed to generate your files. However, COM isn&#8217;t the best approach if performance is a concern, and more often than not you&#8217;ll be deploying on a Windows server. If you need to generate Excel files, no matter what platform you&#8217;re working with, Spreadsheet_Excel_Writer is your best bet for pure PHP.</p>
<p><strong>5. <a href="http://pear.php.net/package/XML_Parser/" target="_blank">XML_Parser</a></strong><br />
XML is becoming more and more prominent in web applications. From configuration files to meta information and even page data. XML_Parser provides a consistent, reliable, effective way to parse XML files, and is reasonably fast as well.</p>
<p>Have a look through these PEAR packages; remember you can easily install them just by running `pear install PACKAGE_NAME` at a command line/terminal. If this isn&#8217;t an option, you can still download them and include them as usual (although you may need to slightly rewrite file paths within the PEAR packages, as they include each other).</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d90').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d90" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/free-open-source-pear-package-gems-90/&amp;title=5+PEAR+gems%3A+free+php+scripts+that+will+help+you+code+quicker" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/free-open-source-pear-package-gems-90/&amp;title=5+PEAR+gems%3A+free+php+scripts+that+will+help+you+code+quicker" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/free-open-source-pear-package-gems-90/&amp;title=5+PEAR+gems%3A+free+php+scripts+that+will+help+you+code+quicker" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/free-open-source-pear-package-gems-90/&amp;title=5+PEAR+gems%3A+free+php+scripts+that+will+help+you+code+quicker" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d90').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/free-open-source-pear-package-gems-90/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Script execution time and maximum workaround</title>
		<link>http://www.developertutorials.com/blog/php/php-measure-max-execution-time-script-execution-time-83/</link>
		<comments>http://www.developertutorials.com/blog/php/php-measure-max-execution-time-script-execution-time-83/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 13:39:05 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[php performance]]></category>

		<category><![CDATA[php tips]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/php-measure-max-execution-time-script-execution-time-83/</guid>
		<description><![CDATA[Ever wondered how long your PHP scripts were taking to execute? Or maybe you&#8217;ve broken the maximum execution time limit on your server, as defined in your php.ini&#8217;s max_execution_time directive. Well, dealing with PHP script execution time is actually quite easy. In this mini tutorial, I&#8217;ll show you how to measure your PHP script execution [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wondered how long your PHP scripts were taking to execute? Or maybe you&#8217;ve broken the maximum execution time limit on your server, as defined in your php.ini&#8217;s max_execution_time directive. Well, dealing with PHP script execution time is actually quite easy. In this mini tutorial, I&#8217;ll show you how to measure your PHP script execution time, include monitoring at different stages of the process, and work around your max execution time limit.<br />
<span id="more-83"></span></p>
<h3>Measure script execution time</h3>
<p>This is the easiest part. PHP&#8217;s microtime() function will give you the current timestamp in microseconds (you need that level of precision for script execution time). However, microtime() will give you a value like 0.13554500 978913621, when what you really want is 978913621.13554500 (the 0 taken off the decimal section and added on to the integer). We can take care of this easily with a function we&#8217;ll call microtime_float().</p>
<p>So, to implement script execution time, we just take this value at the start of the script and at (or near) the end, then subtract them. First, at the very start of your page&#8217;s code, add this function:</p>
<pre>function microtime_float()
{
    list($utime, $time) = explode(" ", microtime());
    return ((float)$utime + (float)$time);
}

$script_start = microtime_float();</pre>
<p>Then at the end, add this:</p>
<pre>
$script_end = microtime_float();
echo "Script executed in ".bcsub($script_end, $script_start, 4)." seconds.";
</pre>
<h3>Measure script execution time in stages</h3>
<p>We can use milestones in a script to track how certain sections of code are performing. The best way to achieve this is a simple function with some static variable inside. However, needs can quickly get complicated, so I built a simple static class to handle everything. Include this class in your application:</p>
<pre>&lt;?php
class ScriptTimer {
  static $milestones;
  function microtime_float() {
    list($utime, $time) = explode(" ", microtime());
    return ((float)$utime + (float)$time);
  }
  function timing_milestone($name) {
    self::$milestones[] = array($name, self::microtime_float());
  }
  function dump_profile($return = false) {
    self::$milestones[] = array('finish', self::microtime_float());
    $output = '&lt;table border="1"&gt;'.
              '&lt;tr&gt;&lt;th&gt;Milestone&lt;/th&gt;&lt;th&gt;Diff&lt;/th&gt;&lt;th&gt;Cumulative&lt;/th&gt;&lt;/tr&gt;';
    foreach (self::$milestones as $elem =&gt; $data) {
      $output .= '&lt;tr&gt;&lt;td&gt;'.$data[0].'&lt;/td&gt;'.
        '&lt;td&gt;'.round(($elem ? $data[1] - self::$milestones[$elem - 1][1]: '0'), 5).'&lt;/td&gt;'.
        '&lt;td&gt;'.round(($data[1] - self::$milestones[0][1]), 5).'&lt;/td&gt;&lt;/tr&gt;';
    }
    $output .= '&lt;/table&gt;';
    if ($return) return $output;
    echo $output;
  }
}</pre>
<p>As you can see, it&#8217;s a fairly simple class. It basically stores an array of milestones, each named, in ScriptTimer::$milestones. Each time you call ScriptTimer::timing_milestone(), you pass it a name of the current milestone. This might be &#8216;begin&#8217;, &#8216;init db&#8217;, &#8216;fetch rss&#8217;, &#8216;end&#8217;, or anything you like. When you call ScriptTimeer::dump_profile(), it runs through all these milestones and generates a HTML report. Trying it out in a real application results in something like the following:</p>
<p><img src='http://www.developertutorials.com/blog/wp-content/uploads/2008/03/scripttimer_scr.png' alt='Screenshot of PHP Script Timer in action' /></p>
<p>It&#8217;s no full-on profiler, but it can still prove highly useful in quickly performance testing your application. To use it, just call ScriptTimer::timing_milestone(&#8217;some milestone name&#8217;) at major sections of your code. This is the testing script I used:</p>
<pre>
ScriptTimer::timing_milestone('begin');
usleep(3000); // do some db stuff
ScriptTimer::timing_milestone('db ready');
usleep(5200); // do some cache stuff
ScriptTimer::timing_milestone('caches primed');
usleep(8000); // render the output
ScriptTimer::timing_milestone('all output');
usleep(600); // clean up
ScriptTimer::timing_milestone('garbage collected');
ScriptTimer::dump_profile();
</pre>
<p>I&#8217;ve used the usleep() function to simulate loading time - don&#8217;t do this in your real application! Just add the ScriptTimer::timing_milestone() calls in, and call ScriptTimer::dump_profile() at the end. No need to initialise; the class works statically for simplicity.</p>
<h3>Workaround for max_execution_time limit</h3>
<p>Depending on your server configuration, you should be able to work around the max_execution_time script execution time limit very easily. A call to ini_set() should change the value of max_execution_time for the current execution, like so:</p>
<pre>
ini_set('max_execution_time', '0'); // 0 = no limit.
</pre>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d83').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d83" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/php-measure-max-execution-time-script-execution-time-83/&amp;title=PHP+Script+execution+time+and+maximum+workaround" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/php-measure-max-execution-time-script-execution-time-83/&amp;title=PHP+Script+execution+time+and+maximum+workaround" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/php-measure-max-execution-time-script-execution-time-83/&amp;title=PHP+Script+execution+time+and+maximum+workaround" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/php-measure-max-execution-time-script-execution-time-83/&amp;title=PHP+Script+execution+time+and+maximum+workaround" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d83').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/php-measure-max-execution-time-script-execution-time-83/feed/</wfw:commentRss>
		</item>
		<item>
		<title>7 websites that will make you a better PHP developer</title>
		<link>http://www.developertutorials.com/blog/php/7-websites-that-will-make-you-a-better-php-developer-82/</link>
		<comments>http://www.developertutorials.com/blog/php/7-websites-that-will-make-you-a-better-php-developer-82/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 07:15:57 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[php tips]]></category>

		<category><![CDATA[professional development]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/7-websites-that-will-make-you-a-better-php-developer-82/</guid>
		<description><![CDATA[Developing in PHP isn&#8217;t a textbook science. There&#8217;s skill to it, and that skill comes from experience. Now, you could try your hand at every single PHP development challenge out there, or you could learn from the experiences of others, widely published on the web in blogs and developer portals. Here are seven websites you [...]]]></description>
			<content:encoded><![CDATA[<p>Developing in PHP isn&#8217;t a textbook science. There&#8217;s skill to it, and that skill comes from experience. Now, you could try your hand at every single PHP development challenge out there, or you could learn from the experiences of others, widely published on the web in blogs and developer portals. Here are seven websites you should visit frequently to become a better PHP developer.</p>
<p><span id="more-82"></span></p>
<p><strong>1. <a href="http://devzone.zend.com/public/view" target="_blank" rel="external nofollow">Zend Developer Zone</a></strong><br />
Zend&#8217;s Developer Zone frequently publishes articles and tutorials on just about every area of PHP. Some of the recent items up there include the value of web services, various PHP conferences (and unconferences) coming up, and my favorite, &#8220;Designing Klingon Warships Using Behaviour Driven Development&#8221;.</p>
<p><strong>2. <a href="http://c7y.phparch.com/" target="_blank" rel="external nofollow">PHP Architect C7Y</a></strong><br />
C7Y is the community website of php architect, another PHP company similar to Zend. C7Y features articles on PHP development, interesting forum discussions and news from the PHP world, among other things.</p>
<p><strong>3. <a href="http://phpdeveloper.org/" target="_blank">PHPDeveloper.org</a></strong><br />
PHPDeveloper is about what&#8217;s happening in the PHP world. If something important comes up, chances are it&#8217;ll soon be up on phpdeveloper.org. Interesting posts on major PHP blogs, job openings, releases of open source projects and new tutorials all make it to phpdeveloper.org, making it an invaluable resource.</p>
<p><strong>4. <a href="http://digg.com/programming" target="_blank" rel="external nofollow">Digg.com/programming</a></strong><br />
Digg&#8217;s programming section regularly features major articles of interest to web developers. Along with the software section, Digg has everything from a video on using the Greasemonkey extension to Firefox, to powerful CSS techniques, practical uses of the Firefox Web Developer toolbar and the lateast Adobe AIR release as it happens. Definitely worth keeping an eye on. <a href="http://reddit.com/r/programming/" target="_blank">Reddit&#8217;s programming section</a> also has some gems.</p>
<p><strong>5. <a href="http://phpclasses.org/" target="_blank" rel="external nofollow">PHPClasses.org</a></strong><br />
No matter what you&#8217;re attempting to do in PHP, chances are it&#8217;s been done before. PHPClasses.org is the most comprehensive repository of user-submitted php classes, to handle everything from communicating via the MSN Messenger protocol to parsing configuration files, send SMS messages to reading apache log files. This can save you hours of development, and you can learn something new from innovative approaches other people have taken.</p>
<p><strong>6. <a href="http://www.planet-php.net/" target="_blank">Planet PHP</a></strong></p>
<p>Planet PHP is a blog planet, aggregating posts from well over 100 major PHP blogs. If something big is happening in the PHP world, chances are it&#8217;ll turn up on Planet PHP. This is fairly high traffic, however, so it&#8217;s easiest to grab the feed in your feed reader - see below.</p>
<p><strong>7. Bonus: <a href="http://reader.google.com/" target="_blank">Google Reader</a> to keep track of it all</strong></p>
<p>Of course, you can&#8217;t keep track of all of these sites yourself. Load up your favorite RSS/atom feed reader - we prefer Google Reader, but <a href="http://en.wikipedia.org/wiki/List_of_feed_aggregators" target="_blank" rel="external nofollow">there are many others</a> - and add these feeds:</p>
<blockquote><p><a href="http://feeds.feedburner.com/ZendDeveloperZone" target="_blank" rel="external nofollow">Zend Dev Zone</a><br />
<a href="http://c7y.phparch.com/c/tag/podcast?feed=atom" target="_blank" rel="external nofollow">php architect C7Y</a><br />
<a href="http://phpdeveloper.org/feed" target="_blank" rel="external nofollow">phpdeveloper.org</a><br />
<a href="http://www.planet-php.net/rss/" target="_blank">Planet PHP</a><br />
<a href="http://www.developertutorials.com/blog/php/feed/">Developer Tutorials PHP Blog <img src='http://www.developertutorials.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </a></p>
</blockquote>
<p>You can then load up Google Reader (or your feed reader of choice) every morning and find the latest PHP news, tips and tricks, patterns and approaches, invaluable for becoming a better PHP developer.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d82').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d82" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/7-websites-that-will-make-you-a-better-php-developer-82/&amp;title=7+websites+that+will+make+you+a+better+PHP+developer" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/7-websites-that-will-make-you-a-better-php-developer-82/&amp;title=7+websites+that+will+make+you+a+better+PHP+developer" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/7-websites-that-will-make-you-a-better-php-developer-82/&amp;title=7+websites+that+will+make+you+a+better+PHP+developer" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/7-websites-that-will-make-you-a-better-php-developer-82/&amp;title=7+websites+that+will+make+you+a+better+PHP+developer" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d82').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/7-websites-that-will-make-you-a-better-php-developer-82/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Extracting text from Word Documents via PHP and COM</title>
		<link>http://www.developertutorials.com/blog/php/extracting-text-from-word-documents-via-php-and-com-81/</link>
		<comments>http://www.developertutorials.com/blog/php/extracting-text-from-word-documents-via-php-and-com-81/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 08:00:49 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[php COM]]></category>

		<category><![CDATA[php tips]]></category>

		<category><![CDATA[php tricks]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/extracting-text-from-word-documents-via-php-and-com-81/</guid>
		<description><![CDATA[I was recently working on an enterprise project in which I needed to detect the text inside a Word Document. Now, I could have got rid of all the non-standard characters from the .doc file and hoped I got something reasonable at the end. I could have tried to run Word 2007 via command line [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently working on an enterprise project in which I needed to detect the text inside a Word Document. Now, I could have got rid of all the non-standard characters from the .doc file and hoped I got something reasonable at the end. I could have tried to run Word 2007 via command line to save the file as a .docx. Or I could just talk to any copy of MS Word via COM and have it do all the dirty work for me.</p>
<p>Naturally, I chose the latter. Here&#8217;s ten lines of code that do just that.</p>
<p><span id="more-81"></span></p>
<p>Communicating via COM in PHP is easy as ever; especially for people coming from a VB background where executing complex tasks in MS-applications is a piece of cake, you will feel right at home in PHP. In fact, VB COM calls can be converted to PHP COM calls in just a few simple search and replaces.</p>
<p>Without further ado, here&#8217;s the code. I&#8217;ll point out a gotcha I noticed in just a moment.</p>
<blockquote><pre>&lt;?php
$word = new COM("word.application") or die ("Could not initialise MS Word object.");
$word->Documents->Open(realpath("Sample.doc"));

// Extract content.
$content = (string) $word-&gt;ActiveDocument-&gt;Content;

echo $content;

$word-&gt;ActiveDocument-&gt;Close(false);

$word-&gt;Quit();
$word = null;
unset($word);</pre>
</blockquote>
<p>We first create a new COM object of word.application, which provides access to core MS Word functionality. We then tell it to open &#8220;Sample.doc&#8221; in the current directory. There&#8217;s a bit of a bug/feature when trying to get the content out, however. If you debug this code, you&#8217;ll find that $word-&gt;ActiveDocument-&gt;Content is an empty object (variant). If you assign the value to a variable you&#8217;ll get an empty string, as the variant object has no real __toString(). The workaround in PHP is to explicitly type cast the value as a string and make PHP/COM take care of finding the real value. If you try this in a VB macro run inside Word, this is not neccessary - a MsgBox(ActiveDocument.Content) works fine.</p>
<p>We also need to be aware of performance considerations on Windows servers - creating a COM object initialises a fully-fledged instance of WINWORD.exe, and a 10-15MB memory footprint associated with it. We first call the Quit() method on the Word COM object, then null the variable and destroy it to be safe. Watch your task manager while running this script and you&#8217;ll notice WINWORD.exe appears briefly then exits.</p>
<p>So, in just ten lines of code you can get the text out of an MS Word document, easy as ever!</p>
<p>If you want to explore this approach further, load up MS Word and open the Visual Basic Script Editor - press Alt+F11, then F2. (If that doesn&#8217;t work, Tools > Macros > Visual Basic Script Editor, or &#8220;Visual Basic&#8221; under the Developer tab 2007, then press F2.) From the library drop-down box in the &#8220;Object Browser&#8221; - which might say &#8220;<All Libraries>&#8221; by default - select Word. Just about everything you see there is available via COM in PHP.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d81').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d81" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/extracting-text-from-word-documents-via-php-and-com-81/&amp;title=Extracting+text+from+Word+Documents+via+PHP+and+COM" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/extracting-text-from-word-documents-via-php-and-com-81/&amp;title=Extracting+text+from+Word+Documents+via+PHP+and+COM" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/extracting-text-from-word-documents-via-php-and-com-81/&amp;title=Extracting+text+from+Word+Documents+via+PHP+and+COM" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/extracting-text-from-word-documents-via-php-and-com-81/&amp;title=Extracting+text+from+Word+Documents+via+PHP+and+COM" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d81').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/extracting-text-from-word-documents-via-php-and-com-81/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The ultimate PHP web development environment, part 1</title>
		<link>http://www.developertutorials.com/blog/php/ultimate-php-web-development-environment-software-part-1-78/</link>
		<comments>http://www.developertutorials.com/blog/php/ultimate-php-web-development-environment-software-part-1-78/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 11:12:02 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[php ide]]></category>

		<category><![CDATA[php tips]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/ultimate-php-web-development-environment-software-part-1-78/</guid>
		<description><![CDATA[UPDATE: Part 2 now available.
After you&#8217;ve been coding PHP for a while, you start to work out what the tools of the trade are, which applications can help you work more effectively, and essentially how to get things done. While developing, your environment is crucial: not having the right tools to do your job can [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE:</strong> <a href="http://www.developertutorials.com/blog/php/the-ultimate-php-web-development-environment-part-2-98/">Part 2 now available.</a></p>
<p>After you&#8217;ve been coding PHP for a while, you start to work out what the tools of the trade are, which applications can help you work more effectively, and essentially how to get things done. While developing, your environment is crucial: not having the right tools to do your job can be a serious impediment on productivity. In this new series, I&#8217;ll help you bring together the ultimate PHP web development environment.<br />
<span id="more-78"></span><br />
In part 1 of this series, we&#8217;ll start with the usual suspects: software. The software you use can make or break your project; not being able to debug code, for instance, can double the time taken to complete a project. Here I&#8217;ll be covering software for Windows users, but many of the suggestions here are relevant for OS X and Linux users as well.</p>
<h3>Web browsers</h3>
<p>We could have started with the IDE, but your web application doesn&#8217;t end at the IDE. In fact, a sufficiently low-featured IDE can help your project if coupled with a decent browser. The web browsers - yes, browsers, not just one browser - you use are arguably the most important part of your arsenal. A sufficiently powerful web browser can make pulling an application interface together extremely fast, while an outdated and inflexible browser can cause endless grief. Remember, you&#8217;re a web developer, and your web browser is your window into the world you work in.</p>
<p><a href="http://getfirefox.com/" target="_blank">Firefox</a> is pretty much assumed here. If you&#8217;re developing web applications with PHP and you aren&#8217;t using Firefox, you&#8217;ve either got a fantastic home-brew browser that does everything you need, or you&#8217;re developing much slower than you should be, most likely the latter. Using Firefox is especially important for rich internet applications, where the focus shifts considerably to Javascript and HTML/CSS.</p>
<p>I&#8217;m not trying to be an open source fanboy here - no other browser will allow you to debug javascript as it happens, add new javascript in while debugging, totally recreate the DOM of the page the javascript is working on while editing the javascript while debugging etc. etc. The key to Firefox is the wide variety of web development extensions available. No matter what platform you&#8217;re on, grab a copy of Firefox, then install <a href="http://www.getfirebug.com/" target="_blank">Firebug</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/3829" target="_blank">Live HTTP Headers</a> and <a href="https://addons.mozilla.org/en-US/firefox/addon/60" target="_blank">Web Developer</a>. Have a look through each of these and you&#8217;ll realise just how much power they offer. <a href="http://www.firephp.org/" target="_blank">FirePHP</a> is also fantastic.</p>
<p>Of course, you can&#8217;t just work with one browser all the time. Given IE&#8217;s dominance, a copy of Internet Explorer 7 and regular rendering tests of your applications on it should be taken for granted. Once you&#8217;ve got IE7, take a look at the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&#038;displaylang=en" target="_blank" rel="external nofollow">IE Developer Toolbar</a> too; you might be pleasantly surprised at how much power IE web developers have as well (although nowhere near as much as Firefox).</p>
<p>And finally, given <a href="http://www.webware.com/8301-1_109-9836106-2.html" target="_blank" rel="external nofollow">IE8 is going to be highly standards compliant</a>, having a <em>stable</em> standards compliant web browser might be an idea for future-proofing your application. Ironically, the best browser for this is Apple&#8217;s <a href="http://www.apple.com/safari/" target="_blank">Safari</a>. Safari uses the WebKit rendering engine, which is not only far more standards compliant than Firefox, it&#8217;s also considerably faster. Under Windows, Safari isn&#8217;t a very good idea for standard web browsing given some past security concerns, but checking your applications render fine on Safari is definitely a good idea for future proofing your application.</p>
<h3>Editor</h3>
<p>Okay, I&#8217;m putting this out here right now: it doesn&#8217;t matter what IDE you use, as long as it has a debugger. This limits your options considerably; for Windows, the best way to get an IDE with a debugger is to get yourself a copy of <a href="http://www.waterproof.fr/products/PHPEdit/" target="_blank">PHPEdit</a> or <a href="http://www.nusphere.com/products/index.htm" target="_blank">PhpEd</a>. A number of other IDEs offer inbuilt debuggers, but none manage the simplicity and ease of use as these two, especially PhpEd. And it just so happens that both PHPEdit and PhpEd have syntax highlighting, code completion, CVS integration and all the usual features you&#8217;d expect to get out of an IDE.</p>
<p>It&#8217;s worth mentioning <a href="http://zend.com/" target="_blank">Zend</a>&#8217;s Zend Studio and Zend Studio for Eclipse, as these are by far the best editors available for simply coding PHP, especially the original Zend Studio. The code intelligence is second to none, code completion is the most helpful of any IDE I&#8217;ve ever seen and the full-on feature set is ideal for any web developer. However, Zend Studio has two strikes against it: first, it uses Java, and second, the debugger is very complicated to setup (I think it needs a seperate product altogether, Zend Studio Server, although after hours of searching I simply could not work this one out). The problem with using Java is that the editor is very slow; in my tests, it started using 250MB of memory after working with some code for an hour, and it also slowed to a crawl. Think three second lags just to open context menus or expand a filesystem tree; five seconds to open a new (1KB!) file and fifteen seconds to switch to the inbuilt web browser. You&#8217;ve got work to do.</p>
<p>For a more comprehensive, albeit less detailed, roundup of IDEs, check out <a href="http://www.ibm.com/developerworks/library/os-php-ide/index.html" target="_blank">this article on IBM&#8217;s Developer Works</a>.</p>
<p>To complement your IDE, and for quick code edits and tests, grab a copy of <a href="http://www.flos-freeware.ch/notepad2.html" target="_blank">Notepad2</a> as well, and remember that if <a href="http://www.php.net/manual/en/faq.installation.php#faq.installation.addtopath" target="_blank">your PHP binary is in your system PATH</a> you can test out code interactively just by running php -a through Start > Run (also winkey + R).</p>
<h3>That&#8217;s all, folks!</h3>
<p>That&#8217;s all for browsers and editors today; in the next part of this series, I&#8217;ll take a look at configuring PHP and various other software and some Linux editors and utilities.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d78').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d78" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/ultimate-php-web-development-environment-software-part-1-78/&amp;title=The+ultimate+PHP+web+development+environment%2C+part+1" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/ultimate-php-web-development-environment-software-part-1-78/&amp;title=The+ultimate+PHP+web+development+environment%2C+part+1" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/ultimate-php-web-development-environment-software-part-1-78/&amp;title=The+ultimate+PHP+web+development+environment%2C+part+1" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/ultimate-php-web-development-environment-software-part-1-78/&amp;title=The+ultimate+PHP+web+development+environment%2C+part+1" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d78').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/ultimate-php-web-development-environment-software-part-1-78/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Give Your Visitors a Relative Time</title>
		<link>http://www.developertutorials.com/blog/php/give-your-visitors-relative-time-php-69/</link>
		<comments>http://www.developertutorials.com/blog/php/give-your-visitors-relative-time-php-69/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 07:15:29 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[php tips]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/give-your-visitors-relative-time-php-69/</guid>
		<description><![CDATA[Toby Somerville recently blogged about giving visitors a rough time - instead of displaying exact timestamps, providing a rough written approximation of the time.
Toby suggested that we generally communicate in approximate times, but on the web we usually work with exact timestamps. His idea was that by displaying the time as you would describe it [...]]]></description>
			<content:encoded><![CDATA[<p>Toby Somerville recently blogged about <a href="http://www.sitepoint.com/blogs/2008/03/06/give-you-visitors-a-rough-time/">giving visitors a rough time</a> - instead of displaying exact timestamps, providing a rough written approximation of the time.</p>
<p>Toby suggested that we generally communicate in approximate times, but on the web we usually work with exact timestamps. His idea was that by displaying the time as you would describe it verbally, he could better communicate the time in a visitor-friendly way.</p>
<p>After reading his post, I understood the merits of the approach, but it struck me that a relative time might be a little more useful for many situations. For example, in a fast moving discussion, a short timestamp (e.g. 8:30 AM) as well as a verbal summary of how long ago the time was (e.g. &#8220;4 hours ago&#8221;, &#8220;20 minutes ago&#8221;) are most useful to the user. In fact, this is precisely what Gmail does:</p>
<p><img src='http://www.developertutorials.com/blog/wp-content/uploads/2008/03/screenshot-7_03_2008-4_45_06-pm.png' alt='Gmail timestamps' /></p>
<p>A common feature of Gmail&#8217;s timestamp system is approximation, similar to what Toby was getting at. For example, as you approach 60 minutes in the hour, Gmail seems to switch from &#8220;x minutes ago&#8221; to &#8220;1 hour ago&#8221;, even if you&#8217;re not quite there.</p>
<p>Now, I figured this could be achieved very easily in PHP - and it could. After the jump, here&#8217;s the code:</p>
<p><span id="more-69"></span></p>
<p><pre>&lt;?php
function RelativeTime($time, $now = false)
{
	$time = (int) $time;
	$curr = $now ? $now : time();
	$shift = $curr - $time;

	if ($shift < 45):
		$diff = $shift;
		$term = "second";
	elseif ($shift < 2700):
		$diff = round($shift / 60);
		$term = "minute";
	elseif ($shift < 64800):
		$diff = round($shift / 60 / 60);
		$term = "hour";
	else:
		$diff = round($shift / 60 / 60 / 24);
		$term = "day";
	endif;

	if ($diff == 1) $term .= "s";
	return "$diff $term ago";
}
</pre>
</p>
<p>It&#8217;s got a few unusual constants in there - the number values refer to 75% of the number of seconds in a particular period of time. 75% seemed like a reasonable measure beyond which we could round up - for example, the function will say &#8220;45 seconds ago&#8221; for 45 seconds, but &#8220;1 minute ago&#8221; for 46. The same goes for 2700 seconds, equal to 45 minutes, and 64800 seconds, or eighteen hours. Beyond this it simply uses the number of days.</p>
<p>The function will give you values like &#8220;20 seconds ago&#8221;, &#8220;10 minutes ago&#8221;, &#8220;3 hours ago&#8221; etc. Adding the <a href="http://pear.php.net/package-info.php?package=Numbers_Words">Numbers_Words PEAR package</a> might improve readability of your timestamps even more</p>
<p>So give it a go - it&#8217;s especially handy for message boards, comment lists and news readers, especially with threaded discussion. The code is very basic at the moment, suitable for adapting to whatever purpose you see fit.</p>
<p>EDIT: Hasin Hayder, a fellow DT blogger, <a href="http://www.developertutorials.com/blog/php/calculating-date-difference-more-precisely-in-php-71/">wrote a post about a similar function</a> that you may be interested in.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d69').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d69" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/give-your-visitors-relative-time-php-69/&amp;title=Give+Your+Visitors+a+Relative+Time" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/give-your-visitors-relative-time-php-69/&amp;title=Give+Your+Visitors+a+Relative+Time" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/give-your-visitors-relative-time-php-69/&amp;title=Give+Your+Visitors+a+Relative+Time" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/give-your-visitors-relative-time-php-69/&amp;title=Give+Your+Visitors+a+Relative+Time" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d69').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/give-your-visitors-relative-time-php-69/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Say hello to namespace naming conventions!</title>
		<link>http://www.developertutorials.com/blog/php/say-hello-to-namespace-naming-conventions-59/</link>
		<comments>http://www.developertutorials.com/blog/php/say-hello-to-namespace-naming-conventions-59/#comments</comments>
		<pubDate>Sat, 01 Mar 2008 09:50:45 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[php 5.3]]></category>

		<category><![CDATA[php namespaces]]></category>

		<category><![CDATA[php tips]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/say-hello-to-namespace-naming-conventions-59/</guid>
		<description><![CDATA[First, we had variable naming conventions. Then we got classes and functions / methods, so we got general naming conventions. With PHP 5.3 introducing namespaces, it&#8217;s time to say hello to namespace naming conventions.
Namespaces were introduced to solve the problem of naming clashes. Once upon a time, all your code lived in one, two, maybe [...]]]></description>
			<content:encoded><![CDATA[<p>First, we had variable naming conventions. Then we got classes and functions / methods, so we got general naming conventions. With PHP 5.3 introducing namespaces, it&#8217;s time to say hello to namespace naming conventions.</p>
<p>Namespaces were introduced to solve the problem of naming clashes. Once upon a time, all your code lived in one, two, maybe three files, and you could see and know exactly what was going on. Then applications started expanding, and OOP came along. Suddenly there were hundreds of functions, classes and methods in your application, not to mention variables and properties.</p>
<p><span id="more-59"></span></p>
<p>It was generally accepted that names should therefore be descriptive. However, names soon became very brief and generic, such as new(), Blog::add_post(), $config etc. All very well when you controlled all the code in the scope of your application, but the moment you came to integrating or reusing code everything went awry. To avoid this, names were long winded, prefixed and determinedly different.</p>
<p>So, where do namespaces fit in? Well, first we had raw procedural code, then we had functions, then we put functions inside classes. The best way to explain namespaces is that we can now put functions inside classes inside namespaces. <a href="http://www.php.net/manual/en/language.namespaces.using.php" target="_blank">this page</a> has some good samples.</p>
<p>Of course, this is only going to work if namespaces names are unique.</p>
<p>Once PHP 5.3 goes mainstream, I suspect we&#8217;ll see the same trends in namespace naming as we did in class / package naming. In the samples used to demonstrate namespaces, we&#8217;ve seen anything from Company::Project::Package containing classs Package, Package_Something, Package_Something_Else; to MyProject::Package::Class containing class Class.</p>
<p>Ideally, we&#8217;d have [OriginOfCode::]Project::Package[::SubPackage] for naming conventions. The origin of the code could be the project itself (e.g. for open source collaborative projects), and could be omitted where appropriate. Subpackages would have to be clearly defined - there is no need to create a seperate namespace just for a new class. On the other hand, it makes perfect sense to have Zend::Framework::Service::Delicious and Zend::Framework::Service::Akismet.</p>
<p>Taking this to the extreme, we maintain a global list of TLNs - like TLDs, but Top Level Namespaces - and have a basic registration system. $0.25 to register your very own JohnCitizen namespace in PHP history? Each developer/company/project could then manage their top level namespace - and, if they so desire, park it with keyword-rich classes commented with ads for the latest and greatest in commercial PHP development tools. Just kidding.</p>
<p>So, what are your thoughts on namespaces and naming conventions? Should we be enforcing certain formats for namespace names? Will we ever see Microsoft::Windows::Core::Filesystem::Utils::Defragement, or will namespaces be the final solution to ensuring code can co-exist as the one big happy family that is the PHP ecosystem?</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d59').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d59" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/say-hello-to-namespace-naming-conventions-59/&amp;title=Say+hello+to+namespace+naming+conventions%21" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/say-hello-to-namespace-naming-conventions-59/&amp;title=Say+hello+to+namespace+naming+conventions%21" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/say-hello-to-namespace-naming-conventions-59/&amp;title=Say+hello+to+namespace+naming+conventions%21" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/say-hello-to-namespace-naming-conventions-59/&amp;title=Say+hello+to+namespace+naming+conventions%21" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d59').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/say-hello-to-namespace-naming-conventions-59/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Zend Framework: The Best Framework for Use With Other Frameworks</title>
		<link>http://www.developertutorials.com/blog/php/zend-framework-use-with-other-frameworks-56/</link>
		<comments>http://www.developertutorials.com/blog/php/zend-framework-use-with-other-frameworks-56/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 10:13:58 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[php frameworks]]></category>

		<category><![CDATA[php tips]]></category>

		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/zend-framework-use-with-other-frameworks-56/</guid>
		<description><![CDATA[Here&#8217;s an interesting sales pitch. Using a PHP Framework? Cool. Just make sure you add Zend.
The Zend Framework is a fairly standard, (optionally) MVC PHP application framework. It comes with all the usual functionality; request routing, database access, templates (through view files) etc. It also comes with a lot of extra functionality that you might [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an interesting sales pitch. <em>Using a PHP Framework? Cool. Just make sure you add Zend.</em></p>
<p>The Zend Framework is a fairly standard, (optionally) MVC PHP application framework. It comes with all the usual functionality; request routing, database access, templates (through view files) etc. It also comes with a lot of extra functionality that you might find useful in your application, including some of the best web services libraries available, especially when working with Google&#8217;s APIs.</p>
<p><span id="more-56"></span></p>
<p>But here&#8217;s the kicker: it works entirely standalone. The classes and their methods can, generally, be used statically in any context, or at least independently of the framework. You can use the Zend Framework&#8217;s libraries to manipulate dates and times, work with RSS feeds, interact with Google&#8217;s Gdata APIs, even generate PDF files (although the functionality isn&#8217;t as mature as FPDF).</p>
<p>Fred Wu recently <a href="http://thislab.com/2008/02/21/using-zend-framework-with-codeigniter/">blogged about using Zend Framework with CodeIgniter</a>. It&#8217;s a fantastic way to make use of the efforts of all ZF contributors, as well as speed up development significantly. Chances are, if there&#8217;s something you&#8217;re trying to do in your web application, the Zend Framework can help.</p>
<p>So <a href="http://framework.zend.com/">check it out</a>. It might just make your day.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d56').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d56" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/zend-framework-use-with-other-frameworks-56/&amp;title=Zend+Framework%3A+The+Best+Framework+for+Use+With+Other+Frameworks" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/zend-framework-use-with-other-frameworks-56/&amp;title=Zend+Framework%3A+The+Best+Framework+for+Use+With+Other+Frameworks" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/zend-framework-use-with-other-frameworks-56/&amp;title=Zend+Framework%3A+The+Best+Framework+for+Use+With+Other+Frameworks" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/zend-framework-use-with-other-frameworks-56/&amp;title=Zend+Framework%3A+The+Best+Framework+for+Use+With+Other+Frameworks" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d56').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/zend-framework-use-with-other-frameworks-56/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
