<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-8656346749704430235</atom:id><lastBuildDate>Tue, 19 Mar 2024 03:09:39 +0000</lastBuildDate><category>symfony</category><category>Classes and Objects</category><category>connecting php with mysql</category><category>forms</category><category>installing symfony</category><category>media streaming</category><category>mysql storage engines</category><category>php mvc framework</category><category>php performance tuning</category><category>real time web</category><category>ror</category><category>ruby</category><category>symfony cli</category><category>using static variables</category><category>xmpp</category><title>PHP Crat</title><description></description><link>http://phpcrat.blogspot.com/</link><managingEditor>noreply@blogger.com (anton)</managingEditor><generator>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-574696147236809273</guid><pubDate>Sun, 23 Jan 2011 13:38:00 +0000</pubDate><atom:updated>2011-01-23T06:10:48.627-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">media streaming</category><title>Realtime Media Streaming Applicaions on the Web</title><description>For a long time, streaming media contents on the web seems to be more expensive as it challenges over the bandwidth and server cost. There are few comparable number of media streaming servers are available, and to name a few of them: &lt;a href=&quot;http://www.adobe.com/products/flashmediaserver&quot;&gt;FMS&lt;/a&gt;(Flash Media Server) from Adobe, &lt;a href=&quot;http://www.wowzamedia.com/&quot;&gt;Wowza,&lt;/a&gt; &lt;a href=&quot;http://red5.org/&quot;&gt;Red5&lt;/a&gt;(Open source) (&lt;a href=&quot;http://askmeflash.com/article/10/comparison-wowza-vs-fms-vs-red5&quot;&gt;See comparisons&lt;/a&gt;) and &lt;a href=&quot;http://erlyvideo.org/&quot;&gt;Erlyvideo&lt;/a&gt;. The recent version of FMS(&lt;a href=&quot;http://sonnati.wordpress.com/2010/09/09/adobe-announces-fms4/&quot;&gt;FMS4&lt;/a&gt;) supports multi-cast with P2P streaming, which eliminate the need of costly servers and bandwidth cost(but still available only as a beta service with limited access through developer API key).&lt;br /&gt;
&lt;br /&gt;
Streaming media contents like static images and video are also a bit complicated with mostly used general web servers like Apache, when comparing with response time. And hence it is also required to identify special purpose web servers to increase the response time while serving these static contents. Few web servers like &lt;a href=&quot;http://www.lighttpd.net/&quot;&gt;Lighttpd &lt;/a&gt;and &lt;a href=&quot;http://nginx.org/&quot;&gt;NginX &lt;/a&gt;are notable web servers which performs quite better in serving static contents. The popular rich content serving websites like Youtube and Wikipedia are using NginEx to serve their images and video contents.&lt;br /&gt;
&lt;br /&gt;
Cisco&#39;s &lt;a href=&quot;http://www.webex.com/&quot;&gt;WebEx &lt;/a&gt;provides an excellent platform to integrate their online meeting center with any web applications. WebEx&#39;s integrated meeting center is a licensed cloud solution to facilitate both one-to-one and multi-cast video/audio conferencing system with all required meeting components like desktop sharing, chatting, tele-conferencing and shared whiteboard. WebEx&#39;s recordng feature is doing an excellent stuff as it&#39;s capability to record the complete meeting activity in a single playback stream.</description><link>http://phpcrat.blogspot.com/2011/01/realtime-media-streaming-applicaions-on.html</link><author>noreply@blogger.com (anton)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-3016440170577068099</guid><pubDate>Sun, 09 Jan 2011 17:43:00 +0000</pubDate><atom:updated>2011-01-17T10:52:55.331-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ror</category><category domain="http://www.blogger.com/atom/ns#">ruby</category><title>Ruby On Rail (RoR) - the De-Facto for Enterprise Application Development Platform</title><description>&lt;b&gt;Ruby&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Ruby is a dynamic, reflective, general purpose object-oriented programming language with a super clean syntax that makes programming elegant and fun. It combines Smalltalk&#39;s conceptual elegance with Python&#39;s ease of use and learning, and Perl&#39;s pragmatism. &lt;br /&gt;
&lt;br /&gt;
It&#39;s language design said to be follow the principle of least astonishment(POLA), which means it minimize the confusion for experienced users.&lt;br /&gt;
&lt;br /&gt;
Ruby was originally designed by Yukihiro Matsumoto in 1993 and the first version has released on December 25, 1996.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Rails&lt;/b&gt; (The Framework for Ruby)&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Less software&lt;/u&gt;&lt;br /&gt;
Less software means you write fewer lines of code to implement your application. Keeping the code small means faster development and fewer bugs, which makes the code easier to understand, maintain, and enhance. In contrast, you will see how Rails cuts your code burden.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Convention over configuration&lt;/u&gt;&lt;br /&gt;
Ruby on Rails uses the Model-View-Controller (MVC) architecture pattern to organize application programming. Rails seemed to make everything easier, with its Convention Over Configuration and Don&#39;t Repeat Yourself principles(DRY). Convention over configuration means an end to verbose XML configuration files; -there aren&#39;t any in Rails! Instead of configuration files, a Rails application uses a few simple programming conventions that allow it to figure out everything through reflection and discovery.&lt;br /&gt;
&lt;br /&gt;
The key factors to be considered on enterprise web application development&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Scaling and Performance&lt;/li&gt;
&lt;li&gt;Development Speed&lt;/li&gt;
&lt;li&gt;Development Tools&lt;/li&gt;
&lt;li&gt;Maintainability&lt;/li&gt;
&lt;/ul&gt;The Rail&#39;s Hot-Spots&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Standardized project layout,&lt;/li&gt;
&lt;li&gt;Scaffolding and generators,&lt;/li&gt;
&lt;li&gt;MVC framework, &lt;/li&gt;
&lt;li&gt;ActiveRecord&lt;/li&gt;
&lt;li&gt;Web forms and Form helpers&lt;/li&gt;
&lt;li&gt;Custom Routing&lt;/li&gt;
&lt;li&gt;I/O filters&lt;/li&gt;
&lt;li&gt;Plugins&lt;/li&gt;
&lt;li&gt;Rail&#39;s CLI Rake tasks&lt;/li&gt;
&lt;li&gt;HAML&lt;/li&gt;
&lt;li&gt;Capistrano&lt;/li&gt;
&lt;/ul&gt;With JRuby/Warbler, Rails can be run on Java Application Servers. Learning RoR would be much easier than JSP / Struts / Spring / Hibernate. Rails has built in support for the idea of having a different set of settings for Development, Test and Production.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Web Servers&lt;/b&gt;&lt;br /&gt;
Applications built on RoR can be run on web servers like Mongrel, WEBrick. But it can also be run on many other web servers(as a module - Passenger for example - or via CGI, FastCGI or mod_ruby) such as Lighttpd, Abyss, Apache, nginx and many others. More recently, the Passenger web servers replaced Mongrel as the most used web server.&lt;br /&gt;
&lt;br /&gt;
A few case studies to compare RoR&#39;s capabilities: Twitter, Scribd, Hulu, Blinksale, Crunchbase, Slideshare, Medhelp, Github, Jobster.</description><link>http://phpcrat.blogspot.com/2011/01/ruby-on-rail-ror-de-facto-for.html</link><author>noreply@blogger.com (anton)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-8067441151986330306</guid><pubDate>Sat, 25 Dec 2010 19:01:00 +0000</pubDate><atom:updated>2010-12-25T12:08:00.759-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">real time web</category><category domain="http://www.blogger.com/atom/ns#">xmpp</category><title>Building real time web applications with XMPP</title><description>Ajax has been used on the web for a long, to make the web pages updates their content instantly without reloading the page again and again. But the fall back is to make the page poll to the server every time for new updates. The possibility that the server may encounter unnecessary request overhead, if at all there are no new content updates from the server.&lt;br /&gt;
&lt;br /&gt;
The term Comet, Reverse Ajax, Ajax Push, are coined to take up advantage using the content push or content streaming technology on the web pages. Although web-sockets are another similar technology, but challenged with the &lt;a href=&quot;http://en.wikipedia.org/wiki/WebSockets#Browsers_supporting_WebSocket&quot;&gt;browser compatibility&lt;/a&gt; and &lt;a href=&quot;http://hacks.mozilla.org/2010/12/websockets-disabled-in-firefox-4/&quot;&gt;security issues&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The XMPP(Extensible Messaging and Presence Protocol) is an open technology for real-time communication. This XMPP candidate seem to be the more appropriate contender in implementing Comet, Ajax push or Content streaming on the web. There are a plenty of of XMPP Client implementation are curently available for most of the platforms including javascript, php, python, flex and etc. I thrilled to see the javascript implementation &lt;a href=&quot;http://xmpp4js.sourceforge.net/&quot;&gt;xmpp4js&lt;/a&gt;, and it works fantastic on cross-browser.&lt;br /&gt;
&lt;br /&gt;
I did an experiment with &lt;a href=&quot;http://www.igniterealtime.org/projects/openfire/&quot;&gt;Openfire xmpp server&lt;/a&gt; and apache/nginx, with both javascript and php xmpp client(&lt;a href=&quot;http://code.google.com/p/xmpphp/&quot;&gt;xmppphp&lt;/a&gt;) implementations. It seems promising, that more web apps to come with these kind of Ajax-Push and Real-time http content streaming technologies.</description><link>http://phpcrat.blogspot.com/2010/12/building-real-time-web-applications.html</link><author>noreply@blogger.com (anton)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-8278593819233563949</guid><pubDate>Sat, 26 Sep 2009 14:51:00 +0000</pubDate><atom:updated>2009-09-26T08:52:56.306-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">php performance tuning</category><category domain="http://www.blogger.com/atom/ns#">using static variables</category><title>PHP5 - Performance tuning using static variables</title><description>In general, the php static variables would hold the value, which has been set by a last known action.&lt;br /&gt;&lt;br /&gt;Since the static variables are not just bound within a scope of an object or an instance, and rather these variable&#39;s can be accessed within a global context by the use of Scope Resolution Operator(::) instead of access using objects.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Problem&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Say, if you have a table in the database called &quot;config&quot; and it holds all basic configurations required to your website. Your code will make a repeated call in every routines to refer these configurations. And now the problem occurring is the necessity to fire query to db each time, when trying to refer the configurations.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Solution&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If we can able to cache the variable in a global context, the unnecessary query overhead to the database can be minimized.&lt;br /&gt;&lt;br /&gt;Whenever a query has been fired to the config table, cache the return value and assign it to a static variable. If the static variable has some values already exists, do not query again the database; instead, use the value in the static variable.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Example&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&amp;lt;?php&lt;br /&gt;class Config{&lt;br /&gt;public static $arrConfigData;&lt;br /&gt;public function getSetting($settingName){&lt;br /&gt;&lt;br /&gt;    if(isset(self::$arrConfigData[$settingName]) &amp;amp;&amp;amp; !empty(self::$arrConfigData[$settingName])){&lt;br /&gt;        return self::$arrConfigData[$settingName];&lt;br /&gt;    }else{&lt;br /&gt;        //..Write sql&#39;s to retreive the value of the requested setting and assign it to as $retVal&lt;br /&gt;        $retVal = $dbResultVal;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    //Assign back value to static variable&lt;br /&gt;    self::$arrConfigData[$settingName] = $retVal;&lt;br /&gt;    return $retVal;   &lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//Calling the method:&lt;br /&gt;$objConfig = new Config();&lt;br /&gt;$objConfig-&gt;getSetting(&#39;setting1&#39;);&lt;br /&gt;$objConfig-&gt;getSetting(&#39;setting1&#39;);&lt;br /&gt;$objConfig-&gt;getSetting(&#39;setting1&#39;);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;Now, even though you have actually making multiple call to the same setting, the db will get accessed only once. For each other tries, it will simply refer the data from the static variable itself; and thus reducing the overhead to the database. Note that, this is the same way as the normal singleton objects works.</description><link>http://phpcrat.blogspot.com/2009/09/php5-performance-tuning-using-static.html</link><author>noreply@blogger.com (anton)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-8532509694213960552</guid><pubDate>Fri, 21 Aug 2009 18:50:00 +0000</pubDate><atom:updated>2009-08-21T12:16:43.570-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">forms</category><title>Customization and Internalization of Symfony-Doctrine Forms</title><description>In general we create a doctrine schema from the database by using the following command&lt;br /&gt;c:\xampp\htdocs\testproject\&gt; symfony doctrine:build-schema&lt;br /&gt;&lt;br /&gt;To build forms which are associated with the database, we have to run the following command&lt;br /&gt;c:\xampp\htdocs\testproject\&gt; symfony doctrine:build-forms&lt;br /&gt;&lt;br /&gt;The next step after built the forms, we can configure and customize the form labels, widgets, error-texts, and help-texts&lt;br /&gt;&lt;br /&gt;The default function configure() will work for all common customization required for a form. The below are the symfony functions used to customize the forms.&lt;br /&gt;&lt;br /&gt;To assign custom label to form field:&lt;br /&gt;$this-&gt;widgetSchema-&gt;setLabel(&#39;firstname&#39;, &#39;Enter your first name&#39;);&lt;br /&gt;&lt;br /&gt;To assign help text to form field:&lt;br /&gt;$this-&gt;widgetSchema-&gt;setHelp(&#39;firstname&#39;,&#39;Provide your first name&#39;);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 153);font-size:130%;&quot; &gt;Rendering forms in template:&lt;/span&gt;&lt;br /&gt;To render a form input field with custom style:&lt;br /&gt;echo $form[&#39;firstname&#39;]-&gt;render(array(&#39;style&#39;=&gt;&#39;mystyle&#39;, &#39;id&#39;=&gt;&#39;field id&#39;));&lt;br /&gt;&lt;br /&gt;To render a label of the form input field with custom style:&lt;br /&gt;echo $form[&#39;firstname&#39;]-&gt;renderLabel(array(&#39;style&#39;=&gt;&#39;mystyle&#39;, &#39;id&#39;=&gt;&#39;field id&#39;));&lt;br /&gt;&lt;br /&gt;To render a error string for a form input field with custom style:&lt;br /&gt;echo $form[&#39;firstname&#39;]-&gt;renderError(array(&#39;style&#39;=&gt;&#39;mystyle&#39;, &#39;id&#39;=&gt;&#39;field id&#39;));&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 153);font-size:130%;&quot; &gt;&lt;br /&gt;Displaying errors in template:&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php if ($sf_request-&amp;lt;hasError()): ?&amp;gt;&lt;br /&gt;  &amp;lt;ul class=&quot;error_list&quot;&amp;gt;&lt;br /&gt;    &amp;lt;?php foreach ($sf_request-&amp;gt;getError() as $error): ?&amp;gt;&lt;br /&gt;      &amp;lt;li&amp;gt;&amp;lt;?php echo $error ?&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;    &amp;lt;?php endforeach; ?&amp;gt;&lt;br /&gt;  &amp;lt;/ul&amp;gt;&lt;br /&gt;&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Display help text of a form in template:&lt;br /&gt;$form-&gt;getWidgetSchema()-&gt;getHelp(&#39;firstname&#39;);&lt;br /&gt;&lt;br /&gt;To apply a translation scheme to the form:&lt;br /&gt;$this-&gt;widgetSchema-&gt;getFormFormatter()-&gt;setTranslationCatalogue(&#39;catalog&#39;);&lt;br /&gt;&lt;br /&gt;firstname.[language].xml&lt;br /&gt;&lt;br /&gt;Sample XLIFF file &#39;catalog.fr.xml&#39; placed in apps/applicationName/i18n/firstname.fr.xml&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?xml version=&quot;1.0&quot; ?&amp;gt;&lt;br /&gt;&amp;lt;xliff version=&quot;1.0&quot;&amp;gt;&lt;br /&gt;  &amp;lt;file original=&quot;global&quot; language=&quot;en&quot; datatype=&quot;plaintext&quot;&amp;gt;&lt;br /&gt;    &amp;lt;body&amp;gt;&lt;br /&gt;      &amp;lt;trans-unit&amp;gt;&lt;br /&gt;        &amp;lt;source&amp;gt;Name&amp;lt;/source&amp;gt;&lt;br /&gt;        &amp;lt;target&amp;gt;Nom&amp;lt;/target&amp;gt;&lt;br /&gt;      &amp;lt;/trans-unit&amp;gt;&lt;br /&gt;      &amp;lt;trans-unit&amp;gt;&lt;br /&gt;        &amp;lt;source&amp;gt;Email address&amp;lt;/source&amp;gt;&lt;br /&gt;        &amp;lt;target&amp;gt;Adresse email&amp;lt;/target&amp;gt;&lt;br /&gt;      &amp;lt;/trans-unit&amp;gt;&lt;br /&gt;      &amp;lt;trans-unit&amp;gt;&lt;br /&gt;        &amp;lt;source&amp;gt;Body&amp;lt;/source&amp;gt;&lt;br /&gt;        &amp;lt;target&amp;gt;Message&amp;lt;/target&amp;gt;&lt;br /&gt;      &amp;lt;/trans-unit&amp;gt;&lt;br /&gt;    &amp;lt;/body&amp;gt;&lt;br /&gt;  &amp;lt;/file&amp;gt;&lt;br /&gt;&amp;lt;/xliff&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;To get user-submited-form data in action:&lt;br /&gt;$this-&gt;getRequestParameter($elementName)&lt;br /&gt;&lt;br /&gt;To get all posted data as array&lt;br /&gt;$request-&gt;getPostParameters();&lt;br /&gt;&lt;br /&gt;To get all post and get data as array&lt;br /&gt;$this-&gt;getRequest()-&gt;getParameterHolder()-&gt;getAll();&lt;br /&gt;&lt;br /&gt;Custom validators in action file:&lt;br /&gt; public function validateActionname(){&lt;br /&gt;    if(validation successful){&lt;br /&gt;        return true;&lt;br /&gt;    }else{&lt;br /&gt;        return false;&lt;br /&gt;    }   &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 153);font-size:130%;&quot; &gt;Form validation using YAML files&lt;/span&gt;:&lt;br /&gt;create actionname.yml under validate/ folder of the module. And define validation schema for necessary fields as below:&lt;br /&gt;&lt;br /&gt;fields:&lt;br /&gt;  &amp;nbsp;&amp;nbsp;name:&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;required:&lt;br /&gt;      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;msg:       The name field cannot be left blank&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sfStringValidator:&lt;br /&gt;      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;min:       2&lt;br /&gt;      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;min_error: This name is too short (2 characters minimum)&lt;br /&gt;      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;max:       100&lt;br /&gt;      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;max_error: This name is too long. (100 characters maximum)&lt;br /&gt;&lt;br /&gt;Form data re-population if validation fails:&lt;br /&gt;Specify your validation YAMAL file also the fillin feature as below:&lt;br /&gt;&lt;br /&gt;fillin:&lt;br /&gt;  &amp;nbsp;&amp;nbsp;enabled: true  # Enable the form repopulation&lt;br /&gt;  &amp;nbsp;&amp;nbsp;param:&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name: test  # Form name, not needed if there is only one form in the page&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;skip_fields:   [email]  # Do not repopulate these fields&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;exclude_types: [hidden, password] # Do not repopulate these field types&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;check_types:   [text, checkbox, radio, select, hidden] # Do repopulate these&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;content_type:  html  # html is the tolerant default. Other option is xml an&lt;br /&gt;&lt;br /&gt;Note: Any changes on the yml files, requires &#39;clearing the symfony cache&#39;, to reflect changes to the application.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.symfony-project.org/blog/2008/06/18/the-symfony-forms-in-action-book-is-online&quot;&gt;more details..&lt;/a&gt;</description><link>http://phpcrat.blogspot.com/2009/08/customization-and-internalization-of.html</link><author>noreply@blogger.com (anton)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-4494811714137050394</guid><pubDate>Sun, 26 Jul 2009 08:24:00 +0000</pubDate><atom:updated>2009-07-26T11:04:30.424-07:00</atom:updated><title>Sending e-mail/SMTP e-mails using sfMail addon from Symfony framework</title><description>Finally I was able to send emails in my recent pet-project using sfMail. Simply Amazing!&lt;h2&gt;1. Creating templates for your emails&lt;/h2&gt;Create a separate module to create our e-mail templates for sending mails. In this tutorial we create a module &quot;mailTemplate&quot; to generate all email-templates. To create the module run the below command at command line:&lt;br /&gt;&lt;br /&gt;c:\xampp\htdocs\myproject\&amp;gt; symfony generate:module frontend mailTemplate&lt;br /&gt;&lt;br /&gt;-here myproject is your project directory&lt;br /&gt;-frontend is your application name, which you already created&lt;br /&gt;-mailTemplate is the new module we create.&lt;h2&gt;Configuring view layer for the mail-templates&lt;/h2&gt;To configure the mailTemplate module to use the &#39;sfMailView&#39; to generate templates for the e-mail presentation, create module.yml file under the &#39;config&#39; directory under the directory mailTemplate. So it will be looks like for our project:&lt;br /&gt;&lt;br /&gt;..\myproject\apps\frontend\modules\mailTemplate\config\module.yml&lt;br /&gt;&lt;br /&gt;The configuration for accessing the special mail view layer is as below:&lt;br /&gt;(&lt;a href=&quot;http://antorobin.googlepages.com/module.yml&quot; target=&quot;_new&quot;&gt;download the module.yml file used in this tutorial&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;all:&lt;br /&gt;&amp;nbsp;&amp;nbsp;view_class:    sfMail&lt;h2&gt;Securing the mailtemplates from accessing outside&lt;/h2&gt;To secure our mail templates from accesing outside, the configuration in the module.yml is as below:&lt;br /&gt;&lt;br /&gt;all:&lt;br /&gt;&amp;nbsp;&amp;nbsp;is_internal:    on&lt;br /&gt;&lt;br /&gt;So now our final module file will look like,&lt;br /&gt;(&lt;a href=&quot;http://antorobin.googlepages.com/module.yml&quot; target=&quot;_new&quot;&gt;download the module.yml file used in this tutorial&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;all:&lt;br /&gt;&amp;nbsp;&amp;nbsp;view_class:    sfMail&lt;br /&gt;&amp;nbsp;&amp;nbsp;is_internal:    on&lt;h2&gt;2. Configuring the mailer&lt;/h2&gt;sfMail is simple, but a powerfull symfony addon built on top of phpMailer. sfMail will will look for it&#39;s configurations under your mailTemplate module. So we need to create a file mailer.yml and put in the config directory under the mailTemplate folder. So the file path will looks like as below:&lt;br /&gt;&lt;br /&gt;..\myproject\apps\frontend\modules\mailTemplate\config\mailer.yml&lt;br /&gt;&lt;br /&gt;See below the e-mail configured for sending smtp e-mails:&lt;br /&gt;(&lt;a href=&quot;http://antorobin.googlepages.com/mailer.yml&quot; target=&quot;_new&quot;&gt;download the mailer.yml file used in this tutorial&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;default:&lt;br /&gt;&amp;nbsp;&amp;nbsp;deliver:           on&lt;br /&gt;&amp;nbsp;&amp;nbsp;mailer:            smtp&lt;br /&gt;&amp;nbsp;&amp;nbsp;domain:          localhost.localdomain&lt;br /&gt;&amp;nbsp;&amp;nbsp;hostname:      smtpHostname&lt;br /&gt;&amp;nbsp;&amp;nbsp;port:                25&lt;br /&gt;&amp;nbsp;&amp;nbsp;username:      smtpUsername&lt;br /&gt;&amp;nbsp;&amp;nbsp;password:       smtpPassword&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;wordwrap:      80&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;.headers:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;priority:        3&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;content_type:    text/plain&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;charset:         utf-8&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;encoding:       8bit&lt;h2&gt;3. Creating a sample mail template&lt;/h2&gt;&lt;h2&gt;The action class&lt;/h2&gt;..\myproject\apps\frontend\modules\mailTemplate\actions\actions.class.php&lt;br /&gt;&lt;br /&gt;(&lt;a href=&quot;http://antorobin.googlepages.com/mailTemplate.zip&quot; target=&quot;_new&quot;&gt;download the actions.class.php file used in this tutorial&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * mailTemplate actions.&lt;br /&gt; *&lt;br /&gt; * @package    sfd&lt;br /&gt; * @subpackage mailTemplate&lt;br /&gt; * @author     Your name here&lt;br /&gt; * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $&lt;br /&gt; */&lt;br /&gt;class mailTemplateActions extends sfActions&lt;br /&gt;{&lt;br /&gt; /**&lt;br /&gt;  * Executes index action&lt;br /&gt;  *&lt;br /&gt;  * @param sfRequest $request A request object&lt;br /&gt;  */&lt;br /&gt;  public function executeGetSampleTemplate(sfWebRequest $request)&lt;br /&gt;  {&lt;br /&gt;    //Get the receipient email set in the calling action&lt;br /&gt;    $recepientEmail = $this-&amp;gt;getRequest()-&amp;gt;getAttribute(&#39;recepientEmail&#39;);&lt;br /&gt;&lt;br /&gt;    $objMail = new sfMail();&lt;br /&gt;    $objMail-&amp;gt;addAddress($recepientEmail);&lt;br /&gt;    $objMail-&amp;gt;setFrom(&#39;Marshal Anto Robin &amp;lt;antorobin@gmail.com&amp;gt;&#39;);&lt;br /&gt;    $objMail-&amp;gt;setSubject(&#39;Symfony sample sfmail test&#39;);&lt;br /&gt;    $objMail-&amp;gt;setPriority(1);&lt;br /&gt;&lt;br /&gt;    //To embed images&lt;br /&gt;    $objMail-&amp;gt;addEmbeddedImage(sfConfig::get(&#39;sf_web_dir&#39;).&#39;/images/logo.gif&#39;, &#39;CID1&#39;, &#39;Logo&#39;, &#39;base64&#39;, &#39;image/gif&#39;);&lt;br /&gt;&lt;br /&gt;    // To attachment documents&lt;br /&gt;    $objMail-&amp;gt;addAttachment(sfConfig::get(&#39;sf_data_dir&#39;).&#39;/MyDocumentSample.doc&#39;);&lt;br /&gt;    &lt;br /&gt;    // To attachment simple string&lt;br /&gt;    $objMail-&amp;gt;addStringAttachment(&#39;this is few cool text to embed&#39;, &#39;file.txt&#39;);&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;    //This line is importand; otherwise you mail wont send.&lt;br /&gt;    $this-&amp;gt;mail = $objMail;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    //These variables are from the action where the email-call function is supposed to be called&lt;br /&gt;    //You may assign variables available to the email-action from your calling action as below:&lt;br /&gt;    //$this-&amp;gt;getRequest()-&amp;gt;setAttribute(&#39;nickname&#39;, $nickname);&lt;br /&gt;&lt;br /&gt;    //Here you are passing some data available to the email template&lt;br /&gt;    $this-&amp;gt;nickname = $this-&amp;gt;getRequest()-&amp;gt;getAttribute(&#39;nickname&#39;);&lt;br /&gt;  }&lt;br /&gt;}&lt;h2&gt;The template for the action&lt;/h2&gt;..\myproject\apps\frontend\modules\mailTemplate\templates\getSampleTemplateSuccess.php&lt;br /&gt;&lt;br /&gt;(&lt;a href=&quot;http://antorobin.googlepages.com/mailTemplate.zip&quot; target=&quot;_new&quot;&gt;download the getSampleTemplateSuccess.php file used in this tutorial&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;Dear &amp;lt;?php echo $nickname ?&amp;gt;,&lt;br /&gt;&lt;br /&gt;Thanks for reading this tutorial &quot;Symfony - Using sfmail to sending your e-mails&quot;.&lt;br /&gt;&lt;br /&gt;sfMail is simple but a powerful email addon from symfony. You can create much configurable e-mail templates on the fly. Translate email contents using i18N based on your receipient&#39;s language. Thanks to symfony&#39;s great i18n support using __() function, and easy translation catalogues.&lt;br /&gt;&lt;br /&gt;Thanks,&lt;br /&gt;Marshal Anto Robin&lt;br /&gt;(antorobin@gmail.com)&lt;br /&gt;&lt;h2&gt;4. Sending the emails from action&lt;/h2&gt;&lt;br /&gt;Send emails from your action file like the sample given below:&lt;br /&gt;&lt;br /&gt;(&lt;a href=&quot;http://antorobin.googlepages.com/actions.class.php&quot; target=&quot;_new&quot;&gt;download the sample action.class.php file used in this tutorial, for calling sendEmail method&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * user actions.&lt;br /&gt; *&lt;br /&gt; * @package    sfd&lt;br /&gt; * @subpackage user&lt;br /&gt; * @author     Your name here&lt;br /&gt; * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $&lt;br /&gt; */&lt;br /&gt;class userActions extends sfActions&lt;br /&gt;{&lt;br /&gt; /**&lt;br /&gt;  * Executes index action&lt;br /&gt;  *&lt;br /&gt;  * @param sfRequest $request A request object&lt;br /&gt;  */&lt;br /&gt;  public function executeSendEmail(sfWebRequest $request)&lt;br /&gt;  {&lt;br /&gt;    $nickname = &#39;marshalR&#39;;&lt;br /&gt;    $recepientEmail = &#39;antorobin@gmail.com&#39;;&lt;br /&gt;&lt;br /&gt;    $this-&amp;gt;getRequest()-&amp;gt;setAttribute(&#39;nickname&#39;, $nickname);&lt;br /&gt;    $this-&amp;gt;getRequest()-&amp;gt;setAttribute(&#39;recepientEmail&#39;, $recepientEmail);&lt;br /&gt; &lt;br /&gt;    //Parameters used in sendEmail: mailer-module-name, mailer-action-name&lt;br /&gt;    $objController = sfContext::getInstance()-&amp;gt;getController();&lt;br /&gt;    $raw_email = $objController-&amp;gt;sendEmail(&#39;mailTemplate&#39;, &#39;getSampleTemplate&#39;);&lt;br /&gt;&lt;br /&gt;    //To log the mail content&lt;br /&gt;    $this-&amp;gt;logMessage($raw_email, &#39;debug&#39;);&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;}&lt;h2&gt;5. Test the scripts&lt;/h2&gt;Clear the cache before test the scripts:&lt;br /&gt;Use the following command in command line to clear the cache&lt;br /&gt;&lt;br /&gt;symfony cc&lt;br /&gt;&lt;br /&gt;c:\xampp\htdocs\myproject\&amp;gt; symfony cc&lt;br /&gt;&lt;br /&gt;Go to the url where your email-calling scripts are written,&lt;br /&gt;say if it&#39;s in user module and sendEmail action,&lt;br /&gt;&lt;br /&gt;http://localhost/myproject/web/user/sendEmail&lt;br /&gt;&lt;br /&gt;Now hopefully you are sending emails successfully. Thanks to symfony&#39;s sfMail addon.&lt;h2&gt;6. Sending the emails from batch-scripts&lt;/h2&gt;(From outside of the action class)&lt;br /&gt;&lt;br /&gt;If you want to send emails from outside of an action, say you want to send emails as batch0process, then you need to use the following method to do that&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;    define(&#39;SF_ROOT_DIR&#39;,    realpath(dirname(__FILE__).&#39;/..&#39;));&lt;br /&gt;    define(&#39;SF_APP&#39;,         &#39;myapp&#39;);&lt;br /&gt;    define(&#39;SF_ENVIRONMENT&#39;, &#39;test&#39;);&lt;br /&gt;    define(&#39;SF_DEBUG&#39;,       false);&lt;br /&gt;&lt;br /&gt;    require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.&#39;apps&#39;.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.&#39;config&#39;.DIRECTORY_SEPARATOR.&#39;config.php&#39;);&lt;br /&gt;&lt;br /&gt;    $raw_email = sfContext::getInstance()-&amp;gt;getController()-&amp;gt;sendEmail(&#39;mailTemplate&#39;, &#39;getSampleTemplate&#39;);&lt;h2&gt;7. Download the mailTemplate module used in this tutorial&lt;/h2&gt;&lt;a href=&quot;http://antorobin.googlepages.com/mailTemplate.zip&quot; target=&quot;_new&quot;&gt;Click here to download the source code of the mailTemplate module&lt;/a&gt;</description><link>http://phpcrat.blogspot.com/2009/07/sending-e-mailsmtp-e-mails-using-sfmail.html</link><author>noreply@blogger.com (anton)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-1628106014015084375</guid><pubDate>Sun, 19 Jul 2009 13:58:00 +0000</pubDate><atom:updated>2009-07-19T07:34:19.890-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">installing symfony</category><category domain="http://www.blogger.com/atom/ns#">symfony</category><category domain="http://www.blogger.com/atom/ns#">symfony cli</category><title>Installing Symfony Framework</title><description>Before installing symfony using pear, you need pear installed in your machine. To install php-pear in your system, you can run the &quot;go-pear.bat&quot; file in your xampp-php installation folder.&lt;br /&gt;&lt;br /&gt;if you have installed the pear in your machine, follow the below at your command-prompt to install symfony&lt;br /&gt;&lt;br /&gt;c:\&gt;pear upgrade&lt;br /&gt;c:\&gt;pear channel-discover pear.symfony-project.com&lt;br /&gt;c:\&gt;pear install symfony/symfony&lt;br /&gt;&lt;br /&gt;Now that you have successfully installed symfony in your system.&lt;br /&gt;&lt;br /&gt;To create new projects using symfony framework, we need to run some tools using command line inteface. For  that we need to add the PHP&#39;s binary path to the system environment variable.&lt;br /&gt;&lt;br /&gt;Goto start &gt; settings &gt; control panel. Click on the system icon, Select the advanced tab, and click &quot;Environment variable&quot; button as shown in the screen shot:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo2NUIGHGKzPSMn0-Ww_a7oV1VAn8lILhuL-XCIu369qMBl1kwc5P0Yd20ScwdBCdFDzl6Avu5hM6BhnbCLuMPzmbpfyPLd_IKwJ36B2eqhWnwUW85Qea2Ho9QRyC87Z8Zu23QvivaprgI/s1600-h/add-path-environment-variab.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 290px; height: 320px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo2NUIGHGKzPSMn0-Ww_a7oV1VAn8lILhuL-XCIu369qMBl1kwc5P0Yd20ScwdBCdFDzl6Avu5hM6BhnbCLuMPzmbpfyPLd_IKwJ36B2eqhWnwUW85Qea2Ho9QRyC87Z8Zu23QvivaprgI/s320/add-path-environment-variab.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5360171229313329522&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Now you will get a screen like below:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBnfDL4WA34f2KpDmdjCeRi1Ffz0lvHC4fTXux-LU6pe5JSgUirA9JhZRo7jtFiI59ho3CcK3bI4ei_IFu5l-V1lgr7Y7Jw-OL-a419RQGpi60_1l8W75ik4Dps1YIjwzTtZ5q0-RUQSAN/s1600-h/select-path-to-edit.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 286px; height: 320px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBnfDL4WA34f2KpDmdjCeRi1Ffz0lvHC4fTXux-LU6pe5JSgUirA9JhZRo7jtFiI59ho3CcK3bI4ei_IFu5l-V1lgr7Y7Jw-OL-a419RQGpi60_1l8W75ik4Dps1YIjwzTtZ5q0-RUQSAN/s320/select-path-to-edit.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5360171637313038882&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;In the system variable box choose path and click edit, and the dialog will prompt you to edit the path variable. Add the path of the php binary with the path value following a semicolon as below:&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1iTaOSsj2ck3xX4dmlvuzYx1QO4SeALy5t838T73HOehqdmEy-eI7OyljYl4QSBY1gk0hWrfujbQ7oCvk-AyEQzjfAnF7eRkZDUw8_KYoTCGj-LRzAicCK1mlBmfbczsgoA12_YuqUpT9/s1600-h/add-path-php-binary.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 268px; height: 320px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1iTaOSsj2ck3xX4dmlvuzYx1QO4SeALy5t838T73HOehqdmEy-eI7OyljYl4QSBY1gk0hWrfujbQ7oCvk-AyEQzjfAnF7eRkZDUw8_KYoTCGj-LRzAicCK1mlBmfbczsgoA12_YuqUpT9/s320/add-path-php-binary.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5360172033999303330&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Symfony requires at least PHP 5.2. To check your php version, type the following in command prompt&lt;br /&gt;c:\&gt;php -v&lt;br /&gt;&lt;br /&gt;it will display the version informatiom as below:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh3We0gDoe6DaaQn3mrxMP2R3kcedycPjqOfdjwy1POIDOlqWcUD29rctJ-Om8oT3w_y02onYMr7OrzNLBdMYZSnyBlqfAQSJ36sPpjfHy-2awv0no_9tCz6ApwIzeU24KQhyaSmMVIMoI/s1600-h/php-version-check.png&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 58px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh3We0gDoe6DaaQn3mrxMP2R3kcedycPjqOfdjwy1POIDOlqWcUD29rctJ-Om8oT3w_y02onYMr7OrzNLBdMYZSnyBlqfAQSJ36sPpjfHy-2awv0no_9tCz6ApwIzeU24KQhyaSmMVIMoI/s320/php-version-check.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5360172456031259346&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now test your symfony&#39;s installation by type the following in command prompt:&lt;br /&gt;c:\&gt;php symfony -V&lt;br /&gt;this will display you the newly installed symfony&#39;s version information.&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 153);font-size:130%;&quot; &gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Creating Project in Symfony&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Symfony organize each project by a specific folder structure, that helps manage the project&#39;s code easily. Symfony&#39;s command line tool itself generate all the folder structure for your project. To do this type the following in your command line:&lt;br /&gt;&lt;br /&gt;1. navigate to your projct folder inside the apache&#39;s htdocs folder.&lt;br /&gt;say you created myproject directory under the we root c:\xampp\htdocs.&lt;br /&gt;&lt;br /&gt;2. Run the following symfony&#39;s command line tool to create your new project &#39;myproject&#39;&lt;br /&gt;c:\xampp\htdocs\myproject\&gt; php C:\xampp\php\symfony generate:project myproject&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPO0quhAuC4g-46ZbbwoMqUTJF8VMiuxakm17bIOy4emvXgIEoZwb5wp63pgvMsb90BT3BtFRq5zLkxSE81nvX7FR8cW4P4MucfYNXq37wdCLOX9P0onJzpPFWxgPiq-Rotq3aBJTZXXEE/s1600-h/symfony-generate-app.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 157px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPO0quhAuC4g-46ZbbwoMqUTJF8VMiuxakm17bIOy4emvXgIEoZwb5wp63pgvMsb90BT3BtFRq5zLkxSE81nvX7FR8cW4P4MucfYNXq37wdCLOX9P0onJzpPFWxgPiq-Rotq3aBJTZXXEE/s320/symfony-generate-app.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5360172945215007234&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;This will create the file structure for your new project as below&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv0ymHfKvWCW1OLocN8okRZqnO_utFjS1u-JNhy2aamHTvU1eKT_8Lof704bTJkNnn2lqMKGeYQ9A-tWs7ObqvGvu0RkdH8ywkvUPYmWIzttj_GxT6jvLKyV6eQZe79LFqfSmyIny9K5v3/s1600-h/symfony-folder-structure.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 123px; height: 207px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv0ymHfKvWCW1OLocN8okRZqnO_utFjS1u-JNhy2aamHTvU1eKT_8Lof704bTJkNnn2lqMKGeYQ9A-tWs7ObqvGvu0RkdH8ywkvUPYmWIzttj_GxT6jvLKyV6eQZe79LFqfSmyIny9K5v3/s320/symfony-folder-structure.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5360173468751192466&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;span style=&quot;color: rgb(51, 51, 153);font-size:130%;&quot; &gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Creating the Application&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One symfony project may contain multiple applications; generally any we application has atleast two applications as the &quot;frontend presentation(frontend)&quot; and the &quot;admin interface(backend)&quot;&lt;br /&gt;&lt;br /&gt;To create new application(say frontend) navigate to your project folder in command prompt and run the following command:&lt;br /&gt;&lt;br /&gt;c:\xampp\htdocs\myproject\&gt; php symfony generate:app frontend&lt;br /&gt;&lt;br /&gt;This will create a unique folder structure inside the frontend directory as below:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwO5eKBfct-OAZnJLWon_nbLHNf_1b0TvtCLY7ZJT7gB2fds0X5xPTtNHDOo40Ij5AfcZ8sE22kNOtlhjLZ9FocEJkXFldrqhYvlatbfvbtTQIQHFeEGGFQriVJxYZwDSGuheZ1rIo62AQ/s1600-h/symfony-app-folder-structur.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 256px; height: 158px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwO5eKBfct-OAZnJLWon_nbLHNf_1b0TvtCLY7ZJT7gB2fds0X5xPTtNHDOo40Ij5AfcZ8sE22kNOtlhjLZ9FocEJkXFldrqhYvlatbfvbtTQIQHFeEGGFQriVJxYZwDSGuheZ1rIo62AQ/s320/symfony-app-folder-structur.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5360174011534853682&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.symfony-project.org/book/1_2/03-Running-Symfony&quot;&gt;For more information about creating a project in symfony&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;font-size:130%;&quot; &gt;Creating a Module&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A module is a part of an application which has n number of actions based on the size of the module. In this sample application i am creating module called &quot;login&quot;&lt;br /&gt;For this run the following command:&lt;br /&gt;C:\xampp\htdocs\myproject&gt;php symfony generate:module frontend login&lt;br /&gt;&lt;br /&gt;This will create a login module under the frontend application. And this module has two folders generated under this, and are actions and templates as the screenshot below:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOaOOPLgyqFbzDpebA3I9pbEOwkx0N9daSLj9DeGoJ-rEbGrtBJ4qQt5UXLi6EQMHYVHqkkvJO35ZB-o_X0HAI0zn-ZLwIfF02fg9l0pAT5rqjo7YXr6PfRBma8-7cSM4DEKz2W1AOBOsa/s1600-h/symfony-module-directory-st.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 71px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOaOOPLgyqFbzDpebA3I9pbEOwkx0N9daSLj9DeGoJ-rEbGrtBJ4qQt5UXLi6EQMHYVHqkkvJO35ZB-o_X0HAI0zn-ZLwIfF02fg9l0pAT5rqjo7YXr6PfRBma8-7cSM4DEKz2W1AOBOsa/s320/symfony-module-directory-st.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5360174438556459970&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;font-size:130%;&quot; &gt;Creating Actions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Inside actions folder within every module there is a file named actions.class.php. This file is used to define all actions belonged to that module. And all corresponding template files will be placed inside the templates folder under that module.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 153); font-weight: bold;font-size:130%;&quot; &gt;Naming conventions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To describe an action, the name should be &quot;executeActionname()&quot; and the template name would be &quot;actionnameSuccess.php&quot;&lt;br /&gt;&lt;br /&gt;Sample action named as index&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQwQjPSCiNxSXKSGI3xvxHxBT9DpHnIN835wnXdOh9iQ2QDOxfgkG33s514X21xCwAN_G7mj7fUhDnhRH5869R1vCI0KT-LqTVWx48pris215Vq1dyLRKy94WeO_tck9Ts9fFAXjF0PlWf/s1600-h/sample-action.png&quot;&gt;&lt;img style=&quot;cursor: pointer; width: 320px; height: 211px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQwQjPSCiNxSXKSGI3xvxHxBT9DpHnIN835wnXdOh9iQ2QDOxfgkG33s514X21xCwAN_G7mj7fUhDnhRH5869R1vCI0KT-LqTVWx48pris215Vq1dyLRKy94WeO_tck9Ts9fFAXjF0PlWf/s320/sample-action.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5360174830992477442&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Template for the action named as index&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit3ptkwZjUdWKnAu6ttzlvOPl1Q74PGoRiDp8YlttVYYiNxKfVKIxSqC_IHb6ZesofUyeg_0zEM-xBIqWSY0WSl2bjgVeVG-ykHGHNglnpwewi3iQJsr9LcZzg9iOL4ToqcoPYuNkTQQAB/s1600-h/template-action.png&quot;&gt;&lt;img style=&quot;cursor: pointer; width: 320px; height: 103px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit3ptkwZjUdWKnAu6ttzlvOPl1Q74PGoRiDp8YlttVYYiNxKfVKIxSqC_IHb6ZesofUyeg_0zEM-xBIqWSY0WSl2bjgVeVG-ykHGHNglnpwewi3iQJsr9LcZzg9iOL4ToqcoPYuNkTQQAB/s320/template-action.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5360175350521849186&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To access the application in browser:&lt;br /&gt;http://localhost/myproject/&amp;lt;modulename&amp;gt;/&amp;lt;actionname&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;modulename&gt;&lt;actionname&gt;So for our sample application, it will be&lt;br /&gt;http://localhost/myproject/login/index&lt;/actionname&gt;&lt;/modulename&gt;&lt;/actionname&gt;&lt;/modulename&gt;</description><link>http://phpcrat.blogspot.com/2009/07/installing-symfony-framework.html</link><author>noreply@blogger.com (anton)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo2NUIGHGKzPSMn0-Ww_a7oV1VAn8lILhuL-XCIu369qMBl1kwc5P0Yd20ScwdBCdFDzl6Avu5hM6BhnbCLuMPzmbpfyPLd_IKwJ36B2eqhWnwUW85Qea2Ho9QRyC87Z8Zu23QvivaprgI/s72-c/add-path-environment-variab.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-1442341397989964273</guid><pubDate>Sun, 19 Jul 2009 13:54:00 +0000</pubDate><atom:updated>2009-07-19T06:56:19.056-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">php mvc framework</category><category domain="http://www.blogger.com/atom/ns#">symfony</category><title>Why Symfony</title><description>Symfony is a MVC(Model-View-Controller) framework, and It establishes a set of best practices, which helps to develop maintainable, secure and scalable Enterprise Level web applications.&lt;br /&gt;&lt;br /&gt;Why symfony:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Open Source (MIT License)&lt;/li&gt;&lt;li&gt;Deploy Enterprise Applications quickly using RAD (Rapid Application Development) methodology&lt;/li&gt;&lt;li&gt;Manageable even for larger applications&lt;/li&gt;&lt;li&gt;Completely Object Oriented&lt;/li&gt;&lt;li&gt;Switch between any databases with no modifications on the code level&lt;/li&gt;&lt;li&gt;Easy Form Handling: Fillin, Validation and Connecting with ORM(doctrine and propel)&lt;/li&gt;&lt;li&gt;Large and ever growing community support ( more than 650 available plugins)&lt;/li&gt;&lt;li&gt;In-built cache support&lt;/li&gt;&lt;li&gt;Internationalization and Localization(I18n, L10n)&lt;/li&gt;&lt;li&gt;Bridges to other frameworks&lt;/li&gt;&lt;li&gt;Development/debugging environments&lt;/li&gt;&lt;li&gt;Themes based on url&lt;/li&gt;&lt;li&gt;Extending the framework is easy with writing own filters, helpers, plugins. &lt;/li&gt;&lt;li&gt;Easily overriding the control layers to support with smarty like template frameworks&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Symfony is developed and promoted by Sensio Labs, a French Web Agency well known for its innovative views on web development.</description><link>http://phpcrat.blogspot.com/2009/07/why-symfony.html</link><author>noreply@blogger.com (anton)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-2467250926964941714</guid><pubDate>Tue, 07 Apr 2009 14:06:00 +0000</pubDate><atom:updated>2009-04-07T07:07:39.766-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">mysql storage engines</category><title>How to select &#39;database storage engine&#39; for your MySQL tables</title><description>MySQL supports several storage engines and, are &lt;span style=&quot;font-style: italic;&quot;&gt;MyISAM, InnoDB, MERGE, MEMORY (HEAP), BDB (BerkeleyDB), EXAMPLE, FEDERATED, ARCHIVE, CSV and BLACKHOLE &lt;/span&gt;storage engine.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;MyISAM&lt;/span&gt; is the storage engine which is used for non-transactional tables, and where these tables undergo huge volume of access with search and select queries, other than storing and updating the data. MyISAM is the default storage engine for MySQL database unless otherwise if you are explicitly declared for.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The InnoDB&lt;/span&gt; and BDB storage engines are used for transaction-safe tables. The InnoDB storage engine supports FOREIGN KEY referential-integrity constraints.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The MEMORY&lt;/span&gt; storage engine provides in-memory tables, which are . Tvisible only on the run-time and destroys itself after the script ends it execution. The MERGE storage engine allows a collection of identical MyISAM tables to be handled as a single table. The MEMORY and MERGE storage engines also used for non-transactional tables similar to that of MyISAM.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The NDBCLUSTER&lt;/span&gt; (also known as NDB) storage engine is used by MySQL Cluster to implement tables that are partitioned over many computers such as cloud computing.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The ARCHIVE&lt;/span&gt; storage engine is used for storing large amounts of data without indexes with a very small footprint. And it supports only INSERT and SELECT operations, but not DELETE, REPLACE, or UPDATE. It does support ORDER BY operations and BLOB columns.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The CSV&lt;/span&gt; storage engine stores data in text files as the comma-separated values format. This storage engine does not support indexing.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The BLACKHOLE&lt;/span&gt; storage engine is a &#39;no-op&#39; storage engine, which can&#39;t able to store any data, but used only for logging and analysing the query performances.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;In FEDERATED&lt;/span&gt; storage engine the queries on the local server are automatically executed on the remote tables. No data will eb stored on the local tables.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The EXAMPLE&lt;/span&gt; storage engine is a sample engine that does nothing. The purpose of keeping this engine is to showcase as an example in the MySQL source code which illustrates how to begin writing new storage engines.</description><link>http://phpcrat.blogspot.com/2009/04/how-to-select-database-storage-engine.html</link><author>noreply@blogger.com (anton)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-1832882310412073512</guid><pubDate>Tue, 07 Apr 2009 12:51:00 +0000</pubDate><atom:updated>2009-04-07T05:57:17.618-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">connecting php with mysql</category><title>The differences between mysql_pconnect() and mysql_connect()</title><description>&lt;span style=&quot;font-weight: bold;&quot;&gt;mysql_pconnect()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Open a persistent connection to a MySQL server.&lt;br /&gt;&lt;br /&gt;mysql_pconnect() acts very similar to mysql_connect() with the following two major differences.&lt;br /&gt;&lt;br /&gt;1. When trying to connect with the database, the function would first try to find if any persistent link that&#39;s already open with the same host, username and password. It would use the existing one if found and will return an identifier for the connection. These connection identifiers are usually called as child connections and must not produce equal overhead as a fresh new connection would do.&lt;br /&gt;&lt;br /&gt;2. These  persistent connection to the Database server will not be closed when the execution of the script ends, and the link will remain open and accessible for future use. And also the function mysql_close() can not close links established by these persistent conection.&lt;br /&gt;&lt;br /&gt;Persistent connections are good if the overhead to create a connection to the database server is high.&lt;br /&gt;&lt;br /&gt;There should be some drawbacks using persistent connections, that if you are using a database with connection limits that are exceeded by persistent child connections. For example, say if your database has a limit of 100 simultaneous connections, and in the course of a busy server session, the 101th child thread will not be able to connect. And again if any connection on your database caused an infinite loop or a similar bug on your script, then it will be the major problem with a databases with limited persistent child connections.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;mysql_connect()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Opens or reuses a connection to a MySQL server.&lt;br /&gt;&lt;br /&gt;The link to the server will be closed as soon as the execution of the script ends, unless it&#39;s closed earlier by explicitly calling mysql_close().&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;syntax: resource mysql_connect ( [string $server [, string $username [, string $password [, bool $new_link [, int $client_flags]]]]] )&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The fourth argument (bool $new_link) is notable here as it will instruct the script engine to always open a new link whenever a connection is requested, even if a connection with the same parameter has already established.</description><link>http://phpcrat.blogspot.com/2009/04/differences-between-mysqlpconnect-and.html</link><author>noreply@blogger.com (anton)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8656346749704430235.post-5787111900358528878</guid><pubDate>Tue, 07 Apr 2009 07:05:00 +0000</pubDate><atom:updated>2009-04-07T00:09:53.060-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Classes and Objects</category><title>Classes and Objects in PHP 5</title><description>&lt;span style=&quot;font-weight: bold;&quot;&gt;Class&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;syntax: class classname{ }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In php5 the handling of objects has been completely rewritten, and specifically to allowing for better performance and more features to use objects efficient.&lt;br /&gt;&lt;br /&gt;Classes begins with the keyword &#39;class&#39;, followed by a the class name which the user may choose. The keyword &#39;new&#39; used to create object from a class.&lt;br /&gt;&lt;br /&gt;Inside the scope of a current class context, it is possible to create a objects by using keywords &#39;self&#39; and &#39;parent&#39;;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;eg: new self; new parent;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A class can inherit methods and members of another class by using the keyword &#39;extends&#39;;&lt;br /&gt;eg: class inheritedclass extends parentclassname{ }&lt;br /&gt;&lt;br /&gt;Any inherited methods and members of the parent class can be overridden, unless the parent class has defined a method byusing the keyword &#39;final&#39;, by re declaring those methods or members with the same name defined in the parent class.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Autoloading&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;By defining an __autoload function, during the object creation, the scripting engine is given a last chance to load the required class before PHP fails with an error.&lt;br /&gt;&lt;br /&gt;The function __autoload gets the class name whenever any object gets created. so we can include the class definition for the particular class. So the main usage is to avoid include lot of class file in every page.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;eg:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;function __autoload($nameOfClass) {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    require_once $nameOfClass . &#39;.php&#39;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Any exceptions thrown in __autoload function cannot be caught in the catch block and thus it results in a fatal error.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Namespaces&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;we can have our classes within unique namespace and prevent code clashes.&lt;br /&gt;&lt;br /&gt;namespace must be the first statement in the script&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;eg:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;//in file1.php&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;namespace ProjectOne;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;class myClass{  }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;//in file2.php&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;require &quot;file1.php&quot;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;use ProjectOne as One;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;$myObj = new One::myClass;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Constructors and destructors&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Constructor&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Constructor is suitable for any initialization that the object may require before it is used.&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;syntax: void __construct(args){}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Destructor&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The destructor method will be called automatically when as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.&lt;br /&gt;&lt;br /&gt;parent destructors will not be called implicitly/ automatically by the engine. we need call manually by calling parent::__destruct() in the destructor body.&lt;br /&gt;&lt;br /&gt;Attempting to throw an exception from a destructor (called in the time of script termination) causes a fatal error.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;syntax: void __destruct ( void ){}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Visibility&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The visibility of a member property or method of a class can be defined by prefixing the declaration with the keywords: public, protected or private. Public declared items can be accessed everywhere. Protected limits access to inherited and parent classes (and to the class that defines the item). Private limits visibility only to the class that defines the item.&lt;br /&gt;&lt;br /&gt;Parent and child class can have a private set of private variables that no-one else has access to, other than the class itself even it was inherited. Which means private members of a class cant be overridden.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Scope resolution operator (::)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Scope Resolution Operator is a token that allows access to static, constant, and other members or methods of a class. Two special keywords self and parent are used to access members or methods from inside the class definition. Call it by the name of the class, when referencing these from outside the class.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Static keyword&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Declaring class members or methods as static makes them accessible without needing an instantiation of the class. A member declared as static can not be accessed with an instantiated class object (though a static method can).&lt;br /&gt;&lt;br /&gt;static methods are callable without an instance of the object created, the pseudo variable &#39;$this&#39; is not available inside the method declared as static.&lt;br /&gt;Static properties cannot be accessed through the object using the arrow operator -&gt;, use :: instead.&lt;br /&gt;&lt;br /&gt;static variable are used to store data inside a function or method. see: &lt;a href=&quot;http://phpblog.info/2008/07/26/when-to-use-static-php-variables&quot;&gt;http://phpblog.info/2008/07/26/when-to-use-static-php-variables&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Class constants&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;keyword used to declare a constant is &#39;const&#39;. Constants differ from normal variables in that you don&#39;t use the &#39;$&#39; symbol to declare or use them. The value must be a constant expression, and should not be a variable, a class member, result of a mathematical operation or a function call.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Class abstraction&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is not allowed to create an instance from a class that has been defined as abstract. Any class that contains at least one abstract method must also be abstract. Methods defined as abstract simply declare the method&#39;s signature they cannot define the implementation.&lt;br /&gt;&lt;br /&gt;when overridding an abstarce method or abstarct member property, the visibility would be less restrictive or same; For example, if the abstract method is defined as protected, the function implementation must be defined as either protected or public, but not private.&lt;br /&gt;An abstract class that extends another abstract class doesn&#39;t need to define the abstract methods from the parent class.&lt;br /&gt;&lt;br /&gt;Usage: sometime different classes have same methods which are differ in their functionalities.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Difference between abstarct and interface&lt;/span&gt;:&lt;br /&gt;The difference between an interface and an abstract class, is that an interface does not define the behavior of an object. Rather, it defines how you work with a class.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;eg:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;class X implements Y { } // this is saying that &quot;X&quot; agrees to speak language &quot;Y&quot; with your code.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;class X extends Y { } // this is saying that &quot;X&quot; is going to complete the partial class &quot;Y&quot;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Overloading&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;PHP&#39;s interpretation of &quot;overloading&quot; is different than most object oriented languages. Overloading traditionally provides the ability to have multiple methods with the same name but different quantities and types of arguments.&lt;br /&gt;&lt;br /&gt;Overloading in PHP provides means to dynamically &quot;create&quot; members and methods. These dynamic entities are processed via magic methods; and are as below:&lt;br /&gt;Member overloading:&lt;br /&gt;void __set ( string $name , mixed $value ) - is run when writing data to inaccessible members.&lt;br /&gt;mixed __get ( string $name ) - is utilized for reading data from inaccessible members&lt;br /&gt;bool __isset ( string $name ) - is triggered by calling isset() or empty() on inaccessible members.&lt;br /&gt;void __unset ( string $name ) - is invoked when unset() is used on inaccessible members.&lt;br /&gt;&lt;br /&gt;Method overloading&lt;br /&gt;mixed __call ( string $name , array $arguments ) - is triggered when invoking inaccessible methods in an object context.&lt;br /&gt;mixed __callStatic ( string $name , array $arguments ) - is triggered when invoking inaccessible methods in a static context.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Object iteration&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;object&#39;s elements can be viewed as array format by using the print_r() function.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Magic methods&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The function names __construct, __destruct, __call, __callStatic, __get, __set, __isset, __unset, __sleep, __wakeup, __toString, __invoke, __set_state and __clone are magical in PHP classes. You cannot have functions with these names in any of your classes unless you want the magic functionality associated with them.&lt;br /&gt;&lt;br /&gt;The __invoke method is called when a script tries to call an object as a function. eg: $obj(5);&lt;br /&gt;The __toString method allows a class to decide how it will react when it is converted to a string. eg: echo $obj;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Final keyword&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The keyword &#39;final&#39; prevents child classes from overriding a method. If the class itself is being defined final then it cannot be extended.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Object cloning&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is nothing but a &#39;copy constructors&#39;. we can extend the functionality by using the __close function inside the class. __clone function will be invoked when any object cloned using clone keyword.&lt;br /&gt;&lt;br /&gt;If you intend to pass a copy of an object to a function, then you should use &#39;clone&#39; to create a copy explicity.  In PHP5, objects appear to always be passed by reference (unlike PHP4).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Type hinting&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;PHP 5 introduces Type Hinting. Functions are now able to force parameters to be objects (by specifying the name of the class in the function prototype) or arrays.&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;eg: &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    class class1(class2 $obj1){}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    function funct1 (array $my_array)&lt;/span&gt;</description><link>http://phpcrat.blogspot.com/2009/04/classes-and-objects-in-php-5.html</link><author>noreply@blogger.com (anton)</author><thr:total>0</thr:total></item></channel></rss>