<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Larry Ullman&#039;s Blog &#187; PHP</title>
	<atom:link href="http://blog.dmcinsights.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dmcinsights.com</link>
	<description>flotsam and jetsam abounds</description>
	<lastBuildDate>Tue, 27 Jul 2010 16:27:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Handling Checkboxes in Yii with non-Boolean Values</title>
		<link>http://blog.dmcinsights.com/2010/07/25/handling-checkboxes-in-yii-with-non-boolean-values/</link>
		<comments>http://blog.dmcinsights.com/2010/07/25/handling-checkboxes-in-yii-with-non-boolean-values/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 15:24:08 +0000</pubDate>
		<dc:creator>Larry</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[yii]]></category>

		<guid isPermaLink="false">http://blog.dmcinsights.com/?p=1205</guid>
		<description><![CDATA[On a recent Yii-based project, managing one of the Models required a whole slew of checkboxes to indicate that yes, the quality does apply, or no, it does not. In this case, the value being stored in the database for each attribute was a single letter: Y/N. However Yii, when showing the form to update [...]]]></description>
			<content:encoded><![CDATA[<p>On a recent Yii-based project, managing one of the Models required a whole slew of checkboxes to indicate that yes, the quality does apply, or no, it does not.  In this case, the value being stored in the database for each attribute was a single letter: Y/N. However Yii, when showing the form to update an item, needs the checkbox value to be a Boolean, in order to properly pre-check the box. Changing the database wasn&#8217;t an option in this case, so I had to figure out a good conversion process. In this post, I&#8217;ll tell you exactly how I solved this issue.<span id="more-1205"></span>As I said, for the item in question, the database table had multiple columns, each of which only stored either <em>Y</em> or <em>N</em>. As an example, think of a users table with multiple opt-in options: newsletters, offers, etc. When the user creates and updates their account, presenting these as checkboxes is appropriate. But for the administrator, it&#8217;d probably be best to view user preferences by just seeing Y/N for each option (although the code I&#8217;m going to present wouldn&#8217;t be significantly different if you stored 1/0).</p>
<p>The <strong>protected/views/modelName/_form.php</strong> file defines the form that&#8217;s used to both create and update an individual record. In it, checkboxes are created using:</p>
<pre>&lt;?php echo $form-&gt;checkBox($model,'<em>attribute</em>'); ?&gt;</pre>
<p>I can pass an array of options to the <strong>checkbox()</strong> method in order to tweak how it behaves. In my example, I want to set the values assigned to the Model in both the checked and unchecked states. Here&#8217;s how you do that:</p>
<pre>&lt;?php echo $form-&gt;checkBox($model,'<em>attribute</em>',array('value' =&gt; 'Y', 'uncheckValue'=&gt;'N')); ?&gt;</pre>
<p>The <em>value</em> option literally creates the <strong>value=&#8221;Y&#8221;</strong> code in the checkbox HTML. The <em>uncheckValue</em> option is something that Yii adds that allows you to indicate what the value should be if the box is not checked. It&#8217;s a nice addition, saving you from having to add code in the Model to define the value when the box isn&#8217;t checked.</p>
<p>So now my Model will receive, and the database will store, either <em>Y</em> or <em>N</em>, depending upon whether the box is checked or not. The next hurdle comes for properly handling updates. An update uses this same form, but the above code alone will not automatically check the box should the database store the value <em>Y</em> for the given attribute. My solution, then, was to convert <em>Y</em> to true and <em>N</em> to false when retrieving the Model item, but only on an update. In the other situations where a Model record might be retrieved and used, the Y/N values are preferable.</p>
<p>In the Controller for this Model, the update action is where I want to start my changes. That method first loads an individual Model using the Controller&#8217;s <strong>loadModel()</strong> method:</p>
<pre>public function actionUpdate() {
    $model=$this-&gt;loadModel();</pre>
<p>After this point, I want to convert all instances of Y/N to true/false, so I invoke a Model method (I&#8217;ll define next) to perform that task:</p>
<pre>$model-&gt;convertToBooleans();</pre>
<p>The <strong>convertToBooleans()</strong> method is defined in the Model. It first defines an array of all attributes that need the conversion:</p>
<pre>public function convertToBooleans() {
    $attributes = array('newsletter', 'offers', ...);</pre>
<p>This list of strings must exactly match the names of the corresponding Model attributes. From here, there are a couple of ways to proceed. One obvious route is to loop through the array using a <strong>foreach</strong>. Within the <strong>foreach</strong>, the ternary operator is used to assign to the Model&#8217;s attribute a Boolean based upon its current value:</p>
<pre>foreach ($attributes as $attr) {
    $this-&gt;$attr = ($this-&gt;$attr == 'Y') ? true : false;
}</pre>
<p>So that&#8217;s all you need to do to make this work. But if you&#8217;re like me and you prefer to make your methods as atomic as possible, you could create a separate Model method that performs the specific conversion:</p>
<pre>public function convertAttributeToBoolean($attr) {
    $this-&gt;$attr = ($this-&gt;$attr == 'Y') ? true : false;
}</pre>
<p>In this case, the <strong>convertToBooleans()</strong> method needs to call this other method for each item in the array. The <strong>array_map()</strong> PHP function can apply a function to every element in an array:</p>
<pre>array_map('someFunction', $someArray);</pre>
<p>To use an object method, use this syntax:</p>
<pre>array_map(array($object, 'methodName'), $someArray);</pre>
<p>So the <strong>convertToBooleans()</strong> method could do this:</p>
<pre>array_map(array($this, 'convertAttributeToBoolean'), $attributes);</pre>
<p>And that&#8217;s what you need to do to make form checkboxes work with non-Boolean database values (MySQL does support storing of Booleans, though). Remember that you first need to update the <strong>_form.php</strong> script, which will be used for both adding and updating records. Then you only need to convert the Y/N values to Booleans when you go to update a record.</p>
<p>I hope this helps and thanks for reading. Let me know if you have any questions or comments. Thanks, Larry!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dmcinsights.com/2010/07/25/handling-checkboxes-in-yii-with-non-boolean-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forcing Login for All Pages in Yii</title>
		<link>http://blog.dmcinsights.com/2010/07/20/forcing-login-for-all-pages-in-yii/</link>
		<comments>http://blog.dmcinsights.com/2010/07/20/forcing-login-for-all-pages-in-yii/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 06:45:17 +0000</pubDate>
		<dc:creator>Larry</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[auth]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[yii]]></category>

		<guid isPermaLink="false">http://blog.dmcinsights.com/?p=1195</guid>
		<description><![CDATA[Some time back, I had written a couple of blog posts on authentication and authorization in Yii. As a comment to one of those posts, someone shared some code (also posted in the Yii forums) that requires a login to access any page. The interesting thing about this code is that it&#8217;s placed in the [...]]]></description>
			<content:encoded><![CDATA[<p>Some time back, I had written a couple of blog posts on <a href="http://blog.dmcinsights.com/2010/01/07/custom-authentication-using-the-yii-framework/">authentication</a> and <a href="http://blog.dmcinsights.com/2010/01/14/yii-framework-access-control-lists/">authorization</a> in <a href="http://www.yiiframework.com/">Yii</a>. As a comment to one of those posts, someone shared some code (also posted in the Yii forums) that requires a login to access any page. The interesting thing about this code is that it&#8217;s placed in the primary application configuration file, not within individual Controllers. The benefit to this approach is that a little bit of code can add authorization to your entire site, no matter how many Controllers you have. I&#8217;ll explain how to use this approach in this post, although keep in mind that it&#8217;s really best for situations where users must be logged in to access almost all of the site&#8217;s content.<span id="more-1195"></span>The very first step uses the <span style="text-decoration: underline;">protected/config/main.php</span> configuration file. That configuration file returns an array of values. Within that primary array (i.e., not within any of the subsections), you&#8217;ll want to add:</p>
<pre>'behaviors' =&gt; array(
    'onBeginRequest' =&gt; array(
        'class' =&gt; 'application.components.RequireLogin'
    )
),
</pre>
<p>By placing this within the primary array, it applies to the application as a whole, as opposed to a specific component or module. This code associates one class with the <strong>onBeginRequest</strong> behavior. This is to say that every time a request is made, an instance of the <strong>RequireLogin</strong> class should be created.</p>
<p>Next, create a file called <span style="text-decoration: underline;">RequireLogin.php</span> and store it in the <span style="text-decoration: underline;">protected/components</span> directory. That file needs to define the <strong>RequireLogin</strong> class, which should be an extension of the Yii <strong>CBehavior</strong> class, which defines how application behaviors are used:</p>
<pre>&lt;?php
class RequireLogin extends CBehavior
{
}
?&gt;</pre>
<p>Within that class, only two methods need to be defined. The first is <strong>attach()</strong>, which will associate an event handler with the application:</p>
<pre>public function attach($owner)
{
    $owner-&gt;attachEventHandler('onBeginRequest', array($this, 'handleBeginRequest'));
}</pre>
<p>This method will receive the application as an argument (this code was found in the Yii forums, too). The <strong>attachEventHandler()</strong> function attaches to the application an event handler, saying that when the <strong>onBeginRequest</strong> event occurs, this class&#8217;s <strong>handleBeginRequest()</strong> method should be called.</p>
<p>The <strong>handleBeginRequest()</strong> method is defined like so:</p>
<pre>public function handleBeginRequest($event)
{
    if (Yii::app()-&gt;user-&gt;isGuest &amp;&amp; !in_array($_GET['r'],array('site/login'))) {
        Yii::app()-&gt;user-&gt;loginRequired();
    }
}</pre>
<p>The method takes one argument, which will be the event (not actually used in the method). The purpose of the method is to determine the conditions in which a login must be required of the user. That enforcement is made by calling <strong>Yii::app()-&gt;user-&gt;loginRequired()</strong>. For this bare-bones example, the condition checks if the user is a guest, which is to say they aren&#8217;t logged in, and that <strong>$_GET['r'] </strong>does not have a value of <em>site/login</em>. The net effect is that guests can only ever access the login page. If you wanted to allow access to other pages, just add those values to the array:</p>
<pre>if (Yii::app()-&gt;user-&gt;isGuest &amp;&amp; !in_array($_GET['r'],array('site/login', 'site/index', 'site/contact'))) {
</pre>
<p>So that&#8217;s one way of implementing a broad login requirement without individually adjusting each Controller. To be clear, you&#8217;ll probably need to do that some as well, like to allow for access to specific actions based upon the type of logged-in user. Still, this is a simple and quite effective catchall. The person that shared the original code in my blog had put all this together within the configuration file. It is possible to do that (by creating an executed function) but the syntax is tricky and the code can really muddle up your configuration file. I think it&#8217;s best to separate it out, plus you now have a new class (<strong>RequireLogin</strong>) that you can use in other Yii-based sites.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dmcinsights.com/2010/07/20/forcing-login-for-all-pages-in-yii/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Lerdorf&#8217;s No-Framework PHP MVC Framework</title>
		<link>http://blog.dmcinsights.com/2010/07/17/lerdorfs-no-framework-php-mvc-framework/</link>
		<comments>http://blog.dmcinsights.com/2010/07/17/lerdorfs-no-framework-php-mvc-framework/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 16:47:07 +0000</pubDate>
		<dc:creator>Larry</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://blog.dmcinsights.com/?p=1166</guid>
		<description><![CDATA[Some years ago, Rasmus Lerdorf, original creator of PHP, posted on his personal Web site a discussion of what he would look for in a framework for the MVC architecture. It&#8217;s an interesting read, from the master&#8217;s voice. He specifically talks about how to properly use MVC, how to guarantee performance and security, and how [...]]]></description>
			<content:encoded><![CDATA[<p>Some years ago, Rasmus Lerdorf, original creator of <a href="http://www.php.net">PHP</a>, posted on <a href="http://toys.lerdorf.com/">his personal Web site</a> a<a href="http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html"> discussion of what he would look for in a framework for the MVC architecture</a>. It&#8217;s an interesting read, from the master&#8217;s voice. He specifically talks about how to properly use MVC, how to guarantee performance and security, and how to design with scalability and flexibility in mind. Although the post is a few years old, most of it is still valid, although there are little changes such as the fact that the PECL/Filter extension is now part of PHP proper.</p>
<p>Lerdorf also posted <a href="http://toys.lerdorf.com/archives/53-HipHop-PHP-Nifty-Trick.html">his own thoughts</a> on <a href="http://developers.facebook.com/blog/post/358">Facebook&#8217;s use of HipHop PHP</a> for faster PHP execution, if you&#8217;re looking for something to read.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dmcinsights.com/2010/07/17/lerdorfs-no-framework-php-mvc-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Flash with Yii</title>
		<link>http://blog.dmcinsights.com/2010/07/08/using-flash-with-yii/</link>
		<comments>http://blog.dmcinsights.com/2010/07/08/using-flash-with-yii/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 06:38:31 +0000</pubDate>
		<dc:creator>Larry</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://blog.dmcinsights.com/?p=1151</guid>
		<description><![CDATA[On my most recent Yii-based Web site, I decided to use a custom Flash application for part of the back-end administration of the site. The justification was simple: what the administrator needed to do was a bit complicated; lots of information had to be available but the user interface had to remain uncluttered and natural. [...]]]></description>
			<content:encoded><![CDATA[<p>On my most recent <a href="http://www.yiiframework.com">Yii</a>-based Web site, I decided to use a custom Flash application for part of the back-end administration of the site. The justification was simple: what the administrator needed to do was a bit complicated; lots of information had to be available but the user interface had to remain uncluttered and natural. The specific Web site provided a way to create and take online quizzes. In a separate process, the administrator could add and edit questions. In the Flash-based process, the administrator could associate any number of questions with a quiz (actually, a pool of questions would be associated with a quiz and X number of random questions would be pulled from that pool). The main issue, from a user interface perspective, was how to display the questions in an intelligent way. With other examples, I might create a form for adding or editing quizzes and within that form, the questions would be listed within a dropdown menu (actually a SELECT menu that displayed and allowed for the selection of multiple options). However, with this particular example, there was no good way to display the questions in a SELECT menu. Each question had a unique primary key, of course, but that&#8217;s not very useful to the administrator. The questions did not have unique names (what name do you give a question?) and the best indicator of a question was its prompt, which would be HTML, possibly containing images and videos. So, again, how do I display possibly hundreds of questions in a meaningful way?</p>
<p>My solution was to show the list of questions by number and, when the admin clicks on a specific question, they&#8217;d see a preview of that question&#8217;s prompt (i.e., the HTML) in a separate interface. Now I&#8217;ve got three areas in my UI: one for adding or editing the other quiz attributes, one for listing every question, and a third for displaying the particulars of a single question. Given all this, I thought having the admin drag the questions from one area to another would be the best way to associate a question with a quiz. I could have done all this using <a href="http://www.jquery.com">jQuery</a> (the JavaScript framework Yii uses by default), but that would have taken me days to figure out how to use jQuery in this way. On the other hand, I knew I could develop this using <a href="http://www.adobe.com/go/flex">Flex</a> (a framework for creating Flash applications) in no time. I just didn&#8217;t know how to get Yii and Flash to play ball. It turns out not to be that hard&#8230;<span id="more-1151"></span></p>
<p>From a client-server perspective, the application required three services:</p>
<ul>
<li>The client fetches a list of questions from the server.</li>
<li>The client fetches a list of quizzes from the server (so that the user can update existing quizzes).</li>
<li>The client sends to the server a quiz-questions combination to be stored in the database.</li>
</ul>
<p>To keep things relatively simple, I decided to go with basic <strong>HTTPService</strong> calls rather than AMF (Action Message Format). AMF is better and preferred in many ways, but it introduces some logistical issues I wasn&#8217;t prepared to deal with yet. So the first thing I had to do was create Controller and View code for returning lists of information (the Models were already defined and, as should be the case, were untouched by this new functionality). In my QuestionController file, I created this method:</p>
<pre>public function actionXml() {
    $this-&gt;renderPartial('xml', array('models'=&gt;Question::model()-&gt;findAll()));
}</pre>
<p>All this function does is render the <em>xml</em> View, passing to it all of the <strong>Question</strong> Models. The View itself has to output XML data. For that reason, I use <strong>renderPartial()</strong> instead of <strong>render()</strong>, as I just want the individual View file to be rendered without the rest of the layout (i.e., without all the HTML, CSS, and JavaScript). I&#8217;ve seen some examples online where people just outputted the XML from within the Controller, but you really shouldn&#8217;t do that as it breaks the MVC architecture.</p>
<p>The <strong>xml.php</strong> View file looks like this:</p>
<pre>&lt;?php header("Content-Type: text/xml");
echo '&lt;?xml version="1.0" encoding="utf-8" ?&gt;'; ?&gt;
&lt;questions&gt;
&lt;?php foreach ($models as $model):?&gt;
    &lt;question&gt;
        &lt;id&gt;&lt;?php echo $model-&gt;id; ?&gt;&lt;/id&gt;
        &lt;prompt&gt;&lt;![CDATA[&lt;?php echo $model-&gt;prompt; ?&gt;]]&lt;/prompt&gt;
        &lt;answer1&gt;&lt;?php echo $model-&gt;answer1; ?&gt;&lt;/answer1&gt;
    &lt;/question&gt;
&lt;?php endforeach; ?&gt;
&lt;/questions&gt;</pre>
<p>The first line sends a <em>Content-Type</em> header to tell the client that the content is XML. Then the XML declaration is printed. Then the opening root tag is created, called <em>questions</em>. Next a <strong>foreach</strong> loop goes through each received Model. Within the loop I print whatever content needs to be sent to the client. This would be the question&#8217;s ID, its prompt, its possibly answers, etc. If the content might include any characters that are problematic in XML, including the ampersand, I would use this syntax, as in the <em>prompt</em> value:</p>
<pre>&lt;something&gt;&lt;![CDATA[&lt;?php echo $model-&gt;something; ?&gt;]]&gt;&lt;/something&gt;
</pre>
<p>The <strong>CDATA</strong> tags prevent text from being parsed as XML, thereby preventing problems with certain characters.</p>
<p>After I wrote this code for both of the services (the XML for the quizzes is quite similar), I tested the services in my Web browser by just going to <strong>http://<em>hostname</em>/question/xml </strong>and <strong>http://<em>hostname</em>/quiz/xml</strong>. By using a browser that understands XML, I can see the proper output before attempting to use my Flash client to connect to the service.</p>
<p>For the third service, data will be posted to the Yii-based site. In my <strong>QuizController</strong> file, I created a new method for this:</p>
<pre>public function actionFlash() {
}</pre>
<p>What this method really does is the same thing as the auto-generated <strong>actionUpdate()</strong> and <strong>actionCreate()</strong> methods, but some of the code will be different based upon how I&#8217;m sending data here from the Flash client, so I decided to create a new method instead. All this method needs to do is receive the data, associate it with a <strong>Quiz</strong> Model, then save the Model and report upon the results. One complication, however, is that when Yii creates a form for a Model, it&#8217;ll use names such as <strong>Quiz['prompt']</strong>. I didn&#8217;t know of an easy way to accomplish this when sending the data from Flash, so I just modified how the creation and updating happens. The first thing the method does is confirm that all of the values are received. In this hypothetical example, the values should be a quiz ID, a quiz name, and a list of questions associated with that quiz. So the method starts off with:</p>
<pre>if (isset($_POST['id'], $_POST['name'], $_POST['questions'])) {</pre>
<p>Next, the method checks if this is a new quiz (the Flash application allows for the creation of new quizzes) or an existing one. A new Model variable or existing Model is created depending upon this:</p>
<pre>if ($_POST['id'] == 0) {
    $model=new Quiz;
} else {
    $model=Quiz::model()-&gt;findbyPk($_POST['id']);
}</pre>
<p>Next, associate the incoming quiz name with the Model:</p>
<pre>$model-&gt;name = $_POST['name'];</pre>
<p>You would do this for any Model attribute that might have changed or be created for the first time. When using just Yii, the equivalent takes place using the Model&#8217;s attributes:</p>
<pre>$model-&gt;attributes=$_POST['Quiz']; // Or whatever Model.</pre>
<p>Then you save the Model:</p>
<pre>if ($model-&gt;save()) {</pre>
<p>This line will only work if all of the Model&#8217;s rules (i.e., its validations) are passed, so you don&#8217;t have to worry about invalid data getting into the system. Still, validation in the Flash client is a good idea, too.</p>
<p>The rest of the method just echo&#8217;s out messages based upon what happened:</p>
<ul>
<li><em>The quiz has been created.</em></li>
<li><em>The quiz has been updated.</em></li>
<li><em>The quiz could not be updated because of invalid data.</em></li>
<li>And so forth.</li>
</ul>
<p>There&#8217;s a bit more code in it as I the database has a <strong>QuizzesQuestions</strong> table which acts as an intermediary for the many-to-many relationship between the quizzes and the questions. (If you want to see the whole method, let me know.) This service, when called from the Flash client, will return a plain text message, which is why I just have the method echo out simple messages. Technically this also breaks the MVC architecture, but I didn&#8217;t feel like creating a new file that just said <em>The quiz has been created.</em></p>
<p>At this point I&#8217;ve created three Controller methods that send and receive the necessary data. Next up, I created the Flash client using the Flex framework and the Flash Builder IDE. The client interface was pretty basic Flex stuff. I created a <strong>DataGrid</strong> for displaying the quizzes. When a quiz is selected in the <strong>DataGrid</strong>, its particulars are displayed and become editable in a form. The form includes a <strong>List</strong> into which questions can be dropped. The existing questions are displayed in a separate <strong>List</strong>. When a question is selected in that <strong>List</strong>, its particulars are displayed in a separate <strong>Panel</strong>.</p>
<p>When the application first loads, the two XML services are called to populate the quiz <strong>DataGrid</strong> and the questions <strong>List</strong>. When the quiz form Button is clicked, the <strong>actionFlash()</strong> service is invoked, saving or creating the quiz accordingly. (The Flex side of this only took me an afternoon to complete, by the way.)</p>
<p>The most interesting thing about all this was tapping into Yii&#8217;s access control rules. The way the entire Web site is written, only logged-in administrators can do things such as create or update quizzes. So how do I ensure that only logged-in administrators can use the Flash application? Tapping into Yii&#8217;s authentication from Flash isn&#8217;t easy but it turns out not to be necessary. To start, in the <strong>QuizController</strong> file, I restrict access to the Flash application&#8217;s View file to only logged-in administrators. This, though, does not prevent the Flash application from doing anything (in theory, someone could load the Flash application separately, if they knew of its existence). What I do as well is restrict access to the XML and Flash actions (in the appropriate Controller files) to only logged-in administrators. This will also automatically prevent the Flash application, if being run by a non-administrator somehow, from accessing those services. Here&#8217;s why this works: the Flash application is running within a Yii-based page, so any request that the Flash application makes is the same as any request the browser itself makes (this is also true for Ajax requests). So Yii-related cookies that are stored in the browser after the user logs in are also passed along as part of the request. Tada! By just using the access control rules in the Controller, the Flash application can only invoke those services if the user is logged in as an administrator. Very simple! The only catch was that when developing the Flex application in Flash Builder, I wouldn&#8217;t be running and testing the Flash application as a logged-in administrator, so I had to make the Controller&#8217;s actions public during that time.</p>
<p>So there&#8217;s that experience, then! I was pleased with how easy this was to pull off (i.e., I was pleased how little thinking I had to do to make this work) and my client was pleased with the result. I hope this helps you in your Flash+Yii projects. Thanks for reading and please let me know if you have any questions or comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dmcinsights.com/2010/07/08/using-flash-with-yii/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Really Useful Tools For PHP Developers</title>
		<link>http://blog.dmcinsights.com/2010/07/04/really-useful-tools-for-php-developers/</link>
		<comments>http://blog.dmcinsights.com/2010/07/04/really-useful-tools-for-php-developers/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 06:54:00 +0000</pubDate>
		<dc:creator>Larry</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[utilities]]></category>

		<guid isPermaLink="false">http://blog.dmcinsights.com/?p=1060</guid>
		<description><![CDATA[I recently StumbledUpon an article on Really Useful Tools For PHP Developers at W3Avenue. The article doesn&#8217;t go into too many details, let alone provide specific instructions for any of the tools, but it&#8217;s nicely organized and presents a good list of useful PHP-related tools. The list ranges from development software to security utilities to [...]]]></description>
			<content:encoded><![CDATA[<p>I recently <a href="http://www.stumbleupon.com">StumbledUpon</a> an article on <a href="http://www.w3avenue.com/2009/08/26/really-useful-tools-for-php-developers/">Really Useful Tools For PHP Developers</a> at <a href="http://www.w3avenue.com">W3Avenue</a>. The article doesn&#8217;t go into too many details, let alone provide specific instructions for any of the tools, but it&#8217;s nicely organized and presents a good list of useful PHP-related tools. The list ranges from development software to security utilities to packages that will simply format your PHP code in a definitive style. Check it out if you&#8217;re a PHP developer; there are always new ways to make your work easier and the output better.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dmcinsights.com/2010/07/04/really-useful-tools-for-php-developers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Caching the Database Schema using MemCached with Yii</title>
		<link>http://blog.dmcinsights.com/2010/06/28/caching-the-database-schema-using-memcached-with-yii/</link>
		<comments>http://blog.dmcinsights.com/2010/06/28/caching-the-database-schema-using-memcached-with-yii/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 02:37:27 +0000</pubDate>
		<dc:creator>Larry</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[yii]]></category>

		<guid isPermaLink="false">http://blog.dmcinsights.com/?p=1142</guid>
		<description><![CDATA[I&#8217;ve just wrapped another project using the Yii framework (my fourth in the past year) and so I&#8217;ve got a few more topics to write about. I really like the Yii framework (obviously) and think it&#8217;s very accessible, but there are still things that take me some time to figure out, so those topics make [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just wrapped another project using the <a href="http://www.yiiframework.com">Yii framework</a> (my fourth in the past year) and so I&#8217;ve got a few more topics to write about. I really like the Yii framework (obviously) and think it&#8217;s very accessible, but there are still things that take me some time to figure out, so those topics make for good blog posts! In this one, I&#8217;ll walk through what I had to do to cache the database schema using memcached. For that matter, I&#8217;ll explain why you&#8217;d want to do this in the first place&#8230;<span id="more-1142"></span>The Yii framework bases its Models on a couple of different base classes. The most common for Models derived from database tables is <em>ActiveRecord</em>. ActiveRecord is a lovely design (it&#8217;s also used by <a href="http://www.rubyonrails.org">Ruby on Rails</a>) but isn&#8217;t so kind when it comes to performance: you see, in order for the framework to do anything with a particular Model, it must first run two queries:</p>
<ul>
<li>SHOW COLUMNS FROM tablename</li>
<li>SHOW CREATE TABLE tablename</li>
</ul>
<p>Again, to be clear, any use of, say, an <strong>Employees</strong> table requires these two commands be run first. If you have the related <strong>Employee</strong> and <strong>Department</strong> Models, a join across them requires four queries before any data is retrieved at all! And this is the downside of ActiveRecord: it does a lot of the work for you, but at a cost of performance. The hardest performance hit a Web site has comes from database queries, so minimizing or optimizing those is crucial. You can improve your Yii application&#8217;s performance by limiting how often these queries are run. To do so, you&#8217;ll need to <em>cache the database schema</em>.</p>
<p>Caching, to be clear, is the process of saving something for later so that it doesn&#8217;t need to be regenerated. For example, a dynamic PHP page can be cached as HTML so that the server can just send the static HTML instead of re-executing the PHP (and, most likely, the underlying database queries). <a href="http://www.yiiframework.com/doc/guide/caching.overview">Yii supports caching</a> in many ways, from caching specific bits of data to parts of a page to entire pages. One example of data you can cache is the database schema: how the database is defined. By caching that information, Yii won&#8217;t have to retrieve it by running two SHOW commands.</p>
<p>Before telling you how to do that, let&#8217;s tell Yii to reveal its inner workings to you. First of all, run your application in debugging mode by having these two lines in your <strong>index.php</strong> bootstrap file:</p>
<pre>defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);</pre>
<p>Those are written into the file by default but should be commented out or deleted entirely on a live server.</p>
<p>Then, in your <strong>protected/config/main.php</strong> configuration file, enable the <em>WebLog</em>:</p>
<pre>'log'=&gt;array(
    'class'=&gt;'CLogRouter',
    'routes'=&gt;array(
        array(
            'class'=&gt;'CFileLogRoute',
            'levels'=&gt;'error, warning',
        ),
        array(
            'class'=&gt;'CWebLogRoute',
        ),
    ),
),</pre>
<p>Now when you access any page in the Web browser, it&#8217;ll report a slew of information at the bottom of the screen. This is a log of whatever Yii is doing, from the loading of modules to the execution of database queries. Normally I&#8217;d show you an image of this here, but it&#8217;d be too revealing for my live sites! In this log, you&#8217;ll see the SHOW queries I already mentioned. To stop those from happening (most of the time), you&#8217;ll need to first tell Yii to cache the database schema. This is also done in the <strong>main.php</strong> configuration file, in the section for configuring the &#8220;db&#8221; component:</p>
<pre>'db'=&gt;array(
    'connectionString' =&gt; 'mysql:dbname=test',
    'schemaCachingDuration' =&gt; 3600,
    'emulatePrepare' =&gt; true,
    'username' =&gt; 'user',
    'password' =&gt; 'pass',
    'charset' =&gt; 'utf8',
),</pre>
<p>The <strong>schemaCachingDuration</strong> line needs to be added there. Assign to it a logical value, such as an hour (the value is in seconds, so 60 seconds times 60 minutes equals 3600). That line will enable caching of the database schema <em>but only if Yii has a caching component registered</em>! This is very important: if you follow these steps and don&#8217;t see the SHOW commands disappear from the Web trace log, the caching isn&#8217;t working.</p>
<p>To enable a cache, register a &#8220;cache&#8221; component (like &#8220;db&#8221;, this is also in the &#8220;components&#8221; section of the <strong>main.php</strong> configuration file):</p>
<pre>'cache' =&gt; array (
    'class' =&gt; 'CMemCache'
),</pre>
<p>The <strong>class</strong> value indicates which kind of cache you want to use. Options include <em>CMemCache</em> (memcached), <em>CApcCache</em> (APC), and <em>CDbCache</em> (which uses SQLite). A small book could be written about each cache type and how to get the most of them. For me, I went with memcached, which is a tool for storing data in memory. So I added this to my configuration file:</p>
<pre>'cache' =&gt; array (
    'class' =&gt; 'CMemCache',
    'servers'=&gt;array(
        array(
            'host'=&gt;'localhost',
            'port'=&gt;11211,
        ),
    ),
),</pre>
<p>Like connecting to a database, I specify a <em>host</em> and a <em>port</em>. To connect to memcached on the same computer, I use &#8220;localhost&#8221; and 11211 as the port (this is the standard). Once I&#8217;ve done this, if I re-run my Yii application, the SHOW queries will disappear (on the second request, because the first has to retrieve the data so that it can be cached).</p>
<p>So if you follow these steps, you can have Yii show you what it&#8217;s doing, then make some of that activity go away, but what does this mean in real-world performance? To test that, I turned to <a href="http://httpd.apache.org/docs/2.0/programs/ab.html">ApacheBench</a>, a command-line benchmarking tool. Assuming you have ApacheBench installed on your computer, you can use it with the command (note that you&#8217;re testing some other server from your computer):</p>
<pre>ab -n # -c # http://www.example.com</pre>
<p>The <strong>-n</strong> flag indicates the number of requests to make. The <strong>-c</strong> flag indicates the number of concurrent requests to make. This is great because no matter how fast you are with your browser, you can&#8217;t single handedly make multiple simultaneous requests of a server. You can also indicate a timelimit, send POST data along with each request, and so forth. As a basic test, I can see the results of my site for 100 requests in groups of 5:</p>
<pre>ab -n 100 -c 5 http://www.example.com</pre>
<p>You&#8217;ll get a bunch of information back, after a few seconds or minutes. You&#8217;ll see the number of complete and failed requests, which is nice, but the requests per second (RPS) is the most common benchmark for a site&#8217;s performance. In other words, this server can handle X number of requests for this URL per second. The more RPS, the better: it&#8217;s that simple.</p>
<p>There are a couple last tips to add, as these things can be confusing. First, <a href="http://memcached.org/">memcached</a> is the caching software that needs to be installed and running on the server. Second, PHP must be configured with support for <em>memcache</em> (no &#8220;d&#8221;), which is PHP&#8217;s extension for working with memcached. And, of course, memcached must be running. When I first tried to enable this (using Mac OS X Server), I wasn&#8217;t seeing any caching taking place, nor any error messages. So my next step was to use an <a href="http://us.php.net/manual/en/memcache.examples-overview.php">example from the PHP manual</a> to test PHP-memcache-memcached outside of Yii. That example indicated that PHP wasn&#8217;t able to connect to memcached. It turns out the reason was that the server didn&#8217;t have memcached installed! Once I installed and started memcached, I got the results I wanted.</p>
<p>Hopefully this will help you improve the performance of your Yii applications, too! Thanks for reading and let me know if you have any questions or comments.</p>
<p>Larry</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dmcinsights.com/2010/06/28/caching-the-database-schema-using-memcached-with-yii/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My Forthcoming E-Commerce Book, Rough Table of Contents</title>
		<link>http://blog.dmcinsights.com/2010/06/17/my-forthcoming-e-commerce-book-rough-table-of-contents/</link>
		<comments>http://blog.dmcinsights.com/2010/06/17/my-forthcoming-e-commerce-book-rough-table-of-contents/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 17:26:27 +0000</pubDate>
		<dc:creator>Larry</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[e-commerce]]></category>

		<guid isPermaLink="false">http://blog.dmcinsights.com/?p=1125</guid>
		<description><![CDATA[I am very pleased to say that I&#8217;ve just finished the rough draft of the Table of Contents for my forthcoming &#8220;E-Commerce with PHP and MySQL&#8221; book, to be published by New Riders Fall 2010. I&#8217;ve been wanting to do this book for some time (and was supposed to do it last year) and readers [...]]]></description>
			<content:encoded><![CDATA[<p>I am very pleased to say that I&#8217;ve just finished the rough draft of the Table of Contents for my forthcoming &#8220;E-Commerce with PHP and MySQL&#8221; book, to be published by New Riders Fall 2010. I&#8217;ve been wanting to do this book for some time (and was supposed to do it last year) and readers have been asking for it for even longer, so I&#8217;m really excited to get going on it finally.<span id="more-1125"></span></p>
<p>Many generous readers have provided their ideas and feedback in a <a href="http://www.dmcinsights.com/phorum/read.php?20,40748">forum thread</a> and an <a href="http://blog.dmcinsights.com/2009/01/29/my-forthcoming-e-commerce-book/#more-222">earlier blog post</a>. I&#8217;ve taken all of those opinions, plus my own thoughts, to come up with this first draft. The content (in terms of what I&#8217;m going to write about) is maybe 90% settled and the order of the chapters is about that, too. Many of the specifics, especially when it comes to chapter and section headings will most likely change. Hopefully it should be clear from the table of contents what the intentions are, but just in case&#8230;</p>
<p>The book is broken down into four parts. In the first part, which is just two chapters long, I talk about the fundamentals that will apply to any e-commerce project you take on. This starts with planning, choosing a host, development tools, etc. Security as a theory gets its own chapter and security will be hammered in throughout the entire book. But that security chapter covers the bigger picture and some gritty details with respect to choices that have big impacts (such as hosting).</p>
<p>In the second part of the book, I&#8217;ll walk through a complete e-commerce project, from HTML and database design to user management to handling payments through PayPal. There are three points to this first example:</p>
<ol>
<li>Understanding the basics in terms of design and the development process</li>
<li>Knowing how to perform user management and access control</li>
<li>Handling payments with a simple gateway like PayPal</li>
</ol>
<p>This e-commerce project would be digital/virtual content. The specific example would be a subscription access to the site (like what <a href="http://www.ConsumerReports.org">ConsumerReports.org</a> does) but it could also be PDFs that you sell or licenses for software or whatever. Anything that doesn&#8217;t have a limited quantity to be sold or that needs to be shipped. I&#8217;ll be using PayPal because it&#8217;s far and away the most common payment system, even if not everyone likes it. Google&#8217;s payment gateway would be comparable.</p>
<p>In the third part of the book, I&#8217;ll cover a second complete e-commerce project. This one will be a lot more complicated, with the focus on:</p>
<ul>
<li>Creating a product catalog</li>
<li>Creating a shopping cart</li>
<li>A multi-step checkout process, including shipping</li>
<li>A credit card payment gateway</li>
<li>Order and catalog administration</li>
</ul>
<p>This example wouldn&#8217;t specifically require user registration and logging in, but you could take the information taught in the second part to enable that feature here. I&#8217;ll try to make the thing being sold reasonably diverse (a range of products, not just a single thing).</p>
<p>The fourth part of the book will be add-ons and improvements. This is also the &#8220;if I have the space&#8221; section, which is to say that I&#8217;ll write about as much of this extra stuff as I have the available pages. I&#8217;ve organized these chapters in terms of most universally useful, starting with a search engine and then going into marketing. There&#8217;s a lot of possible topics in the marketing section, from SEO, to product recommendations and reviews, to analytics. Next up is a chapter on using Ajax to improve the user experience. There should be room for those three chapters in the printed edition of the book.</p>
<p>The final three chapters, in this rough table of contents, are definitely &#8220;if there&#8217;s space&#8221;. If not, I&#8217;ll write about them in this blog. Instead of offering entirely new concepts, the last three chapters would be alternative ways to do things you&#8217;ve already seen to that point: expanding the depth of the content, not its breadth. First up would be other gateways, as that&#8217;s a vital part of the process and there are many good options out there. Next would be a chapter on Object-Oriented Programming (OOP), in which I rewrite some of the book&#8217;s code using OOP. Many people really want to see OOP in the book, many absolutely don&#8217;t, so as a middle ground my theory is to add an OOP chapter that translates procedural code in an understandable way. The final chapter, which I&#8217;ll admit there probably won&#8217;t be room for, would present alternative database schemas for other kinds of e-commerce applications.</p>
<p>All that being said, here&#8217;s the current rough table of contents. I welcome all comments, questions, and thoughts!</p>
<ul>
<li>Introduction</li>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><strong>Part 1: Fundamentals</strong></p>
<li><strong>Chapter 1: Getting Started</strong>
<ul>
<li>Identifying Your Business Goals</li>
<li>Legal/Business Issues</li>
<li>Choosing Web Technologies</li>
<li>Getting a Host</li>
<li>Development Tools</li>
<li>The Development Process</li>
</ul>
</li>
<li><strong>Chapter 2: Security Fundamentals</strong>
<ul>
<li>Hosting Implications</li>
<li>Payment Considerations</li>
<li>Secure Transactions</li>
<li>Protecting Information</li>
</ul>
</li>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<strong><br />
</strong></p>
<p><strong>Part 2: The Digital Content Example</strong> (Rename)</p>
<li><strong>Chapter 3: Site Structure and Design</strong>
<ul>
<li>HTML</li>
<li>Server Organization</li>
<li>Database Design</li>
</ul>
</li>
<li><strong>Chapter 4: Handling Payments with PayPal</strong></li>
<li><strong>Chapter 5: User Management</strong>
<ul>
<li>Registration</li>
<li>Login</li>
<li>Access Control</li>
<li>Updating Accounts</li>
</ul>
</li>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<strong><br />
</strong></p>
<p><strong>Part 3: The Physical Content Example</strong> (Rename)</p>
<li><strong>Chapter 6: Site Structure and Design 2</strong>
<ul>
<li>HTML</li>
<li>Server Organization</li>
<li>Database Design</li>
</ul>
</li>
<li><strong>Chapter 7: Creating a Catalog</strong>
<ul>
<li>Browsing by category</li>
<li>Highlighting new products</li>
<li>Creating Sales and Discounts</li>
</ul>
</li>
<li><strong>Chapter 8: Starting Orders</strong>
<ul>
<li>Creating a Shopping Cart</li>
<li>Shopping Cart Managment</li>
<li>Shipping</li>
<li>Finalizing Purchases</li>
</ul>
</li>
<li><strong>Chapter 9: Checking Out</strong>
<ul>
<li>Credit Card Payment Gateway</li>
<li>Storing Orders</li>
<li>Email Status/Receipts</li>
<li>Checking Order Status Online</li>
</ul>
</li>
<li><strong>Chapter 10: Administration</strong>
<ul>
<li>Authentication</li>
<li>Stock Management</li>
<li>Reports/Graphs</li>
</ul>
</li>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<strong><br />
</strong></p>
<p><strong>Part 4: Extra Touches</strong></p>
<li><strong>Chapter 11: Building a Search Engine</strong></li>
<li><strong>Chapter 12: Marketing</strong>
<ul>
<li>Search Engine Optimization</li>
<li>Adding Ads</li>
<li>Product Recommendations</li>
<li>Notify when product is available</li>
<li>Reviews</li>
<li>Newsletters</li>
<li>Customer Help</li>
<li>Tracking referrers/Analytics</li>
</ul>
</li>
<li><strong>Chapter 13: Adding Ajax</strong>
<ul>
<li>cart management in sidebar</li>
<li>comments/reviews</li>
<li>ratings</li>
<li>purchasing</li>
</ul>
</li>
<li><strong>Chapter 14: Alternative Gateways</strong></li>
<li><strong>Chapter 15: Using OOP</strong></li>
<li><strong>Chapter 16: Alternative Database Schemas</strong></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.dmcinsights.com/2010/06/17/my-forthcoming-e-commerce-book-rough-table-of-contents/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Email Validation in PHP</title>
		<link>http://blog.dmcinsights.com/2010/06/10/email-validation-in-php/</link>
		<comments>http://blog.dmcinsights.com/2010/06/10/email-validation-in-php/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 06:15:47 +0000</pubDate>
		<dc:creator>Larry</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.dmcinsights.com/?p=1094</guid>
		<description><![CDATA[A very common need in PHP-based Web applications is to validate email addresses. An email address, at its most basic contains the @ and a dot and no spaces or special characters, so it&#8217;s pretty easy coming up with a regular expression that will fit this most simple restriction. However, if you want a full-on [...]]]></description>
			<content:encoded><![CDATA[<p>A very common need in PHP-based Web applications is to validate email addresses. An email address, at its most basic contains the @ and a dot and no spaces or special characters, so it&#8217;s pretty easy coming up with a regular expression that will fit this most simple restriction. However, if you want a full-on precise regular expression, that takes an immense amount of code (the full email validation pattern takes up almost a page of code). An alternative, then is to use the <strong>EmailAddressValidation</strong> class, created by <a href="http://www.addedbytes.com/blog/email-address-validation-v2/">Added Bytes</a> and now hosted on <a href="http://code.google.com/p/php-email-address-validation/">Google Code</a>.</p>
<p>After you&#8217;ve downloaded the code and put it on your server, you use it like so:</p>
<pre>require('/path/to/EmailAddressValidator.php');
$emailValidator = new EmailAddressValidator();
if ($emailValidator-&gt;check_email_address('test@example.org')) {
    // Email address is technically valid.
} else {
    // Email not valid.
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.dmcinsights.com/2010/06/10/email-validation-in-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Death of PHP 6/The Future of PHP 6</title>
		<link>http://blog.dmcinsights.com/2010/05/25/the-death-of-php-6the-future-of-php-6/</link>
		<comments>http://blog.dmcinsights.com/2010/05/25/the-death-of-php-6the-future-of-php-6/#comments</comments>
		<pubDate>Wed, 26 May 2010 02:35:34 +0000</pubDate>
		<dc:creator>Larry</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[php6]]></category>

		<guid isPermaLink="false">http://blog.dmcinsights.com/?p=1067</guid>
		<description><![CDATA[About two months ago, Johannes Schlüter posted about the Future of PHP 6. Schlüter works for MySQL (and therefore Oracle-Sun) and is an active and involved member of the PHP team. In his post, Schlüter discusses the difficult choices facing PHP with respect to the intended version 6 and its support for Unicode. In turns [...]]]></description>
			<content:encoded><![CDATA[<p>About two months ago,  Johannes Schlüter posted about the <a href="http://schlueters.de/blog/archives/128-Future-of-PHP-6.html">Future of PHP 6</a>. Schlüter works for MySQL (and therefore Oracle-Sun) and is an active and involved member of the <a href="http://www.php.net">PHP</a> team. In his post, Schlüter discusses the difficult choices facing PHP with respect to the intended version 6 and its support for Unicode. In turns out that changing all of PHP to support Unicode isn&#8217;t as easy as one would have thought. And, of course, it was originally considered to be, well, hard. Apparently, this struggle is the reason PHP 6 is still nowhere to be found (in fact, the source code has slowly been disappearing from <a href="http://snaps.php.net">PHP&#8217;s snaps site</a>). So now, the PHP team is regrouping in order to go forward and we&#8217;re not exactly sure when or how Unicode support will be integrated into PHP, or how this change affects the next few versions of PHP, both minor (i.e., 5.3) and major (6 and 7).</p>
<p>As a person that <a href="http://www.amazon.com/PHP-MySQL-Dynamic-Web-Sites/dp/032152599X/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1274841177&amp;sr=8-1">wrote a book on PHP 6 </a>quite some time ago, and has looked more and more silly over time, I&#8217;m happy to hear this news, even if we don&#8217;t yet know what the end result will be. Granted, most of that book uses PHP 5 and PHP 6 (the version that was available when I wrote it) is only required by like 5-10% of the material, but still&#8230;lesson learned on my part: especially when it comes to open source software, there&#8217;s just no predicting what&#8217;s going to happen next. So, for the time being, let&#8217;s be happy with the PHP we have and keep an eye on where the development team goes with this. I know I sure will!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dmcinsights.com/2010/05/25/the-death-of-php-6the-future-of-php-6/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Yii Framework&#8217;s New Gii Tool</title>
		<link>http://blog.dmcinsights.com/2010/05/18/yii-frameworks-new-gii-tool/</link>
		<comments>http://blog.dmcinsights.com/2010/05/18/yii-frameworks-new-gii-tool/#comments</comments>
		<pubDate>Tue, 18 May 2010 19:08:14 +0000</pubDate>
		<dc:creator>Larry</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[yii]]></category>

		<guid isPermaLink="false">http://blog.dmcinsights.com/?p=1062</guid>
		<description><![CDATA[Version 1.1.2 of the Yii framework came out a couple of weeks ago (May 2, 2010) and it&#8217;s main new feature is Gii. Gii is a Web-based alternative to the yiic command-line tool. Both yiic and Gii are used to generate code in existing Yii Web applications. For example, you create the database for a [...]]]></description>
			<content:encoded><![CDATA[<p>Version 1.1.2 of the <a href="http://www.yiiframework.com">Yii framework</a> came out a couple of weeks ago (May 2, 2010) and it&#8217;s main new feature is <a href="http://www.yiiframework.com/doc/guide/topics.gii">Gii</a>. Gii is a Web-based alternative to the yiic command-line tool. Both yiic and Gii are used to generate code in existing Yii Web applications. For example, you create the database for a project, then use the command-line yiic tool to generate the shell of the project (its directory, configuration files, subdirectories, etc.), and then you would turn to Gii in the Web browser to create Model, Controller, and View files, along with the standard CRUD functionality. I&#8217;ll write more about Gii soon, but in the meantime, check out the previous <a href="http://www.yiiframework.com/doc/guide/topics.gii">Gii</a> link or <a href="http://www.yiiframework.com/doc/guide/quickstart.first-app">this part of the quickstart documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dmcinsights.com/2010/05/18/yii-frameworks-new-gii-tool/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
