<?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>Ngoprek Web &#187; Zend Framework</title>
	<atom:link href="http://www.ngoprekweb.com/tags/zend-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ngoprekweb.com</link>
	<description>We Do Web Things</description>
	<lastBuildDate>Sun, 04 Jul 2010 03:09:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Speedy Alert</title>
		<link>http://www.ngoprekweb.com/2007/08/19/speedy-alert/</link>
		<comments>http://www.ngoprekweb.com/2007/08/19/speedy-alert/#comments</comments>
		<pubDate>Sun, 19 Aug 2007 08:20:03 +0000</pubDate>
		<dc:creator>Eris Ristemena</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ngoprekweb.com/2007/08/19/speedy-alert/</guid>
		<description><![CDATA[  Koneksi Telkom Speedy dipengaruhi ketinggian laut? hmm, nggak ngerti deh bagaimana hubungannya. Tapi itu yang dibilang petugas Telkom saat menginstal Telkom Speedy di rumah saya kemarin. Memang jarak rumah cuma beberapa ratus meter dari pinggir laut. Tapi sejauh ini nggak ada masalah tuh. Dan cukup mengejutkan bagi saya, ternyata koneksinya lumayan cepat, hehe.

Eniwey, kalau [...] ]]></description>
			<content:encoded><![CDATA[ <p>Koneksi Telkom Speedy dipengaruhi ketinggian laut? hmm, nggak ngerti deh bagaimana hubungannya. Tapi itu yang dibilang petugas Telkom saat menginstal Telkom Speedy di rumah saya kemarin. Memang jarak rumah cuma beberapa ratus meter dari pinggir laut. Tapi sejauh ini nggak ada masalah tuh. Dan cukup mengejutkan bagi saya, ternyata koneksinya lumayan cepat, hehe.</p>

<p>Eniwey, kalau anda seperti saya yang nggak pernah berhasil pake Speedy Alert, skrip berikut mungkin berguna untuk memantau penggunaan Speedy. Oya, pakai Zend Framework ya.</p>

<pre>
function getSpeedyUsage($username,$password)
{
  $url = "http://portal.telkomspeedy.com/index.php?flash=-1";

  $client = new Zend_Http_Client($url, array(
    'maxredirects' => 0,
    'timeout'      => 30));
	
  $client->setParameterPost(array(
    'username'       => $username,
    'password'      => $password,
    'login'             => '    Login    '
  ));
	
  $response = $client->request('POST');
  $body = $response->getBody();
	
  $html = str_replace("\n","",$body);
  preg_match_all("|&lt;td class=\"data\"[^&gt;]+>(.*)&lt;/td&gt;|U",$html,$regs);

  $info = array();
  $info['pemakaian']['persen'] 	= $regs[1][1];
  $info['pemakaian']['besar'] 	= $regs[1][3];
  $info['limit'] = $regs[1][4];
  $info['kelebihan'] = $regs[1][5];
	
  return $info;
}
</pre>

<p>Penggunaannya seperti berikut:</p>

<pre>
&lt;?php
require_once 'Zend/Http/Client.php';

/************** ubah di sini **************/
$username = "XXXXXXXXXXXX@telkom.net";
$password = "hewhomustnotbenamed";
/******************************************/

$info = getSpeedyUsage($username,$password);

print_r($info);

?&gt;
</pre>

<p>Keluarannya kurang lebih seperti ini:</p>

<pre>
Array
(
    [pemakaian] => Array
        (
            [persen] => 17,93%
            [besar] => 179,28 MB
        )

    [limit] => 1.000 MB
    [kelebihan] => 0,00 MB
)
</pre> ]]></content:encoded>
			<wfw:commentRss>http://www.ngoprekweb.com/2007/08/19/speedy-alert/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Understanding Zend_Controller (Part I)</title>
		<link>http://www.ngoprekweb.com/2007/07/14/understanding-zend_controller-part-i/</link>
		<comments>http://www.ngoprekweb.com/2007/07/14/understanding-zend_controller-part-i/#comments</comments>
		<pubDate>Sat, 14 Jul 2007 00:02:52 +0000</pubDate>
		<dc:creator>Eris Ristemena</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ngoprekweb.com/2007/07/14/understanding-zend_controller-part-i/</guid>
		<description><![CDATA[  Zend_Controller is the heart of Zend Framework's MVC system. To understand why and how Zend_Controller works you need to have a basic knowledge of MVC. But you'll get more in-depth idea of MVC by starting to write codes anyway.
So, let's start by creating file system layout. Here's my simple layout:

application/
&#160;&#160;controllers/
&#160;&#160;&#160;&#160;IndexController.php
&#160;&#160;&#160;&#160;FooController.php
&#160;&#160;views/
&#160;&#160;&#160;&#160;scripts/
&#160;&#160;&#160;&#160;&#160;&#160;index/
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;index.phtml
&#160;&#160;&#160;&#160;&#160;&#160;foo/
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;bar.phtml
library/
&#160;&#160;Zend/
.htaccess
index.php

To work with Zend_Controller you [...] ]]></description>
			<content:encoded><![CDATA[ <p><a href="http://framework.zend.com/manual/en/zend.controller.html">Zend_Controller</a> is the heart of Zend Framework's <a href="http://en.wikipedia.org/wiki/Model-view-controller">MVC</a> system. To understand why and how Zend_Controller works you need to have a basic knowledge of MVC. But you'll get more in-depth idea of MVC by starting to write codes anyway.</p>
<p>So, let's start by creating file system layout. Here's my simple layout:</p>
<pre>
application/
&nbsp;&nbsp;controllers/
&nbsp;&nbsp;&nbsp;&nbsp;IndexController.php
&nbsp;&nbsp;&nbsp;&nbsp;FooController.php
&nbsp;&nbsp;views/
&nbsp;&nbsp;&nbsp;&nbsp;scripts/
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index/
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index.phtml
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foo/
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bar.phtml
library/
&nbsp;&nbsp;Zend/
.htaccess
index.php
</pre>
<p>To work with Zend_Controller you need to create a rewrite roules in <code>.htaccess</code> file,</p>
<pre>
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
</pre>
<p>I'm assuming that we use Apache mod_rewrite here, you might want to look other configuration for different web server <a href="http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.introduction">here</a>.</p>

<p><code>index.php</code> is our bootstrap file where all requests are routed through. It controls all the workflows. Open up your editor and write this code,</p>
<pre>
&lt;?php
if ( ! defined( "PATH_SEPARATOR" ) ) {
&nbsp;&nbsp;if ( strpos( $_ENV[ "OS" ], "Win" ) !== false )
&nbsp;&nbsp;&nbsp;&nbsp;define( "PATH_SEPARATOR", ";" );
&nbsp;&nbsp;else 
&nbsp;&nbsp;&nbsp;&nbsp;define( "PATH_SEPARATOR", ":" );
}

set_include_path(get_include_path() . PATH_SEPARATOR . "library");

require_once 'Zend/Controller/Front.php';
Zend_Controller_Front::run('application/controllers');
</pre>

<p><code>Zend_Controller_Front::run</code> is a shortcut to tell the controller to search controller files in <code>application/controllers</code> directory for each request and dispatch it.</p>
<p>By default, the first segment of a URL path maps to a controller, and the second to an action. For example, given the URL <code>http://www.example.com/foo/bar</code>, the path is <code>/foo/bar</code>, which will map to the controller <code>foo</code> and the action <code>bar</code>. If no action is provided, the action <code>index</code> is assumed, and if no controller is provided, the controller <code>index</code> is assumed (following the Apache convention that maps a DirectoryIndex  automatically).</p>
<p>So, <code>http://www.example.com/foo</code> will map to the controller <code>foo</code> and the action <code>index</code>. While <code>http://www.example.com</code> will map to the controller <code>index</code> and the action <code>index</code>.</p>
<p>By default, the controller files reside on the directory which we declared in <code>Zend_Controller_Front::run</code> method. The file name use the the controller name with uppercase on the first letter added with <code>Controller</code> words. For example, URL <code>http://www.example.com/foo</code> will search <code>FooController.php</code> in <code>application/controllers</code> directory. While <code>http://www.example.com</code> will search <code>IndexController.php</code>.</p>
<p>The next step is to write the action controller, the actual code for handling the request. First, let's open up <code>application/controllers/IndexController.php</code> and enter the following,</p>
<pre>
&lt;?php
require_once 'Zend/Controller/Action.php';

class IndexController extends Zend_Controller_Action
{
&nbsp;&nbsp;public function indexAction()
&nbsp;&nbsp;{
&nbsp;&nbsp;}
}
</pre>
<p>As you might suspect, <code>indexAction</code> method is the action controller, where executed for index action, i.e where the URL is <code>http://www.example.com</code></p>
<p>Similarly, you can handle URL <code>http://www.example.com/foo/bar</code> by writing this code into <code>application/controllers/FooController.php</code>,</p>
<pre>
&lt;?php
require_once 'Zend/Controller/Action.php';

class FooController extends Zend_Controller_Action
{
&nbsp;&nbsp;public function barAction()
&nbsp;&nbsp;{
&nbsp;&nbsp;}
}
</pre>
<p>Now, if you access <code>http://www.example.com/foo/bar</code> you'll get,</p>
<pre>
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in ...
</pre>
<p>Good, don't worry about the error. It tells you that you're missing something. But before we get to that, it is a good practice to write a controller to handle such errors. By default, Zend_Controller will execute <code>errorAction()</code> method in <code>ErrorController.php</code> when it can't find the appropriate controller files or when something is wrong. So open up <code>application/controllers/ErrorController.php</code> and write the following,</p>
<pre>
&lt;?php
require_once 'Zend/Controller/Action.php';

class ErrorController extends Zend_Controller_Action
{
&nbsp;&nbsp;public function errorAction()
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;die("An error occurred; please try again later.");
&nbsp;&nbsp;}
}
</pre>
<p>Now, if you access URL like this <code>http://www.example.com/none/nothing</code>, you'll get,</p>
<pre>
An error occurred; please try again later.
</pre>
<p>No, you can't treat this as 404 Not Found like. Because it's executed not only when the controller can not be found, but also when there's something missing in your codes. For example when you forget the view parts.</p>
<p>Right, by default <a href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.viewrenderer">ViewRenderer </a> action helper is enabled. What this means is that by simply defining an action method and a corresponding view script, you will immediately get content rendered. By default, <a href="http://framework.zend.com/manual/en/zend.view.html">Zend_View</a> is used as the View layer in the MVC. The ViewRenderer does some magic, and uses the controller name (e.g., <code>foo</code>) and the current action name (e.g., <code>bar</code>) to determine what template to pull. By default, templates end in the .phtml extension, so this means that, <code>http://www.example.com/foo/bar</code> will render the template in <code>views/scripts/foo/bar.phtml</code>.</p>
<p>So, let's open up <code>views/scripts/foo/bar.phtml</code> file and write the following templates,</p>
<pre>
&lt;!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;My first Zend Framework App&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;p&gt;You say foo bar!&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>And now you can view your site <code>http://www.example.com/foo/bar</code>, yes it says</p>
<pre>
You say foo bar!
</pre>
<p>Great!</p>
<p>That's it. Now you have the basic concept of how Zend_Controller works. As you might notice, i say "by default" many times, this is because you can change the way it works according to your needs. All by extending the abstract and interface class. We'll talk more about this on later post.</p> ]]></content:encoded>
			<wfw:commentRss>http://www.ngoprekweb.com/2007/07/14/understanding-zend_controller-part-i/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Setting Up Zend Framework</title>
		<link>http://www.ngoprekweb.com/2007/07/12/setting-up-zend-framework/</link>
		<comments>http://www.ngoprekweb.com/2007/07/12/setting-up-zend-framework/#comments</comments>
		<pubDate>Thu, 12 Jul 2007 00:40:12 +0000</pubDate>
		<dc:creator>Eris Ristemena</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ngoprekweb.com/2007/07/12/setting-up-zend-framework/</guid>
		<description><![CDATA[  I still see some people having a hard time using Zend Framework, so i'll share some of my experience using ZF. Hope this will help.
Let's start with the easy and basic one, setting up ZF. There's two simple way of doing this:
First, download the latest stable release here. It's available in both .zip and [...] ]]></description>
			<content:encoded><![CDATA[ <p>I still see some people having a hard time using <a href="http://framework.zend.com">Zend Framework</a>, so i'll share some of my experience using ZF. Hope this will help.</p>
<p>Let's start with the easy and basic one, setting up ZF. There's two simple way of doing this:</p>
<p>First, <a href="http://framework.zend.com/download/stable">download the latest stable release here</a>. It's available in both <code>.zip</code> and <code>.tar.gz</code> formats. Extract the files.</p>
<p>Second, once you have a copy of the ZF available, your application needs to be able to access the framework classes (in <code>library/Zend</code> folder). There are <a href="http://www.php.net/manual/en/configuration.changes.php">several ways</a> to do this, but assuming you don't have control over PHP configuration in your server all you need to do is using <a href="http://www.php.net/set_include_path">set_include_path</a> function to include the ZF classes.</p>
<p>If you're using Linux,</p>
<pre>
set_include_path(get_include_path().":library");
</pre>
<p>or in Windows,</p>
<pre>
set_include_path(get_include_path().";library");
</pre>
<p>or you can make your apps compatible with both OS, by determining the path separator, like this:</p>
<pre>
if ( ! defined( "PATH_SEPARATOR" ) ) {
&nbsp;&nbsp;if ( strpos( $_ENV[ "OS" ], "Win" ) !== false )
&nbsp;&nbsp;&nbsp;&nbsp;define( "PATH_SEPARATOR", ";" );
&nbsp;&nbsp;else 
&nbsp;&nbsp;&nbsp;&nbsp;define( "PATH_SEPARATOR", ":" );
}

set_include_path(get_include_path() . PATH_SEPARATOR . "library");
</pre>
<p>That's it, you're set to go.</p> ]]></content:encoded>
			<wfw:commentRss>http://www.ngoprekweb.com/2007/07/12/setting-up-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
