<?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>Jonathan Wijaya Loe&#039;s blog &#187; Programming</title>
	<atom:link href="http://blog.jloe.net/category/technology/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jloe.net</link>
	<description>A blog about technology blogging, tips and tricks, troubleshooting, and step by step tutorial with specialties in Microsoft .NET, C#, Zend, and PHP. Also includes wonderful and inspiring stories and jokes.</description>
	<lastBuildDate>Mon, 02 May 2011 00:05:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PHP ZipArchive corrupted</title>
		<link>http://blog.jloe.net/2009/07/06/php-ziparchive-corrupted/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-ziparchive-corrupted</link>
		<comments>http://blog.jloe.net/2009/07/06/php-ziparchive-corrupted/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 06:47:17 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Troubleshoot]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php_zip]]></category>
		<category><![CDATA[wampserver]]></category>
		<category><![CDATA[ZipArchieve]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=592</guid>
		<description><![CDATA[If you experienced a corrupted zip file produced by ZipArchive on WampServer you probably have come to the right place. Apparently there has been a discussion on this long time ago but looks like Wampserver still uses the old php_zip.dll. Well, nothing much to write about as it&#8217;s quite straightforward. You might want to try [...]]]></description>
			<content:encoded><![CDATA[<p>If you experienced a corrupted zip file produced by ZipArchive on WampServer you probably have come to the right place. Apparently there has been a <a title="Discussion on the issue" href="http://pecl.php.net/bugs/bug.php?id=9278" target="_blank">discussion</a> on this long time ago but looks like Wampserver still uses the old php_zip.dll.</p>
<p>Well, nothing much to write about as it&#8217;s quite straightforward. You might want to try downloading the latest binary file <a title="Click to download" href="http://blog.jloe.net/wp-content/uploads/2009/07/jloe_php_zip.zip">here</a> to solve the issue. <img src='http://blog.jloe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Sources:</p>
<ul>
<li><a title="Click to check the site" href="http://pecl.php.net/bugs/bug.php?id=9278" target="_blank">Images files added with ZipArchive::addFile corrupt</a></li>
<li><a title="Click to check the site" href="http://www.mail-archive.com/php-bugs@lists.php.net/msg121851.html" target="_blank">Zip becomes corrupt when using ZipArchive</a></li>
<li><a title="Click to check the site" href="http://www.justskins.com/forums/39506-new-archive-corrupt-with-ziparchive-addfile-method-55114-2.html" target="_blank">Archive corrupt with ZipArchive::addFile method</a></li>
</ul>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 44px; width: 1px; height: 1px;">
<h1><span class="subject">Zip becomes corrupt when using ZipArchive</span></h1>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/07/06/php-ziparchive-corrupted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Manipulation in PHP</title>
		<link>http://blog.jloe.net/2009/06/22/image-manipulation-in-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=image-manipulation-in-php</link>
		<comments>http://blog.jloe.net/2009/06/22/image-manipulation-in-php/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 08:49:17 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[image manipulation]]></category>
		<category><![CDATA[image processing]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[imagick]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php_gd2]]></category>
		<category><![CDATA[php_imagick]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[wampserver]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=665</guid>
		<description><![CDATA[Sometimes there is a need to do simple image manipulation for certain web projects. Take for example a popular site called Flickr. Flickr is an image hosting site that allows online community to store pictures for others to view. And for some cases some uploaders may have big image files and hence a site like [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes there is a need to do simple image manipulation for certain web projects. Take for example a popular site called <a title="Click to go to Flickr" href="http://www.flickr.com/" target="_blank">Flickr</a>. Flickr is an image hosting site that allows online community to store pictures for others to view. And for some cases some uploaders may have big image files and hence a site like Flickr definitely needs some image processing to reduce the actual image into a smaller dimension, hence smaller file size, to allow quick view before actually downloading the actual size.</p>
<p>I&#8217;ve been working with <a title="Click to check about Zend Framework" href="http://framework.zend.com/" target="_blank">Zend Framework</a> quite sometime for web projects. I found it&#8217;s quite interesting to find that Zend Framework does not have any class to perform image manipulation even though a proposal for Zend_Image had been submitted to Zend community as a wrapper of existing PHP interfaces: <a title="Click to read more about GD." href="http://www.boutell.com/gd/" target="_blank">GD</a> and <a title="Click here to read about ImageMagick" href="http://www.imagemagick.org/" target="_blank">ImageMagick</a> but unfortunately <a title="Zend_Image proposal" href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Image+Proposal+-+Davey+Shafik" target="_blank">the proposal</a> was not considered.</p>
<p><!--adsense#az-edeal-->And for your information, GD which stands for &#8216;Gif Draw&#8217; is a standard PHP installation, unlike ImageMagick. If you wish to utilize these libraries, you need to have php extensions called php_gd2 and php_imagick respectively installed and enabled on the web server.</p>
<p>The noticeable difference between GD and ImageMagick is that GD simply does not support image format like <a title="Click to check more about TIFF" href="http://en.wikipedia.org/wiki/Tagged_Image_File_Format" target="_blank">TIFF</a> (Tagged Image File Format). If TIFF is not your issue then go for GD. And if you wish to make your development easier, you may be interested to use <a title="Click to download Thumbnail class" href="http://www.ajaxray.com/blog/2008/09/12/image-manipulation-in-zend-framework-with-php-thumbnailer-class-v20/" target="_blank">Thumbnail class</a> by our fellow developer. But if you&#8217;re looking into ImageMagick I&#8217;m going to show you the steps (from <a title="Click here to see the original post." href="http://sg.php.net/manual/en/imagick.setup.php" target="_blank">another site</a>) on how to install ImageMagick on your Windows web server as Windows installation is a bit tricky since &#8220;pecl install imagick&#8221; does NOT work properly.</p>
<ol>
<li>Download and install ImageMagick software from <a href="http://www.imagemagick.org/script/binary-releases.php#windows" target="_blank">http://www.imagemagick.org/script/binary-releases.php#windows</a>.</li>
<li>Download pecl-5.2-dev.zip (choose the version relevant to your PHP) from <a href="http://snaps.php.net/win32/" target="_blank">http://snaps.php.net/win32/</a></li>
<li>Copy php_imagick.dll from the archive you&#8217;ve downloaded to your PHP extension folder.</li>
<li>Add the following line to php.ini (in the extensions section):<br />
extension=php_imagick.dll</p>
<p>or on <a href="http://www.wampserver.com/en/" target="_blank" title="Click to go to WampServer official site">WampServer</a> click WampServer icon on taskbar, go to PHP &gt; php.ini and add the above entry.</li>
<li>Restart your server.</li>
<li>Try this example script below to verify your installation.
<pre name="code" class="php">header('Content-type: image/tif');

$image = new Imagick('example.tif');
// Create thumbnail for the specified image file.
$image-&gt;thumbnailImage(100, 0);

echo $image;</pre>
<p>The script should display the image thumbnail with a maximum width of 100 pixels.</li>
</ol>
<p>If you find the above steps are difficult to follow you may want to download php_imagick.dll <a title="Click to download" href="../wp-content/uploads/2009/06/php_imagick.zip">here</a> and start from step 3. And if you need help with these libraries, check the manual pages for <a title="Click to see the manual page." href="http://us3.php.net/manual/en/ref.image.php" target="_blank">GD</a> and <a title="Click to see the manual page." href="http://us3.php.net/manual/en/book.imagick.php" target="_blank">ImageMagick</a>.</p>
<p>Lastly if you find this post helpful, kindly leave your rating below to indicate that this post is really useful and at the same time let others know about this post. And if your wish to let other communities know about this post kindly click the sociable icons below. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/06/22/image-manipulation-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Performance Best Practices</title>
		<link>http://blog.jloe.net/2009/06/15/web-performance-best-practices/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=web-performance-best-practices</link>
		<comments>http://blog.jloe.net/2009/06/15/web-performance-best-practices/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 07:29:56 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[firefox add-on]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[page speed]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[web performance]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=621</guid>
		<description><![CDATA[Following-up my previous post on how to increase site performance. I received an email from my lead about a Firefox add-on named &#8220;Page Speed&#8221; that helps analyze a site performance. In brief, Page Speed is an open-source Firefox/Firebug Add-on. Webmasters and web developers can use Page Speed to evaluate the performance of their web pages [...]]]></description>
			<content:encoded><![CDATA[<p>Following-up <a href="http://blog.jloe.net/2009/05/28/one-cent-tips-to-increase-site-performance/">my previous post</a> on how to increase site performance. I received an email from my lead about a Firefox add-on named &#8220;Page Speed&#8221; that helps analyze a site performance.</p>
<p>In brief, <a href="http://code.google.com/speed/page-speed/">Page Speed</a> is an open-source Firefox/Firebug Add-on. Webmasters and web developers can use Page Speed to evaluate the performance of their web pages and to get suggestions on how to improve them.</p>
<p>Page Speed works by performing several tests on a site&#8217;s web server configuration and front-end code. These tests are based on a set of best practices known to enhance web page performance. Webmasters who run Page Speed on their pages get a set of scores for each page, as well as helpful suggestions on how to improve its performance.</p>
<p>But that&#8217;s not all, the good stuff is its article <a href="http://code.google.com/speed/page-speed/docs/rules_intro.html">&#8220;Performance Best Practices&#8221;</a> which explains in detail all aspects on what needs to be done to improve your site: from network (DNS, server settings) to browser layer (CSS, JavaScript, image, compression) which extends <a href="http://blog.jloe.net/2009/05/28/one-cent-tips-to-increase-site-performance/">my previous post</a> in greater detail.</p>
<p><!--adsense#co-1-->However these best practices may not be the complete solutions, in my opinion. If your site deals with dynamic content, there should be programming logic behind the content. This means whoever creates the logic has to utilize the best logic for highest efficiency in terms of computation. And if your site deals with a database, optimizing the queries to the designated database is also required.</p>
<p>Ultimately basic rules for programming are to avoid redundancy and to distribute computation load whenever possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/06/15/web-performance-best-practices/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quick and Easy Way to Create Model Class in PHP</title>
		<link>http://blog.jloe.net/2009/05/20/quick-and-easy-way-to-create-model-class-in-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quick-and-easy-way-to-create-model-class-in-php</link>
		<comments>http://blog.jloe.net/2009/05/20/quick-and-easy-way-to-create-model-class-in-php/#comments</comments>
		<pubDate>Wed, 20 May 2009 15:59:17 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=511</guid>
		<description><![CDATA[Ever experienced a boring and time-consuming task where you have to create a new class for your model object: declaring list of variables and creating the getter and setter functions? &#8220;Always&#8221; is my answer. Imagine if you have a long list of variables. &#8220;Shoot! NOT AGAIN&#8221; may be the first exclamation came out from you. [...]]]></description>
			<content:encoded><![CDATA[<p>Ever experienced a boring and time-consuming task where you have to create a new class for your model object: declaring list of variables and creating the getter and setter functions? &#8220;Always&#8221; is my answer. Imagine if you have a long list of variables. &#8220;Shoot! NOT AGAIN&#8221; may be the first exclamation came out from you. And for the sake of a good software design, the creation of these functions is essential. Blessed if you have excellent <a title="Click to find out more" href="http://en.wikipedia.org/wiki/Integrated_development_environment" target="_blank">IDE</a> to generate these for you.</p>
<p>So far I&#8217;ve been working with some IDEs out there like Microsoft Visual Studio (including Express edition), Eclipse for PHP, Zend Studio, and PHP Designer, and to me Visual Studio is the most developer-friendly IDE. But this task is still repetitive to me and personally I am into the notion of DRY (Don&#8217;t Repeat Yourself).</p>
<p>Well, I finally found a way to resolve this in <strong>PHP</strong> and I&#8217;m going to share this. The code is extended based on a sample file from <a title="Click to read more." href="http://framework.zend.com/docs/quickstart" target="_blank">Zend QuickStart</a>.</p>
<pre name="code" class="php">
/**
 * This class is a helper class that allows developer to
 * create an object model easily by simply inheriting and
 * declaring their desired variables as public in the child class
 * and seamlessly creates a pair of getter and setter functions.
 */
class JLoe_Model_Object
{
  /**
   * The regular expression for get method name.
   *
   * @var string
   */
  const REGEX_GET = '/get.*/';

  /**
   * The regular expression for set method name.
   *
   * @var string
   */
  const REGEX_SET = '/set.*/';

  /**
   * Get the value of a property with method syntax.
   *
   * Map method calls to get and set the declared public variables.
   * This is used to help to create magic get and set functions seamlessly.
   *
   * @param  string $method method name
   * @param  mixed  $param  parameter values to be passed
   * @return property value or this object
   */
  public function __call( $method, $param )
  {
    // Check whether it's a get or set method, else throw exception
    if ( preg_match( self::REGEX_GET, $method ) ) {
      $isGet = true;
      $propName = str_replace( 'get', '', $method );
    }
    elseif ( preg_match( self::REGEX_SET, $method ) ) {
      $isGet = false;
      $propName = str_replace( 'set', '', $method );
    }
    else { throw new JLoe_Model_Exception( 'Invalid method' ); }

    // Check whether property name exists
    $propName = ucfirst( $propName );
    if ( ! property_exists( $this, $propName ) ) {
      throw new JLoe_Model_Exception( 'Invalid method' );
    }

    // Perform respective method call
    if ( $isGet ) { return $this-&gt;$propName; }
    else
    {
      $this-&gt;$propName = $param[0];
      return $this;
    }
  }

  /**
   * Map variable access onto the underlying method representation.
   *
   * Allow to map the variable access with the respective get method.
   *
   * @param  string $name the property name to access
   * @return mixed value depending on the underlying method called
   */
  public function __get( $name )
  {
    $method = 'get' . $name;
    if ( ('mapper' == $name) || !method_exists($this, $method) )
    {
      throw new JLoe_Model_Exception( 'Invalid property' );
    }
    return $this-&gt;$method();
  }

  /**
   * Map variable access onto the underlying method representation.
   *
   * Allow to map the variable access with the respective set method.
   *
   * @param  string $name the property name to access
   * @return instance of the inherited class
   */
  public function __set( $name, $value )
  {
    $method = 'set' . $name;
    if ( ('mapper' == $name) || !method_exists($this, $method) )
    {
      throw new JLoe_Model_Exception( 'Invalid property' );
    }
    $this-&gt;$method( $value );
  }
}
</pre>
<p>And with this, you can code your model class with just a few lines. Here goes a sample.</p>
<pre name="code" class="php">
class Quot_Model_Quote extends JLoe_Model_Object
{
  /**
   * Quote id.
   *
   * @var int
   */
  public $Id;

  /**
   * The quote
   *
   * @var string
   */
  public $Quote;

  /**
   * Tags for this quote.
   *
   * @var array
   */
  protected $_tags;
  public function getTags() { return $this-&gt;_tags; }
  public function setTags( $tags )
  {
    // Put your own logic here
    $this-&gt;_tags = $tags;
  }
}
</pre>
<p><!--adsense#co-1-->Here if you wish to allow other class to access it via its variable name, getter, or setter functions, you just need to declare the variable as public as depicted on line 8 and 15. On the other hand, if you wish to limit access to a variable, you can always declare the variable as protected and create your desired getter or setter functions associated with the variable as shown on line 22 to 27.</p>
<p>And now you may access the class as follows.</p>
<pre name="code" class="php">
$quote = new JLoe_Model_Quote();

$quote-&gt;Id   = $id;
$quote-&gt;Name = $name;
$quote-&gt;Tags = $tags;
// You may also use this
$quote
  -&gt;setId( $id )
  -&gt;setName( $name )
  -&gt;setTags( $tags )

$id   = $quote-&gt;Id;
$name = $quote-&gt;Name;
$tags = $quote-&gt;tags;
// Similar with
$id   = $quote-&gt;getId();
$name = $quote-&gt;getName();
$tags = $quote-&gt;getTags();
</pre>
<p>It&#8217;s that easy. Now I can write my model class quickly and easily for other PHP projects. Yey! <img src='http://blog.jloe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/05/20/quick-and-easy-way-to-create-model-class-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read Remote Content or File using Zend</title>
		<link>http://blog.jloe.net/2009/05/05/read-remote-content-or-file-using-zend/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=read-remote-content-or-file-using-zend</link>
		<comments>http://blog.jloe.net/2009/05/05/read-remote-content-or-file-using-zend/#comments</comments>
		<pubDate>Tue, 05 May 2009 11:33:00 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=333</guid>
		<description><![CDATA[Today I was looking around for sample to read a remote file in PHP or even better using Zend. Well there are quite a few good samples that demonstrate the use of native PHP functions: fopen, file_get_contents, or curl but I hardly find examples using Zend. Perhaps it&#8217;s just not my luck. But the good [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was looking around for sample to read a remote file in PHP or even better using Zend. Well there are quite a few good samples that demonstrate the use of native PHP functions: fopen, file_get_contents, or curl but I hardly find examples using Zend. Perhaps it&#8217;s just not my luck. But the good thing is I managed to write my own code using Zend upon reading through few samples from <a href="http://framework.zend.com/manual/en/zend.controller.response.html">Zend documentation</a>. Here goes the code.<span id="more-333"></span></p>
<pre name="code" class="php">
/**
 * Read the remote file and send the content as the response
 *
 * @author Jonathan Loe
 * @date   May 05 2009
 */
protected function readAndSendRemoteContent( $url )
{
  // Set the configuration parameters
  $config = array( 'adapter' =&gt; 'Zend_Http_Client_Adapter_Socket' );

  // Instantiate a client object
  $client = new Zend_Http_Client( $url, $config );
  $response = $client-&gt;request();

  $this-&gt;getResponse()
    -&gt;setHeader( 'Content-type', $response-&gt;getHeader( 'Content-type' ) )
    -&gt;appendBody( $response-&gt;getRawBody() )
    -&gt;sendResponse();
}
</pre>
<p>First line of code is to set the adapter as Zend_Http_Client_Adapter_Socket. Next line is to specify the remote url along with the adapter set in the config and make the request. My last code is to send whatever was received and send it to the client as a response with the same &#8216;Content-type&#8217;. $this refers to the instance of the Zend controller class.</p>
<p>It&#8217;s that simple hey? <img src='http://blog.jloe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>PS: If you&#8217;re looking for other samples which demonstrate use of the native functions. Here are a few links you may be interested in.</p>
<p>Links:</p>
<ul>
<li><a href="http://www.php-mysql-tutorial.com/wikis/php-tutorial/reading-a-remote-file-using-php.aspx" target="_blank">Reading a Remote File Using PHP</a></li>
<li><a href="http://www.humanumbrella.com/2007/12/08/how-to-download-a-remote-file-in-php-and-then-save-it/" target="_blank">How to download a remote file in php and then save it</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/05/05/read-remote-content-or-file-using-zend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Start SOAP with Zend Framework</title>
		<link>http://blog.jloe.net/2009/04/23/start-soap-with-zend-framework/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=start-soap-with-zend-framework</link>
		<comments>http://blog.jloe.net/2009/04/23/start-soap-with-zend-framework/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 01:37:51 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[wampserver]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[wsdl]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend_soap_client]]></category>
		<category><![CDATA[zend_soap_server]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=139</guid>
		<description><![CDATA[SOAP? Hang on.. This is not the soap you probably first think of from your daily life. This is the SOAP in Information Technology term. Sorry but don't mean to discriminate anyone out there ;)]]></description>
			<content:encoded><![CDATA[<p>SOAP? Hang on.. This is not the soap you probably first think of from your daily life. This is the SOAP in Information Technology term. Sorry but don&#8217;t mean to discriminate anyone out there <img src='http://blog.jloe.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>For readers who have no idea what SOAP is. Here&#8217;s a short explanation about SOAP as defined by <a title="What is SOAP?" href="http://searchsoa.techtarget.com/sDefinition/0,,sid26_gci214295,00.html" target="_blank">TechTarget</a>.</p>
<blockquote><p>SOAP (Simple Object Access Protocol) is a way for a program running in one kind of operating system (such as Windows 2000) to communicate with a program in the same or another kind of an operating system (such as Linux) by using the World Wide Web&#8217;s Hypertext Transfer Protocol (HTTP)and its Extensible Markup Language (XML) as the mechanisms for information exchange.</p></blockquote>
<p>Here I will share my step-by-step guide on how to start your SOAP application using PHP and Zend as your Model View Controller (MVC) framework. First, I have the following application and framework installed. But I will not explain in detail about them in this post.</p>
<ul>
<li><a title="WampServer" href="http://www.wampserver.com/" target="_blank">WampServer</a></li>
<li><a title="Zend Framework" href="http://framework.zend.com/download" target="_blank">Zend Framework 1.7.5</a></li>
</ul>
<p>To start, first you need to enable a php extension called <em>php_soap</em>. In WampServer, this module has been pre-installed but you need to enable the module by the following steps.</p>
<ol>
<li>Click WampServer icon on the tray.</li>
<li>Select PHP &gt; PHP Extension.</li>
<li>And finally click php_soap to enable it.</li>
</ol>
<p>Then, we create a simple class called <em>Models_Writer</em> which has a function <em>write</em> that returns the specified string to the calling function.</p>
<pre name="code" class="php">
class Models_Writer
{
  /**
   * Return the specified text
   *
   * @param string $string
   * @return string
   */
  public function write( $string )
  {
    return $string;
  }
}
</pre>
<p>Followed by a simple action function called <em>wsdlAction</em> which renders generated <em>WSDL</em> for the class <em>Models_Writer</em> using <em>Zend_Soap_AutoDiscover</em>. Hey hey stop! what the heck is <em>WSDL</em>?. In short,</p>
<blockquote><p>WSDL or Web Services Description Language is an XML-based language that provides a model for describing Web services.</p></blockquote>
<p>Follow this <a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language">link</a> on wikipedia to help you along with what exactly is WSDL.</p>
<p>Moving on&#8230;</p>
<pre name="code" class="php">
/**
 * Render the WSDL
 */
public function wsdlAction()
{
  $wsdl = new Zend_Soap_AutoDiscover();
  $wsdl-&gt;setUri( APP_URL . '/index/' );
  $wsdl-&gt;setClass( 'Models_Writer' );
  $wsdl-&gt;handle();
  exit;
}
</pre>
<p><!--adsense#az-edeal-->As shown on line 7, <em>APP_URL</em> is to be replaced with the url of the application (ie. http://localhost/). You may define <em>APP_URL</em> inside <em>bootstrap.php</em> for global use. Function <em>setUri</em> is used to define the url used as the server. In this example, the <em>indexAction</em> is used to serve as the Soap server. And to verify the generated <em>WSDL</em> is correct, use your browser and type http://localhost/index/wsdl<strong><span style="text-decoration: underline;">/</span></strong> with the assumption that all Action functions in this example will be coded inside <em>IndexController</em> class. This url should returns with the correct <em>WSDL</em>. Please take note of the url though, that it must end with a backslash &#8216;/&#8217;.</p>
<p>And if browser returns with an error message below.</p>
<pre name="code" class="html">
XML Parsing Error: XML or text declaration not at start of entity
</pre>
<p>Please make sure there isn&#8217;t any trailing spaces before the <em>&lt;?php</em> and after <em>?&gt;</em> in your php file.</p>
<p>Next, we shall look at the code to create your Soap server.</p>
<pre name="code" class="php">
/**
 * Serve as the web service
 */
public function indexAction()
{
  $server = new Zend_Soap_Server( APP_URL . '/index/wsdl/' );
  $server-&gt;setClass( 'Models_Writer' );
  $server-&gt;handle();
  exit;
}
</pre>
<p>The above code instantiates <em>Zend_Soap_Server</em> with the url to the generated <em>WSDL</em> and set the class as <em>Models_Writer</em> and finally quits upon handling the request. Ok, now the <em>indexAction</em> is ready to serve as a Soap server.</p>
<p>Finally, to make sure that the server is handling the request correctly, let&#8217;s create the Soap client that makes a Soap request to the server.</p>
<pre name="code" class="php">
/**
 * Client to request from web service
 */
public function clientAction()
{
  $client = new Zend_Soap_Client( APP_URL . '/index/wsdl/' );
  $response = $client-&gt;write( 'hello world' );
  var_dump( $response );
  exit;
}
</pre>
<p>The above code first instantiates <em>Zend_Soap_Client</em> with the specified url to the <em>WSDL</em>. Line below then calls the function <em>write</em> from the server. Here, you were probably wondering where in the code have we specified the server url. Well, if you recall the previous code when we first created the <em>WSDL</em>, we has actually specified the Soap server url. As a result, Soap client is able to know the server url from the <em>WSDL</em>.</p>
<p>Now try access http://localhost/index/client/, the page should return you with the following line:</p>
<pre name="code" class="html">
string(11) "hello world"
</pre>
<p>Phew! it&#8217;s along explanation for a simple task. My arms are getting cramped now. I hope you are following well with my explanation. If not, well, I have a sample file you can <a href="http://blog.jloe.net/wp-content/uploads/2009/04/jloe-soap.zip">download</a> and test it on your local. I hope it works well. If not, let me know of your encounter.</p>
<p>Well, while experimenting this I have a stumbling block which I managed to find a solution to it. Here goes the encounter.</p>
<p>If you encounter the following error message:</p>
<pre name="code" class="html">
Warning: domdocument::domdocument() expects at least 1 parameter, 0 given in C:wampbinphpphp5.2.8
includesZendSoapWsdl.php on line 94
Fatal error: Call to undefined method domdocument::loadXML() in C:wampbinphpphp5.2.8
includesZendSoapWsdl.php on line 95
</pre>
<p>You need disable <em>php_domxml</em> on your WampServer.</p>
<p>I hope I give enough information. Feel free to give your feedback. If you find this post useful, please help leave your rating below. Thanks! Happy coding! <img src='http://blog.jloe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Source:</p>
<ul>
<li><a target="_blank" href="http://electrotek.wordpress.com/2008/04/19/soap-web-service-with-zend-framework/">SOAP web service with Zend Framework</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/04/23/start-soap-with-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript call ActionScript</title>
		<link>http://blog.jloe.net/2009/04/19/javascript-call-actionscript/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javascript-call-actionscript</link>
		<comments>http://blog.jloe.net/2009/04/19/javascript-call-actionscript/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 16:21:19 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=42</guid>
		<description><![CDATA[Just to share my finding on how to let javascript communicate with actionscript and vice versa. The complete source can be downloaded from <a title="source files" href="http://blog.jloe.net/wp-content/uploads/2009/04/jloe-external-as3.zip">here</a>. However I will highlight some important lines.]]></description>
			<content:encoded><![CDATA[<p>Just to share my finding on how to let javascript communicate with actionscript and vice versa. The complete source can be downloaded from <a title="source files" href="http://blog.jloe.net/wp-content/uploads/2009/04/jloe-external-as3.zip">here</a>. However I will highlight some important lines.</p>
<pre name="code" class="html:firstline[5]">
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
</pre>
<p>Make sure the above lines are inserted within your <code>&lt;head&gt;</code> tags. The script file <code>AC_RunActiveContent.js</code> may be changed depending on where you store the file. The path can be absolute path/url or relative path to your web root folder.</p>
<pre name="code" class="html:firstline[29]">
	var flash_ID = "External_AS3";
</pre>
<p>Next the value of <code>flash_ID</code> must match with your flash ID as defined in line 82. In this example, &#8220;External_AS3&#8243; is defined as the flash ID.</p>
<pre name="code" class="html:firstline[82]">
			'id', 'External_AS3',
</pre>
<p>Well, that&#8217;s all you need to do. Finally, verify using your browser. This sample has been tested working on Firefox, IE7, and Safari.</p>
<p>I hope this post helpful and feel free to feedback for any unsual encounter. Btw, all credits for this script goes to the following <a title="Flash and JavaScript communication" href="http://www.taterboy.com/blog/2008/08/flash-and-javascript-communication/" target="_blank">site</a>. <img src='http://blog.jloe.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/04/19/javascript-call-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to Software Testing</title>
		<link>http://blog.jloe.net/2009/04/17/software-testing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=software-testing</link>
		<comments>http://blog.jloe.net/2009/04/17/software-testing/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 03:39:44 +0000</pubDate>
		<dc:creator>Jonathan Loe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[automated testing]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[manual testing]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[software testing]]></category>
		<category><![CDATA[TADLC]]></category>
		<category><![CDATA[TDLC]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.jloe.net/?p=77</guid>
		<description><![CDATA[Testing, testing, and testing&#8230; this may be a monotonous task to perform as a tester. In software, testing is clearly necessary to deliver a good product or solution to make your clients or bosses pleased and satisfied with the product. As a developer, I have no experience at all hence have no clue where to [...]]]></description>
			<content:encoded><![CDATA[<p>Testing, testing, and testing&#8230; this may be a monotonous task to perform as a tester.</p>
<p>In software, testing is clearly necessary to deliver a good product or solution to make your clients or bosses pleased and satisfied with the product. As a developer, I have no experience at all hence have no clue where to start and how to begin with. So again, I have to use my googling skill to look for some clue out there. Please read on and I hope I can help you understand abit.</p>
<p>First you need to understand the difference between Black box and White box testing. This isn&#8217;t about the colour but rather to the ideology of the testing. Here&#8217;s the definition of Black box testing taken from wiki.</p>
<blockquote><p><a title="Click to read more about black box testing" href="http://en.wikipedia.org/wiki/Black_box_testing" target="_blank"><strong>Black box testing</strong></a> takes an external perspective of the test object to derive test cases. These tests can be functional or non-functional, though usually functional. The test designer selects valid and invalid inputs and determines the correct output. There is no knowledge of the test object&#8217;s internal structure.</p></blockquote>
<p>This means that the purpose of the testing is merely to simplify your testing process by specifying input and expecting some output without any knowledge of the what the function is supposed to do. Think of black box as opaque box or closed box. To help you better understand, i<span class="Text">magine you are testing an electronics system and it is housed in a black box with lights, switches, and dials on the outside. You must test it without opening it up, and you can’t see beyond its surface. You are only able to see if it works just by flipping switches (inputs) and seeing what happens to the lights and dials (outputs).</span> On the other hand,</p>
<blockquote><p><a title="Click to read more about white box testing" href="http://en.wikipedia.org/wiki/White_box_testing" target="_blank"><strong>White box testing</strong></a> uses an internal perspective of the system to design test cases based on internal structure. It requires programming skills to identify all paths through the software. The tester chooses test case inputs to exercise paths through the code and determines the appropriate outputs.</p></blockquote>
<p>People refers white box testing to clear box testing, glass box testing, transparent box testing, translucent box testing or structural testing. <span class="Text">An opposite test approach would be to open up the electronics system, see how the circuits are wired, apply probes internally and maybe even disassemble parts of it.</span> White box testing may also refer as unit testing, integration testing, or system testing.</p>
<p><!--adsense#co-1-->First statement in your mind may be &#8220;Ok, I get it now&#8221; but the question still remains &#8220;How do I test?&#8221;, &#8220;Where should I start?&#8221;. Next what you need to do is to gather your customer&#8217;s requirements and use them to produce your test cases. A <a title="Click to read more about test case" href="http://en.wikipedia.org/wiki/Test_case" target="_blank">test case</a> is a set of conditions or variables under which a tester will determine whether an <span class="mw-redirect">application</span> or software system meets documented specifications or requirements. After the list of test cases are produced, testing is then performed based on the list. To help you with test cases, you may refer to <a title="Click to see samples of test cases" href="http://it.toolbox.com/blogs/enterprise-solutions/sample-of-test-case-creation-17155" target="_blank">this site</a> which provides a good sample of test cases.</p>
<p>There are two approaches in performing your testing: Manual and Automated testing.</p>
<p>Manual testing is is the process of manually testing software for defects. It requires a tester to play the role of an end user, and use most of all features of the application to ensure correct behavior. To ensure completeness of testing, the tester often follows a written test plan that leads them through a set of important test cases.</p>
<p><!--adsense#az-edeal-->Whereas Automated testing is the technique of testing software using software rather than people. A test program is written that exercises the software and identifies its defects. These test programs may be written from scratch, or they may be written utilizing a generic Test automation framework. As it is considered to be a very expensive technique hence it requires careful planning and effective testing strategy as explained in &#8220;<a title="Best Practives in Software Test Automation" href="http://www.testfocus.co.za/featurearticles/july2005.htm" target="_blank">Best Practices in Software Test Automation</a>&#8220;. <a title="What's your test automation strategy?" href="http://blogs.msdn.com/imtesty/archive/2006/05/08/593395.aspx" target="_blank">I.M. Testy</a> also highlights that the goal of automated testing has to be Specific, Measurable, Achievable, Realistic, and Timely (SMART).</p>
<p>If you find this post useful, please leave your rating below. Or if you still have doubt, leave your comment below. Thank you!</p>
<p>Sources:</p>
<ul>
<li><a title="What is black box/white box testing?" href="http://www.faqs.org/faqs/software-eng/testing-faq/section-13.html" target="_blank">What is black box/white box testing?</a></li>
<li><a title="Click to read more about the article" href="http://www.stickyminds.com/sitewide.asp?Function=edetail&amp;ObjectType=COL&amp;ObjectId=2968" target="_blank">Five Ways to Think about Black Box Testing</a></li>
<li><a title="Test Focus" href="http://www.testfocus.co.za/" target="_blank">Test Focus</a>: This site contains some usefull featured articles about testing.</li>
<li><a title="I. M. Testy : What's your test automation strategy?" href="http://blogs.msdn.com/imtesty/archive/2006/05/08/593395.aspx" target="_blank">I. M. Testy : What&#8217;s your test automation strategy?</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.jloe.net/2009/04/17/software-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

