<?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>PHP Made Simple &#187; Prado framework</title>
	<atom:link href="http://www.phpmadesimple.info/category/php/prado-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpmadesimple.info</link>
	<description>To support simplicity, possiibility and cost effective of PHP</description>
	<lastBuildDate>Tue, 03 Aug 2010 14:13:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Writing the Hello world application with Prado</title>
		<link>http://www.phpmadesimple.info/2008/06/26/making-the-hello-world-application-with-prado/</link>
		<comments>http://www.phpmadesimple.info/2008/06/26/making-the-hello-world-application-with-prado/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 09:38:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Prado framework]]></category>
		<category><![CDATA[prado]]></category>

		<guid isPermaLink="false">http://artemis.com.vn/blogvui/index.php/2008/06/26/making-the-hello-world-application-with-prado/</guid>
		<description><![CDATA[Prado PHP framework is a really cool framework, especially for .NET programmers who are looking for solutions in PHP. Prado focus mainly in making things done than doing a single task smartly. But coder won&#8217;t have to worry about quality of their code as Prado classes are written so well already.
I&#8217;ve spent more than one [...]]]></description>
			<content:encoded><![CDATA[<p>Prado PHP framework is a really cool framework, especially for .NET programmers who are looking for solutions in PHP. Prado focus mainly in making things done than doing a single task smartly. But coder won&#8217;t have to worry about quality of their code as Prado classes are written so well already.</p>
<p>I&#8217;ve spent more than one year with Prado, seeing the community grows day by day and people who I am talking too most say Prado is good and somehow, better than Zend framework or widely use CakePHP, Code Igniter.<span id="more-32"></span></p>
<p>As Prado document is not very easy to learn and their tutorials uses SqlLite as the database, most beginners are reluctant to learn it. That&#8217;s why I create this series of Prado training.</p>
<h1>The Prado Hello, world</h1>
<p>In this app, we learn some common .NET concepts in Prado. You should have first LAMP enviroment setup and Prado 3.1.2 (latest version when this article written) downloaded.</p>
<h2>Setup your project</h2>
<p>Extract the /framework folder to your disk as the Prado application need it. I will put it at /www/framework and my appliation will be at /www/hello. This is for reference in the next step.</p>
<p>Create your project folder structure using this command line:</p>
<p><strong>php path/to/prado-cli.php -c hello </strong></p>
<p>Note that you should stand at /www to execute this command so that Prado create the /www/hello folder for you.</p>
<p>prado-cli.php also provides some usefull command-line tool like generating active-record classes from Database. You will see it later.</p>
<h2>Folder structure</h2>
<p>Like any PHP framework, Prado creates the folder structure for your application.</p>
<ul>
<li><strong>protect : </strong>is where code goes in</li>
<li><strong>assets </strong>: Prado resource files created at runtime. Must has chmod 777</li>
<li><strong>protected</strong>/<strong>runtime</strong>: Prado runtime folder contains application state, cache data, etc.</li>
<li><strong>protected</strong>/<strong>pages</strong>: configurable, store all web pages</li>
</ul>
<p>We will look at application.xml deeper in another article but first you need to know that it contains application configurables information.</p>
<p>&lt;service id=&#8221;<strong>page</strong>&#8221; class=&#8221;<strong>TPageService</strong>&#8221; <strong>DefaultPage</strong>=&#8221;<strong>Home</strong>&#8221; BasePath=&#8221;Application.pages&#8221;&gt;<br />
&#8230;<br />
&lt;/service&gt;</p>
<p>This shows some glues to you:</p>
<ul>
<li><strong>BasePath</strong>: point to <strong>protected/pages</strong> folder. Here note that Prado uses . path syntax and &#8216;Application&#8217; is mapped to folder <strong>protected</strong>.</li>
<li><strong>DefaultPage</strong>: Home is the file /protected/pages/Home.page. When you site runs, the URL is<br />
&#8230;/hellow/index.php?<strong>page</strong>=Home. However, the Home page is the default page, you don&#8217;t have to specify page paramenter.</li>
<li>&lt;service&gt; tag is used to register the service to handle user requests. Depend on the <strong>id </strong>value,Prado load the service to handle user request. Here, when the first parameter on the querystring is <strong>page</strong>, Prado load an instand of <strong>TPageService</strong> to handle request.</li>
</ul>
<p>OK, don&#8217;t wanna make you more confused about Prado configuration at this moment. Let&#8217;s go to the page and write some code.</p>
<h1>Event based programming</h1>
<p>Prado application handle user requests by handling the events. This is very similar to .NET web application where you have pages and a page has events such as Init, Load, PreRender, etc. Each controls in the page also has events. When user interacts with control, it will raise the event and you handle that event in the code to response to user request.</p>
<p>You will have to create  Home.php file in protected/pages folder if you don&#8217;t have one. The standard code template for a page class looks like this:</p>
<pre>
<pre class="brush: php">
class Home extends TPage
{
  public function onLoad($param)
  {
  }
}
 </pre>
</pre>
<p>You can see the function OnLoad($param). This is where we write code to initialize the page whenever it&#8217;s requested by users.</p>
<p>Because Prado separates PHP code and HTML template, there must be ways for your code to pass data to your template, here is the Home.page file. Open it and edit the file:</p>
<pre>&lt;html&gt;</pre>
<pre>&lt;body&gt;</pre>
<pre>&lt;com:TForm&gt;</pre>
<pre>  &lt;com:TLabel Id="lblInfo" Text="Hello" /&gt;</pre>
<pre>  &lt;com:TButton Text="Click me" OnClick="buttonClicked" /&gt;</pre>
<pre>&lt;/com:TForm&gt;</pre>
<pre>&lt;/body&gt;</pre>
<pre>&lt;/html&gt;</pre>
<p>You can run your app now and see the Hello text and the button Click me next to it. Click the button and you get an error message. This is normal as we haven&#8217;t declare the <strong>buttonClicked </strong>function to handle click event. Prado is Event based!!!</p>
<p>Our mission is 50% complete as you see the word Hello. Let&#8217;s do the 50% remain.</p>
<p>Add this code below function OnLoad in Home.php file:</p>
<pre class="brush: php">
protected function buttonClickec($sender, $param)
{
$this-&gt;lblInfor-&gt;Text = &#039;Hello, world&#039;;
}
</pre>
<p>Retest the page and you should now see expected result. Easy! isn&#8217;t it.</p>
<p>What we did is creating a function to handle an Prado control event. An event handler needs two params, $sender represents the object which fire the event and $param contains event data. Most of the time, you don&#8217;t care much about $param b/c changed data reflects in the control properties but for some events, you will have to learn what contained in the $param object/array. You have var_dump() and print_r() PHP functions with you, or you have Prado manual as your companion.</p>
<p>Talking about way to pass data from code to template, you can see that we access the label control  whose Id is lblInfo using this syntax: $this-&gt;lblInfo. You can write this because Prado will parse the template file before processing the php file. During this time, Prado creates propeties represents controls in the template.</p>
<p>A Prado control has many properties, Text is a common property for TLabel, TButton and TTextBox. Again, open Prado manual to learn more about Prado standard controls.</p>
<p>That&#8217;s all for a classic application. Now you know how to create a Prado project using prado-cli.php command line tool, see how a page is served and the events raised by a page or a control. In the next article, we will look into some Prado module, work with MySQL database using Prado ActiveRecord, ActiveRecord Scaffolding and SqlMap. We will also take a look at a very powerful control that Prado &#8220;borrows&#8221; from ASP.NET, the Repeater control, to show tabular data.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpmadesimple.info/2008/06/26/making-the-hello-world-application-with-prado/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting started with Prado</title>
		<link>http://www.phpmadesimple.info/2008/01/15/getting-started-with-prado/</link>
		<comments>http://www.phpmadesimple.info/2008/01/15/getting-started-with-prado/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 18:20:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Prado framework]]></category>
		<category><![CDATA[prado]]></category>

		<guid isPermaLink="false">http://artemis.com.vn/blogvui/?p=17</guid>
		<description><![CDATA[Prado is a rapid web application development framework that widely used nowadays by PHP coders. The framework at this moment is 3.1.1 show the maturity and stable. It provide coders with magnificent modules with beautiful ideas applied for MVC model.
The first noticeable thing in Prado is its control set which embrace the ASP.NET model of [...]]]></description>
			<content:encoded><![CDATA[<p>Prado is a rapid web application development framework that widely used nowadays by PHP coders. The framework at this moment is 3.1.1 show the maturity and stable. It provide coders with magnificent modules with beautiful ideas applied for MVC model.</p>
<p>The first noticeable thing in Prado is its control set which embrace the ASP.NET model of code behind. Any kind of HTML form element can be found in Praso as TWebControl object, for example, an HTML textbox is a &lt;com:TTextBox&gt; control. However, Prado even come in advanced compare to ASP.NET when provides &#8216;active&#8217; controls that support Ajax. Prado also support custom control created by coder. Extending TWebControl or TTemplateControl, coders can create composite controls or new web control from scratch.</p>
<p><span id="more-17"></span>Then come Prado master layout which is very similar to ASP.NET master page. You can have many layout and in each page, choose which layout to display data. A default layout can be setup in application.xml file which is a web.config in ASP.NET.</p>
<p>More than just layouts, controls and all templating works, a wonderful idea in Prado is namespace. Namespace helps experience coders to quickly study the framework in a systematical way. By browsing the hierarchical class tree, coders can quickly find out what are the class he should use, what are its methods or properties and what is the parent class it is derived from.</p>
<p>Data manipulation is a pain in many programming model, especially before ORM is invented. While active record is support in ADODB long time ago, Prado support ActiveRecord and SqlMap, a customizable model of ORM. With SqlMap, you can create a custom mapper to map selected data to your class. For example, imagine you have table users and table roles in your DB. An user can have many roles thus in your code, you want to select user and all of the role he has. But how do you map many rows of data into one User object and all his roles into one array property called Roles ? SqlMap helps you do it in an XML file which contains your SQL Select query and the mapper.</p>
<p>Event driven programming is another nice feature that Prado provide. Embracing the model of web controls, Prado can wrap user request to define postback event, changed event to a page. So it is alway to served page is the postback page in a Prado web application. Control states are kept and any change of a control can be handled in its own changed event.</p>
<p>Not stop at that, a powerful configuration system allow you to add more Prado module into the application, such as caching module, multilingual module or user management module. Application wide parameters can also be configured as well as basic authentication based on page and user roles can be configured too, using a config.xml file.</p>
<p>I felt in love with Prado even after Zend framework became stable with version 1.0 release. The feeling is just more confident and stronger while making a website with Prado and taking any Zend component into used. You have a powerful framework to write quick and clean code plus a set of generic, powerful components from Zend framework library. For example, you can easily implement an Access control list in your Prado application with Zend_Acl or getting RSS feeds with Zend_Feed.</p>
<p>Enough for introduction, here are steps to make your first Prado website. You will be surprised how easy it is.</p>
<ol>
<li>Download Prado framework from www.pradosoft.com</li>
<li>Extract folder <strong>framework</strong> into your web directory</li>
<li>Now open command line and go to web root folder which is matched with something like http://localhost<br />
Execute this command to have Prado create folder structure for your first application<br />
php path/to/prado-cli.php -c .</li>
<li>Now open your web browser and go to: http://locahost/first_prado.  You will see the line: Welcome to PRADO! which come from /protected/pages/home.page</li>
<li>Now create a php file home.php in the same home.page folder. Add this code to handle request to page home:
<pre class="brush: php">
class Home extends TPage{
public function onLoad($params)
{
$this-&gt;label1.Text = &#039;Hello, world&#039;;
}
}
</pre>
</li>
<li>If you refresh browser, there will be error as your page has an onLoad event handler which update a TLabel control called &#8216;label1&#8242; while you have not added it to the page.<br />
Edit home.page to add the control:</p>
<pre class="brush: html">
&lt;com :TLabel ID=&quot;label1&quot; /&gt;
</pre>
</li>
<li>Now you can refresh your browser to see how the page is handled.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.phpmadesimple.info/2008/01/15/getting-started-with-prado/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
