


<?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>Learn DooPHP &#187; Milos Kovacki</title>
	<atom:link href="http://learn.doophp.com/author/mil0s/feed/" rel="self" type="application/rss+xml" />
	<link>http://learn.doophp.com</link>
	<description>Learn DooPHP - a high performance MVC based PHP framework</description>
	<lastBuildDate>Thu, 18 Aug 2011 19:47:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Handling sessions without Apache sessions</title>
		<link>http://learn.doophp.com/2010/09/handling-sessions-without-apache-sessions/</link>
		<comments>http://learn.doophp.com/2010/09/handling-sessions-without-apache-sessions/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 16:08:00 +0000</pubDate>
		<dc:creator>Milos Kovacki</dc:creator>
				<category><![CDATA[Demos & Snippets]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://learn.doophp.com/?p=216</guid>
		<description><![CDATA[<p>You are all familiar that Apache sessions are slow and sometimes insecure. In this text I will try to implement way of handling sessions with all Doo::cache mechanisms that are available in DooPhp.<br />
So our sessions will be stored in some of the cache mechanisms. First we will start with writting our session class that will start and end session, we will save it in protected/class folder.<br />
Here is our Session.class</p>
<pre class="brush: php;">
&#60;?php
/**
 * Session handler
 *
 * @author Milos Kovacki &#60;kovacki@gmail.com&#62;
 * @copyright Milos Kovacki 2010 &#60;kovacki@gmail.com&#62;
 */
 class Session
 {

 public static $_sessionId = NULL;
 public static $session = array();

 /**
 * Start session
 */
 public static function startSession() {
 self::$_sessionId = (isset($_COOKIE['session_id']) ? $_COOKIE['session_id'] : NULL);
 if ((!self::$_sessionId)&#124;&#124;(!(self::$session=Doo::cache(Doo::conf()-&#62;sessionCacheType)-&#62;get('session_'.self::$_sessionId)))) {
 // Create new session
 self::$_sessionId = md5($_SERVER['REMOTE_ADDR'] . time() . rand(0,128));
 self::$session['ip'] = $_SERVER['REMOTE_ADDR'];
 self::$session['created'] = time();
 }
 setcookie('session_id', self::$_sessionId, (time()+3600*24*90), '/');
 }

 /**
 * End session
 */
 public static function endSession() {
 $sessionStored = Doo::cache(Doo::conf()-&#62;sessionCacheType)-&#62;set('session_'.self::$_sessionId, self::$session);
 }

 }
</pre>
<p>You all noticed variable  Doo::conf()-&#62;sessionCacheType so we need to add it in our protected/config/common.conf edit it and add:</p>
<pre class="brush: php;">

$config['sessionCacheType'] = 'apc';
</pre>
<p>You can choose any type that is supported in Doo::cache, now we will edit our index.php, here is my bootstrap:</p>
<pre class="brush: php;">

&#60;?php
/**
* BOOTSTRAP
*/
//ini_set('display_errors', 1);
include './protected/config/common.conf.php';
include './protected/config/routes.conf.php';
include $config['BASE_PATH'].'Doo.php';</pre>]]></description>
		<wfw:commentRss>http://learn.doophp.com/2010/09/handling-sessions-without-apache-sessions/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>DooFlashMessenger</title>
		<link>http://learn.doophp.com/2009/11/dooflashmessenger/</link>
		<comments>http://learn.doophp.com/2009/11/dooflashmessenger/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 01:19:24 +0000</pubDate>
		<dc:creator>Milos Kovacki</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://learn.doophp.com/?p=145</guid>
		<description><![CDATA[<p>Hi guys, DooFlashMessenger is here, in this tutorial I will explain you how can you use it with just 3 lines of code. Same thing you have in class comments.</p>
<p>Well lets begin, we start with calling class:</p>
<pre class="brush: php;">
$flash = new DooFlashMessenger();
</pre>
<p>Now we must give access to DooFlashMessenger from view, we do that like this:</p>
<pre class="brush: php;">
DooController::view()-&#62;flashMessenger = $flash;
</pre>
<p>When we can access from view to flashMessenger we can display messages from flashMessenger, we do that with displayMesssages() method.<br />
Here is the code you need to have in your template file:</p>
<pre class="brush: php;">
$flash-&#62;displayMessages();
</pre>
<p>Thats about it, now you just need to add some message to flash messenger, message will be stored in session, with next execution of DooFlashMessenger class messages that are stored in session will be printed with displayMessages() method. Calling displayMessages() method will echo all messages that are stored.</p>
<p>Adding messages to flashMessenger is done by calling method addMessage:</p>
<pre class="brush: php;">
$flash-&#62;addMessage(&#34;This is just test message&#34;);
</pre>
<p>That&#8217;s it if you have any questions please do ask.</p>
]]></description>
		<wfw:commentRss>http://learn.doophp.com/2009/11/dooflashmessenger/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using DooTranslator for translation</title>
		<link>http://learn.doophp.com/2009/10/using-dootranslator-for-translation/</link>
		<comments>http://learn.doophp.com/2009/10/using-dootranslator-for-translation/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 12:05:32 +0000</pubDate>
		<dc:creator>Milos Kovacki</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[easy]]></category>

		<guid isPermaLink="false">http://learn.doophp.com/?p=141</guid>
		<description><![CDATA[<p>DooTranslator finnaly came out, it supports &#8220;<strong>Csv</strong>&#8220;, &#8220;<strong>Gettext</strong>&#8220;, &#8220;<strong>Array</strong>&#8220;, &#8220;<strong>Ini</strong>&#8221; for now, soon it will be implemented other &#8220;file types&#8221;. So for example you have your translation file with this contents:</p>
<p><strong>en.svn</strong></p>
<pre class="brush: php;">
test;&#34;This is just a test!&#34;
</pre>
<p>Lets initialize DooTranslator class:</p>
<pre class="brush: php;">
$translator = Doo::translator('Csv', $this-&#62;_basePath . 'languages/en/LC_MESSAGES/en.csv');
 echo $translator-&#62;translate(&#34;test&#34;);
</pre>
<p>As you can see its very simple, first argument is file type for translation and second is path to the file, third argument can be options array. For Csv you can set options like: delimiter, enclosure and length. Default value for delimiter is &#8220;;&#8221; and for enclosure is &#8220;.</p>
<p>Now we will add some options to our call, lets say we want some other delimiter then &#8220;;&#8221; and we want to add some caching.</p>
<pre class="brush: php;">
$translator = Doo::translator('Csv', $this-&#62;_basePath . 'languages/en/LC_MESSAGES/main.csv', array('cache' =&#62; 'apc', 'delimiter' =&#62; '&#124;'));
</pre>
<p>So now we have added cache mechanism that is &#8220;apc&#8221; and we added delimiter that is &#8220;&#124;&#8221;, now in our en.csv we must change delimiter:</p>
<pre class="brush: php;">
test&#124;&#34;This is just a test!&#34;
</pre>
<p>Supported cache mechanisms are &#8220;apc&#8221;, &#8220;php&#8221;, &#8220;xcache&#8221; and &#8220;eaccelerator&#8221;.</p>
<p>Now lets add placeholders for translate method:</p>
<pre class="brush: php;">
$translator-&#62;translate(&#34;Hello [_1], wellcome to my website!&#34;, array(&#34;John&#34;));
</pre>
<p>This will show translated string with: &#8220;Hello John, wellcome to my website!&#8221;.</p>
<p>Ok thats about it, if you have any questions please do ask, this is simple translation class its still</p>]]></description>
		<wfw:commentRss>http://learn.doophp.com/2009/10/using-dootranslator-for-translation/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>DooMailer learn how to send emails with new DooMailer class</title>
		<link>http://learn.doophp.com/2009/09/doomailer-learn-how-to-send-emails-with-new-doomailer-class/</link>
		<comments>http://learn.doophp.com/2009/09/doomailer-learn-how-to-send-emails-with-new-doomailer-class/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 18:53:38 +0000</pubDate>
		<dc:creator>Milos Kovacki</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://learn.doophp.com/?p=120</guid>
		<description><![CDATA[<p>In this tutorial we will learn to send emails, I just finished first version of DooMailer, it starts with calling DooMailer class:</p>
<pre class="brush: php;">$mail = new DooMailer();</pre>
<p>You can add charset in constructor of DooMailer, default is utf-8.<br />
Everything is pretty easy here is the code:</p>
<pre class="brush: php;">

$mail = new DooMailer();
 $mail-&#62;addTo('yyyyy@yyyyy.yyy');
 $mail-&#62;addTo('xxxx@xxxx.xxx', 'John Smith');
 $mail-&#62;setSubject(&#34;This is test subject!&#34;);
 $mail-&#62;setBodyText(&#34;This is plain text body&#34;);
 $mail-&#62;setBodyHtml(&#34;&#60;b&#62;This is HTML body!&#60;/b&#62;&#34;);
$mail-&#62;addAttachment('/var/web/files/file1.jpg');
 $mail-&#62;addAttachment('/var/web/files/file2.zip');
 $mail-&#62;setFrom('doo@xxxxxxxx.xxx', 'DooPHP ');
 $mail-&#62;send();
</pre>
<p>*** Added new option in setSubject function for forcing encoding of subject:</p>
<pre class="brush: php;">
$mail-&#62;setSubject('subject of mail', true);
</pre>
<p>So as you can see everything is pretty easy, you add to add html body or text body and you can add attachments, when you are adding attachment you just provide link to the file on your website.<br />
And then just do send() it returns true if mail is sent and false if not.</p>
]]></description>
		<wfw:commentRss>http://learn.doophp.com/2009/09/doomailer-learn-how-to-send-emails-with-new-doomailer-class/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Concept of how to work with DooFramework</title>
		<link>http://learn.doophp.com/2009/09/concept-of-how-to-work-with-dooframework/</link>
		<comments>http://learn.doophp.com/2009/09/concept-of-how-to-work-with-dooframework/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 16:36:55 +0000</pubDate>
		<dc:creator>Milos Kovacki</dc:creator>
				<category><![CDATA[Demos & Snippets]]></category>

		<guid isPermaLink="false">http://learn.doophp.com/?p=114</guid>
		<description><![CDATA[<p>Ok in this article I will show you how should you work with DooFramework, when I am making website I like to have one super class that extends DooController class and in constructor of that class I will add all stuff needed for my application, so lets make that class, we should name it for example CoreController <img src='http://learn.doophp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: php;">
&#60;?php

class CoreController extends DooController {

 /**
 * Current URL
 */

 protected static $_currentUrl = null;

 /**
 * Instance of Doo::db
 */

 protected $_db = null;

 /**
 * Translator
 */
 protected $_translate = null;

 /**
 * Instance of Doo::cache
 */

 protected $_cache = null;

 /**
 * Base path of application
 */

 public $_basePath = null;

 /**
 * Instace of DooSession
 */
 public $_session = null;

 /**
 * Instance of DooAcl
 */

 public $_acl = null;

 /**
 * Host
 */

 public $host = null;

 /**
 * Js path
 */

 public  $jsPath = null;

 public function __construct() {
 $this-&#62;_basePath = Doo::conf()-&#62;ROOT_DIR;
 // add some globals that we need
 $this-&#62;_db = Doo::db();
 $this-&#62;_view = DooController::view();
 $this-&#62;host = Doo::conf()-&#62;host;
 $this-&#62;_view-&#62;host = Doo::conf()-&#62;host;
 // ACL
 $this-&#62;_acl = Doo::acl();
 // add sessions
 $this-&#62;_session = Doo::session(&#34;mywebsite&#34;);
 $templateVariables = $this-&#62;getSettings();
 // session
 $this-&#62;_view-&#62;_session = $this-&#62;_session;
 $this-&#62;_cache = Doo::cache('apc');
 $this-&#62;jsPath = $this-&#62;_view-&#62;host . 'static/js/';
 }

 /**
 * Before run method
 */

 public</pre>]]></description>
		<wfw:commentRss>http://learn.doophp.com/2009/09/concept-of-how-to-work-with-dooframework/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>DooForm learn to work with forms</title>
		<link>http://learn.doophp.com/2009/09/dooform-learn-to-work-with-forms/</link>
		<comments>http://learn.doophp.com/2009/09/dooform-learn-to-work-with-forms/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 23:04:24 +0000</pubDate>
		<dc:creator>Milos Kovacki</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[difficult]]></category>
		<category><![CDATA[DooForm]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://learn.doophp.com/?p=107</guid>
		<description><![CDATA[<p>Ok in this tutorial I will show you how do you work with forms, its very simple.<br />
Loading DooForm helper is very easy:</p>
<pre class="brush: php;">
Doo::loadHelper('DooForm');
</pre>
<p>First you create form from array and then just call</p>
<pre class="brush: php;">echo $form-&#62;render();</pre>
<p>To render the form, render function is returning html of the form. So we will begin making one simple element, lets say textfield:</p>
<pre class="brush: php;">$form = new DooForm(array(
    'method' =&#62; 'post',
    'action' =&#62; $action,
    'elements' =&#62; array(
        'username' =&#62; array('text', array(
            'required' =&#62; true,
            'label' =&#62; 'My username: ',
            'attributes' =&#62; array(&#34;style&#34; =&#62; 'border:1px solid #000;', 'class' =&#62; 'username-field'),
            'field-wrapper' =&#62; 'div',
            'validators' =&#62; array(
                array('username',4,7),
                array('maxlength',6,'This is too long'),
                array('minlength',6)
             )
        ))
    )
));</pre>
<p>As you can see all form data you can add into form array, so when you are creating form you will have to define method, action and elements you have in your form, elemnts is another array, that array will contain all form elements. You begin with naming your element and then create array that will describe that element (type, label, validators, field-wrappers, etc&#8230;)</p>
<p>So in element you will have for example:</p>
<pre class="brush: php;">

'username' =&#62; array('text', array(
    'required' =&#62; true,
    'label' =&#62; 'My username: ',
    'attributes' =&#62; array(&#34;style&#34; =&#62; 'border:1px solid #000;', 'class' =&#62; 'mitar'),
    'field-wrapper' =&#62; 'div',
    'validators' =&#62; array(
        array('username',4,7),
        array('maxlength',6,'This is too long'),
        array('minlength',6))
    )
),</pre>
<p>So</p>]]></description>
		<wfw:commentRss>http://learn.doophp.com/2009/09/dooform-learn-to-work-with-forms/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Quick guide to DooSession</title>
		<link>http://learn.doophp.com/2009/09/quick-guide-to-doosession/</link>
		<comments>http://learn.doophp.com/2009/09/quick-guide-to-doosession/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 15:48:35 +0000</pubDate>
		<dc:creator>Milos Kovacki</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://learn.doophp.com/?p=64</guid>
		<description><![CDATA[<p>This will be a quick guide how to use DooSession, first of all you need to call a DooSession class, I love to have one super class that extends DooController class. In super class constructor I make session and create everything I need for a website.</p>
<p>Calling session class needs one parameter and thats namespace name, often you wish to put name for your session.</p>
<pre class="brush: php;">$this-&#62;_application = Doo::session(&#34;mywebsite&#34;);</pre>
<p>Now that you created session namespace you can start using it, storing in session and getting stuff from it. For example you want to define username of user that is registered:</p>
<pre class="brush: php;">$this-&#62;_application-&#62;user = &#34;John&#34;;</pre>
<p>Now you are accessing it from controller with:</p>
<pre class="brush: php;">$this-&#62;_application-&#62;user</pre>
<p>Another nice thing is to have access to session from your view scripts, I am doing it like this, inside constructor of my super class I add:</p>
<pre class="brush: php;">$data['application'] = Doo::session(&#34;mywebsite&#34;);
$this-&#62;renderc('templatefile', $data);</pre>
<p>Now from your view scripts you can access your user variable like:</p>
<pre class="brush: php;">$this-&#62;data['application']-&#62;user</pre>
<p>Thats about it, all functions that you have in doo session class are in API.</p>
<p><a href="http://doophp.com/documentation/api_svn">http://doophp.com/documentation/api_svn</a></p>
]]></description>
		<wfw:commentRss>http://learn.doophp.com/2009/09/quick-guide-to-doosession/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
