<?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 &#187; yii</title> <atom:link href="http://www.larryullman.com/tag/yii/feed/" rel="self" type="application/rss+xml" /><link>http://www.larryullman.com</link> <description>Translating Geek Into English</description> <lastBuildDate>Sun, 05 Feb 2012 17:48:42 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>My January 2012 Non-Resolutions List</title><link>http://www.larryullman.com/2012/01/03/my-january-2012-non-resolutions-list/</link> <comments>http://www.larryullman.com/2012/01/03/my-january-2012-non-resolutions-list/#comments</comments> <pubDate>Wed, 04 Jan 2012 04:12:41 +0000</pubDate> <dc:creator>Larry</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[book]]></category> <category><![CDATA[phpvqp3]]></category> <category><![CDATA[textmate]]></category> <category><![CDATA[writing]]></category> <category><![CDATA[yii]]></category><guid
isPermaLink="false">http://www.larryullman.com/?p=2947</guid> <description><![CDATA[I&#8217;ve never been much of a New Year&#8217;s Resolution person: if something is important enough to do, start today, not on some arbitrary date that happens to be the first day of the year. (Or, you know, January 2nd, because the first is a holiday and all.) But this year I happen to have quite [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;ve never been much of a New Year&#8217;s Resolution person: if something is important enough to do, start today, not on some arbitrary date that happens to be the first day of the year. (Or, you know, January 2nd, because the first is a holiday and all.) But this year I happen to have quite a long non-resolutions list. The timing is entirely coincidental: I just happen to be almost done with my <em>Modern JavaScript: Develop and Design</em> book, and I always have a long list of things to do between books. I only have two more chapters to write on this book, and the end is in site!</p><p>In a recent newsletter, I <a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#qa2">answered a question about how I spend my time between projects</a>. For me, the biggest projects I have, in terms of stress and time consumption, are the books I write. The client projects&#8211;Web development and such, no matter how big or complicated, never seem to be that much of a burden. Mostly this is because I find programming to be much easier than writing about programming, and because it&#8217;s fun to make things happen, to implement new concepts. Over the course of a year, I&#8217;ll work on any number of projects, ranging from consulting a couple of hours here or there (i.e., helping to steer the actual developers) to doing all of the development myself. When these bigger projects are done, I&#8217;m pleased to have them off of my list, but there&#8217;s never the huge sigh of relief that I have when I&#8217;ve finished a book. And that sigh says: now I can do these other 20 things that have been waiting for me!</p><p>With the completion of the JavaScript book on the horizon, I&#8217;ve been making my January to-do list, and salivating over all the things I&#8217;ll be getting done. Certainly, what I will actually do won&#8217;t be nearly as long as this list, but one can dream, no? My next deadline isn&#8217;t until this summer, which is when I have to turn in the third edition of my <em>PHP 5 Advanced: Visual QuickPro Guide</em> book. Although I&#8217;d like to, for a change, get that book done well in advance! Still, I have a bit of time to really put a dent in my &#8220;someday&#8221; to-do list.</p><p>First on my list is to exercise more often. I feel like I&#8217;ve gained five pounds for every book I&#8217;ve written (all that sitting), and while I&#8217;ve exercised more than never over the past few months, I&#8217;d like to do much, much better. We could all probably use more exercise!</p><p>After exercise, which is a daily and on-going goal, I&#8217;ve grouped my dream tasks into four categories:</p><ul><li>Things to work on</li><li>Books to read</li><li>Work things I really should get done</li><li>Personal things I really should get done</li></ul><p>The last category is of little interest to you, I imagine, or wouldn&#8217;t mean much regardless (mostly construction projects around the house). The work things I really should get done are those things that don&#8217;t get done during my books and big projects. For January, this primarily means creating an HTML5 version of this site&#8217;s design, plus a corresponding version for my forum. Before I redid this site in October of 2010, the site had become woefully outdated and I want to insure that doesn&#8217;t happen again. If time allows, I&#8217;ll do a mobile version, too, and make sure everything is performing as well as can be.</p><p>The books to read are both personal and work related. I want to read one or two parenting books, a novel, and some work-related books. I&#8217;m specifically looking to read <em><a
href="http://www.amazon.com/Pragmatic-Programmer-Journeyman-Master/dp/020161622X/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1325649567&amp;sr=1-1">The Pragmatic Programmer</a></em> by Hunt and Thomas first. I&#8217;ve heard good things about it. Then, coincidentally, I have a couple of ebooks from <a
href="http://pragprog.com/">The Pragmatic Bookshelf</a> on my computer awaiting a few moments of time. As I read these, I&#8217;ll no doubt be posting my thoughts about them here.</p><p>Finally, there&#8217;s my &#8220;things to work on&#8221; category, which is a broad category of topics without definitive targets or concrete tasks. Normally these items are a matter of improving my skills in specific areas. Right now I&#8217;m thinking honing my abilities and knowledge with respect to <a
href="http://www.obdev.at/products/launchbar/index.html">Launchbar</a> and <a
href="http://macromates.com/">TextMate</a>, two Mac apps I use all the time. I know for a fact that I&#8217;m underutilizing both. The time I spend improving my skills with them now will pay dividends over the rest of the year. As time allows, I also plan on continuing to write my Yii book, although I&#8217;ll probably do that as blog posts, too.</p><p>So there are my January 2012 non-resolutions. Which will likely also be my February 2012 non-resolutions. Sadly, at least a quarter of them will end up on my September 2012 resolutions, too!</p><p><strong>UPDATE</strong>: I just literally finished all the work on the <em>Modern JavaScript: Develop and Design</em> book yesterday, so thus far, I&#8217;ve done pretty much none of the things on my list, including exercise more. Ugh. But how about that February list&#8230;</p> ]]></content:encoded> <wfw:commentRss>http://www.larryullman.com/2012/01/03/my-january-2012-non-resolutions-list/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>What Is Larry Thinking? #47 =&gt; Random Monkey Appearances</title><link>http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/</link> <comments>http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#comments</comments> <pubDate>Mon, 21 Nov 2011 04:21:41 +0000</pubDate> <dc:creator>Larry</dc:creator> <category><![CDATA[Flex]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[jsdd]]></category> <category><![CDATA[mongodb]]></category> <category><![CDATA[newsletter]]></category> <category><![CDATA[nosql]]></category> <category><![CDATA[phpmysql4]]></category> <category><![CDATA[yii]]></category><guid
isPermaLink="false">http://www.larryullman.com/?p=2869</guid> <description><![CDATA[In this edition… About This Newsletter What Were You Thinking? =&#62; Using JavaScript On the Web =&#62; Introduction to MongoDB On the Web =&#62; The Protocol-Relative URL On the Web =&#62; 10 Steps to Becoming a Great Web Developer On the Blog =&#62; My Yii Book Update On the Blog =&#62; Adobe&#8217;s Significant Flash and [...]]]></description> <content:encoded><![CDATA[<p>In this edition…</p><ul><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#about">About This Newsletter</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#you">What Were You Thinking? =&gt; Using JavaScript</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#web1">On the Web =&gt; Introduction to MongoDB</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#web2">On the Web =&gt; The Protocol-Relative URL</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#web3">On the Web =&gt; 10 Steps to Becoming a Great Web Developer</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#blog1">On the Blog =&gt; My Yii Book Update</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#blog2">On the Blog =&gt; Adobe&#8217;s Significant Flash and Flex Changes</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#qa1">Q&amp;A =&gt; How Do You Choose Between Competing Technologies?</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#qa2">Q&amp;A =&gt; How Do You Spend Time Between Projects?</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#thinking">What is Larry Thinking =&gt; Starting a New Project</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#giveaway">Book Giveaway =&gt; “PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide” (4th Edition)</a></li><li><a
href="http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/#news">Larry Ullman&#8217;s Book News =&gt; “Modern JavaScript: Develop and Design”</a></li></ul><p><span
id="more-2869"></span></p><h2 id="about">About This Newsletter</h2><p>Hello, hello. Not a very cohesive theme in this newsletter, but in it, I write about: Web development technologies, how to start new projects, and how to spend one’s downtime. Oh, and there’s one of those bookgiveawaythingies that y’all like so much!</p><p>As always, questions, comments, and all feedback are much appreciated. And thanks for your interest in what I have to say and do!</p><h2 id="you">What Were You Thinking? =&gt; Using JavaScript</h2><p>In <a
href="http://www.larryullman.com/2011/10/21/what-is-larry-thinking-46-javascript-sexism-and-bad-user-interface/#you">my previous newsletter</a>, I asked for input as to how <em>you</em> use JavaScript, what you know you’re confused by, what you’d like to learn more about, and so forth. I received oodles of replies, which were very much appreciated. I haven’t responded to quite everyone yet, but do plan to still. And all respondents are going into a pool of candidates for a free copy of the book when I have my copies to give away (that looks like February now, or thereabouts).</p><p>The bulk of the responses emphasized that I just need to do what I do normally, but this time for JavaScript. In other words, there’s a certain way that I go about presenting technical information that seems to work for many people, and I need to be true to those inclinations. That’s quite flattering and reassuring, as I often second-guess myself when writing new books. It’s also a good reminder not to over extend myself or the book, and as I do the rewrites I’ll be certain to adjust accordingly.</p><p>I remember that when I first started writing computer books, I looked at the books that were out there, and many writers seem to want to impress the reader with what she or he (i.e., the writer) knows. Maybe wasn’t the intent, and maybe other writers just have a broader sense of what readers need to know than I do. In any case, my belief has always been that <em>a technical book isn’t about what I know but about what you, the reader, needs to know</em>. Further, it’s not my aim to impress you with my knowledge, but for you to be impressed by what you’ve managed to learn and do. So, as I finish the JavaScript book and perform the rewrites, this is a good reminder for me to keep the content simple (-ish), straightforward, and, above all, useful. When I question if some tip or sidebar is too advanced or unnecessary, that’s probably an indicator that it is.</p><p>A good idea that came up a couple of times is to demonstrate and discuss key JavaScript libraries. The book will already introduce some frameworks, but I think libraries merit coverage, too. I’m also now debating doing a chapter on mobile JavaScript. I’m leaning towards doing one, but am pressed for time.</p><p>Finally, a couple of people have volunteered to act as proofreaders on the book. The offer is much appreciated, and something I would have definitely taken advantage of if I was self-publishing. However, as this book is going through a traditional publisher, there are already several proofreaders involved. Adding more proofreaders might help catch a thing or two, but would further overwhelm me (it takes a lot of work to assign chapters, read feedback, and so forth) and I’m already so very behind. But I thank everyone again for their offers to help.</p><p>And my thanks once again to everyone for their thoughts and feedback. If you have any more suggestions, please keep them coming!</p><h2 id="web1">On the Web =&gt; Introduction to MongoDB</h2><p><a
href="http://phpmaster.com/">phpmaster</a> recently posted an article titled <a
href="http://phpmaster.com/introduction-to-mongodb/">Introduction to MongoDB</a>. I’m not entirely sold on non-relational databases yet, in that while I can see how wonderfully beneficial they can be in many situations, they’re not as ubiquitously useful as all the hype would seem to suggest. But in any case, a good article like this one is worth the time to read. The article introduces <a
href="http://www.mongodb.org/">MongoDB</a>, shows how to install support for it in PHP (although the instructions are for Unix-like systems), and provides code for actually interacting with a MongoDB database.</p><h2 id="web2">On the Web =&gt; The Protocol-Relative URL</h2><p>Some time back, I came across this excellent nugget of information that <a
href="http://paulirish.com/">Paul Irish</a> has put forth about the <a
href="http://paulirish.com/2010/the-protocol-relative-url/">protocol-relative URL</a>. I don’t want to reveal the details here (it’s a short article, and you ought to read it), but the gist is that there’s a very simple way to link CSS, images, JavaScript, and whatever other resources so that they’ll be served over HTTP on HTTP pages and provided over HTTPS on HTTPS pages. I wish I had thought to use this when I wrote <a
href="http://www.larryullman.com/books/effortless-e-commerce-with-php-and-mysql/">my e-commerce book</a> (instead of using two different header files)! Sometimes the simple solution is the most brilliant one…</p><h2 id="web3">On the Web =&gt; 10 Steps to Becoming a Great Web Developer</h2><p>I just recently Stumbled Upon an article titled <a
href="http://komunitasweb.com/2009/10/10-steps-to-becoming-a-great-web-developer/">10 Steps to Becoming a Great Web Developer</a>. Even though the article is two years old, I think it does a great job of laying out the steps one would take to become a Web developer, starting with the basics of HTML, then moving into a server-side technology, and then getting into SQL, CSS, and JavaScript. On the higher end, there are regular expressions, Unix/Linux commands and administration, Web servers, version control, and frameworks. I would question some of the specific resources mentioned, but overall this is a nicely presented list and I can’t argue with the order. Two years later, perhaps the only thing I would add would be to start learning about mobile Web development, and a commenter on my original blog posting suggested XML and JSON, which would be good additions, too.</p><h2 id="blog1">On the Blog =&gt; My Yii Book Update</h2><p>In my blog and in these newsletters, I’ve informally mentioned my intent to write a book on the <a
href="http://www.yiiframework.com">Yii framework</a>. In theory, I would be writing it about now, but I’m very much behind on my JavaScript book so that’s not happening at the moment. I have been receiving more questions about this potential book, so I recently posted <a
href="http://www.larryullman.com/2011/11/03/my-yii-book-update/">a quick update</a> on the reasons for the book, how I plan on doing it, and when that might actually happen.</p><p>Thanks to anyone interested in that book!</p><h2 id="blog2">On the Blog =&gt; Adobe&#8217;s Significant Flash and Flex Changes</h2><p>I just <a
href="http://www.larryullman.com/2011/11/17/adobes-significant-flash-and-flex-changes/">posted the following on my blog today</a>, and thought I’d share it here since it’s so topical…</p><p>Last week, or thereabouts, Adobe announced that it was discontinuing support for Flash on mobile devices. This is, by all accounts, a wave of the white flag in Adobe’s battle against Apple and its iOS devices (if only Steve Jobs were alive today to celebrate). I didn’t think too much of that decision: it does make sense to use HTML5 or native apps for dynamic content to be run on mobile devices anyway. And Flash would still continue to run on desktops, where something like 99% of browsers have the plug-in and 90-some% of video is run through Flash. Flash is such a large component of Adobe’s various technologies that I can’t imagine Adobe leaving it behind.</p><p>And then Adobe announced today that it was offering Flex to the Apache Software Foundation (managers of the ubiquitous Apache Web server, among other projects).  Apache will need to vote on whether to accept Flex or not. This announcement does surprise me, as Flex is used not only for Flash creation, but also desktop and mobile application development via the AIR platform. Adobe says it will continue to support Flash and Flex, but clearly Adobe is moving more towards HTML5.<br
/> An interesting, and rather big, development. One does not normally think of a technology with such a large market share being outright dropped. We shall see how this plays out…</p><h2 id="qa1">Q&amp;A =&gt; How Do You Choose Between Competing Technologies?</h2><p>Richard emailed me recently, asking how I approach the situation where two competing technologies can be used for a given project. With his specific example, Richard was trying to decide between using HTML5 or Flash for an animated game. Assuming that both technologies were equally capable of performing the task, how does one make the choice? In simplest terms, Flash will provide the same experience for all users, so long as their browser supports Flash. This, unfortunately, rules out most (and as recently announce, all) mobile devices. Conversely, HTML5 will work equally well on all modern browsers, but will not work at all on older ones.</p><p>In response to Richard, I came up with two criteria for making any decision as to what technology to use for a project. First, one has to determine <em>what technologies can achieve the task</em>. Sometimes that alone makes the decision for you, when there’s only one possible solution. Considering the range of technologies and programming languages out there, this is rarely the case these days. For example, for a while, one could only develop iOS apps using Objective-C. But in most situations, there will be more than one option.</p><p>The next question is twofold then: <em>who is the target audience</em> and <em>what needs to be supported</em>? In this particular example, if the target audience is mobile users and outdated browsers don’t need to be supported, then HTML5 makes sense. If the target audience is all desktop users and mobile devices don’t need to be supported, then Flash. If everyone needs to be supported, then <em>both technologies</em> is the best solution.</p><p>With my own work, I normally aim for the broadest support over the newest thing, unless the point <em>is</em> the newest thing (e.g., you can’t make a site about HTML5 and have it be backwards compatible). I’m really not on the cutting edge of technologies, as many people are. I may be relatively on the cutting edge of <em>useful</em> technologies, but my goal is always to use the best tool, not the coolest one.</p><p>A third criteria that I failed to include in my reply to Richard, but is worth considering, is what technology you, the developer, are strongest with. Now, to be clear, this should not have a significant impact on the decision. I’ve seen people use technologies for the wrong tasks too many times, simply because that was the technology the person knew best (e.g. creating graphical desktop applications with PHP, which is possible, but not wise). My point with this criteria is that if you have two comparable choices and you’re stronger with one, then use that by all means. The project will go faster and the end result will be better.</p><h2 id="qa2">Q&amp;A =&gt; How Do You Spend Time Between Projects?</h2><p>David posed this question, asking me specifically, I believe (as opposed to asking for general advice towards this end). Being me, I’ll both answer for myself and give some advice.</p><p>When you work for yourself, the time between projects is especially important. For starters, this is time you’re not making money, so it needs to be used wisely. But if you treat the time between projects as an investment in yourself, and therefore your business, hopefully the period without money coming in will pay off in time. I don’t actually have much time off between projects, which is both a good thing (i.e., I’m busy making money) and a bad thing (I’m stressed and secondary things aren’t getting done). But when I do have downtime, at that moment, I look to the past and I look to the future.</p><p>In terms of the past, downtime between projects is when you should make sure that you’ve done everything that needs to be done but got put on the back burner while you were toiling away. This can be replying to emails, doing a little something for a client that wasn’t a priority, and updating your own Web site, LinkedIn profile, and so forth. When I overhauled my Web site a year ago, I was aghast by how out of date and unhelpful it had become. Having such public, poor representations of yourself out there is bad for business in the long run, even if only a little bit. You should have some sort of task management application, and in it you should keep a running list of “high priority someday” tasks, such as those I’ve just mentioned. Complete as many of these as you can as soon as your downtime begins, because if you don’t do it then, when will you?</p><p>In terms of the future, it’s largely a matter of improving one’s skills, whether that means learning something new or solidifying existing knowledge. In my task management application, I have a running list of topics that I’m interested in (these are non-high-priority-but-someday tasks). I take some time to investigate those during these little breaks.</p><p>Finally, I think it’s really important to recharge one’s batteries during these downtimes, whatever that may mean for you. To me, that primarily means getting away from my computer and doing something active. Part of the reason that I suspect I’m struggling in completing this JavaScript book is that I didn’t have enough (well, any) downtime between it and the previous book I wrote.</p><p>Time spent not working may seem like time spent not getting things done and not making money, but there’s a lot to be said for having some recovery time between projects. And I think, perhaps unmeasurably, such downtimes reap their own benefits in the long run.</p><h2 id="thinking">What is Larry Thinking? =&gt; Starting a New Project</h2><p>Last week, a friend came over to my house, hoping to learn about Web development. This friend has almost completed her PhD from Cornell in computer science, has taught college-level classes on programming languages, and worked at Google, too, so her technical knowledge is excellent, probably exceeding mine. She’s wanting to learn Web development, and while she has had no problems picking up the syntax and fundamentals of PHP, the big picture of Web development was eluding her. We went over a few things and, at one point, she asked how I had learned this or that. And, to be completely honest, I’ve been doing this long enough now, and my memory regarding my own development is sketchy at best, that I couldn’t answer her. But I can certainly recall that starting a big Web project, especially when you’re just beginning, is a daunting enough task as to be overwhelming, and perhaps you, too, don’t know where to begin.</p><p>Simply put, projects are a combination of <em>data</em>, <em>functionality</em>, and <em>presentation</em>. Games have a lot more of the latter two and many Web-based projects focus on the data, but those are the three elements, in varying percentages. When you go to begin a new project, it’s in one of these three areas that you must begin. And you should always start with the functionality, as that dictates everything else.</p><p>The functionality is what a Web site or application must be able to do, along with the corollary of what a user must be able to do with the Web site or application. The functionality needs to be defined in advance, and ought to be clearly stipulated in the contract (when there is one). Use a paper and pen (or note-taking application), and write down everything the project requires:</p><ul><li>Presentation of content</li><li>User registration, login, logout</li><li>Search</li><li>Rotating banner ads</li><li>Random monkey appearances</li><li>Et cetera</li></ul><p>Try your best to be exhaustive, and to perform this task without thinking of files and folders, let alone specific code. Be as detailed as you can about what the project has to be able to do, down to such things as:</p><ul><li>Show how many users are online</li><li>Cache dynamic pages for improved performance</li><li>Not use cookies or only use cookies</li><li>Have sortable tables of data</li></ul><p>The more complete and precise the list of requirements is, the better the design will be from the get-go, and you’ll need to make fewer big changes as the project progresses.</p><p>Once you’ve come up with the functionality (with the client, too, if one exists), it’s time to start coding and creating files and folders. You can start that process from one of two directions: the data or the presentation. I’m a data-first person, but let’s look at the presentation side to start.</p><p>If you’re a designer, or are working with clients that think in visual terms primarily, it makes sense to begin any new project in terms of how it will look. You may want to start with a wireframe representation, or actual HTML, but create a series of pages that provides a usable bases for how the site will appear from a user interface perspective. You don’t need to create every page, and in a dynamically-driven site you actually shouldn’t, but address the key and common components. The end goal is the HTML, CSS, and media, in a final or nearly-final state. Once you’ve done that, and the client has accepted it, you can work your way backwards through the functionality and data.</p><p>If you’re a developer, like me, incapable of thinking in graphical terms, it makes sense to begin any new project from the perspective of the data: what will be stored and how the stored information will be used. For this task, you’ll want to use a paper and pen, or a modeling tool such as the <a
href="http://www.mysql.com/products/workbench/">MySQL Workbench</a>, but the goal is to create a database schema. Always err on the side of storing too much information, and always err on the side of pure normalization (when using a relational database). Once you’ve done that, I normally populate the database with some sample data. This allows me to then create the functionality that ties the data into a sample presentation. By doing so, I, and the client, can confirm that it’s looking and working as it should. From there, you can implement more functionality, and then have the presentation finalized.</p><p>So that’s the process in a nutshell.</p><h2 id="giveaway">Book Giveaway =&gt; “PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide” (4th Edition)</h2><p><em>You must be subscribed to the newsletter to qualify for the book giveaway.</em></p><h2 id="news">Larry Ullman’s Book News =&gt; “Modern JavaScript: Develop and Design”</h2><p>I just submitted Chapter 8 of “Modern JavaScript: Develop and Design”, which means I’m about 50% done with the first draft (well, first submitted draft: there are multiple internal drafts prior to that). Progress is still going more slowly than I’d like, but… I always hope I’m about to turn a corner and speed up and one of these days, I will. In fact, I’ve got another deadline to shoot for (having blown past the original), so I will be doing everything I can to get this done ASAP. If anyone knows how to put more hours in the day, or days in the week, please let me know!</p><p>Since my last newsletter, I’ve written chapters on: arrays and objects (Chapter 6); functions (Chapter 7); and events (Chapter 8). Next is Chapter 9, on the browser (including CSS and DOM manipulation), Chapter 10, on forms, and Chapter 11, on Ajax. With the core concepts of JavaScript behind me (really, Chapters 4-7), these chapters are getting into more interesting and useful stuff. For example, two events have been used ever since Chapter 2, but now the examples can take advantage of other events. And although most of the chapters in the book thus far use an HTML form is some way, the forms chapter can now be more of a “cookbook” type chapter, explaining how to best work with specific form element types.</p><p>The third part of the book, beginning with Chapter 13, is still somewhat up in the air. There will be a chapter on frameworks, one on HTML5 and JavaScript, and another on advanced programming. Depending upon time and space, I’ll do a chapter on libraries (individual libraries, as opposed to frameworks), server-side JavaScript, and JavaScript for mobile apps.</p> ]]></content:encoded> <wfw:commentRss>http://www.larryullman.com/2011/11/20/what-is-larry-thinking-47-random-monkey-appearances/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>My Yii Book Update</title><link>http://www.larryullman.com/2011/11/03/my-yii-book-update/</link> <comments>http://www.larryullman.com/2011/11/03/my-yii-book-update/#comments</comments> <pubDate>Fri, 04 Nov 2011 01:48:50 +0000</pubDate> <dc:creator>Larry</dc:creator> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[books]]></category> <category><![CDATA[framework]]></category> <category><![CDATA[mvc]]></category> <category><![CDATA[yii]]></category> <category><![CDATA[yiibk]]></category><guid
isPermaLink="false">http://www.larryullman.com/?p=2853</guid> <description><![CDATA[I&#8217;ve received a few comments and questions lately about my intentions to write a book on the Yii framework. I&#8217;ve never formally discussed the idea, and so it seems like it&#8217;s about time I do so. I first started using the Yii framework about two and half years ago. I&#8217;ve never been much of a framework [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;ve received a few comments and questions lately about my intentions to write a book on the <a
href="http://yiiframework.com/">Yii framework</a>. I&#8217;ve never formally discussed the idea, and so it seems like it&#8217;s about time I do so.</p><p>I first started using the Yii framework about two and half years ago. I&#8217;ve never been much of a framework person, but Yii really felt right to me, quite similar to <a
href="http://rubyonrails.com/">Ruby on Rails</a>, which I also always liked. Being a writer, after learning to use the framework, I wrote an <a
href="http://www.larryullman.com/series/learning-the-yii-framework/">introductory series on the subject</a>, which has been quite popular. In all modesty, many have suggested it&#8217;s the best documentation available. In fact, the creator of Yii liked my series so much that he listed it prominently on the official Yii documentation page (it&#8217;s now under <a
href="http://www.yiiframework.com/tutorials/">tutorials</a>). Some time after writing that series, I started thinking about writing a full book on Yii, because <a
href="http://www.larryullman.com/books/">that&#8217;s what I do</a>.</p><p>When I decided to write a book on Yii, I figured I&#8217;d self-publish it, for a couple of reasons. First, even though I have a wonderful relationship with <a
href="http://peachpit.com/">Peachpit Press</a>, I&#8217;m not sure they&#8217;d want to do a book on Yii, as the market is kind of small. Second, even if Peachpit would publish such a book, I doubt I&#8217;d make much money on the project, considering the small market. By comparison, if I self-publish, I can make 4-5 times per book what I&#8217;d make if I went through a publisher. The higher per copy amount could be enough to make up for the smaller sales, ending up with a project that&#8217;s financially worth my time to do (sorry to be crass about the money, but writing a book is a lot of work and I do have bills to pay!). Fourth, I&#8217;ve been intrigued about self-publishing for some time. And, fifth, self-publishing would give me the opportunity to distribute the book in unique formats and channels, such as a chapter at a time.</p><p>If I had my act together (which is to say, if my life were other than it is, in about ten ways), I would have been on the ball and published this book a year or more ago. Sadly, that has not been the case. I keep fairly busy work-wise, and I don&#8217;t actually have the time (due to personal constraints) to put in 40-hour weeks, so it&#8217;s really hard to add new projects, especially on the level of an entire book. Moreover, self-publishing means no guaranteed money, so I&#8217;d have to not do paying work while not making money working on the Yii book, which is a tough situation to be in.</p><p>All that being said, <em>it is still my intention to write and self-publish a book on Yii</em>. The only question is: when? This is the question I&#8217;m getting asked a lot lately. Before I do anything towards a book on Yii, I still have to:</p><ul><li>Finish my <em>Modern JavaScript: Develop and Design</em> book (which I&#8217;m weeks late on as is)</li><li>Write one more article in support of my <em>PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)</em> [I've written two out of three articles, but I'm weeks late on that, too.]</li><li>Come up with a list of videos to do in support of my <em>Modern JavaScript: Develop and Design</em> book</li><li>Actually do those videos</li><li>Continue doing the Web development and other work I have for my clients</li></ul><p>So&#8230;yikes. Don&#8217;t get my wrong: I&#8217;m quite fortunate to be busy, but yikes! I&#8217;ll be crying if I haven&#8217;t finished all of the above by the end of this year, which means in theory I can begin the Yii book at the beginning of 2012. However, I have the third edition of my <em>PHP 5 Advanced: Visual QuickPro Guide</em> due at the end of April. That does give me four months, but I&#8217;d like actually make that deadline for a change (my publisher is wonderfully understanding, but&#8230;).</p><p>Also, along with writing the Yii book, I&#8217;m going to have to come up with a site and an ecommerce system and so forth (I already have the software that can output PDFs, ePubs, and mobis). If I&#8217;m being optimistic, perhaps in 2012 I can do two Yii chapters per month, but the <em>PHP 5 Advanced</em> book will need to be my first priority. I also don&#8217;t want to start the Yii book, get some people paying for it (in part or in whole), and then have the project drag out. I don&#8217;t know. We shall see.</p><p>I very much thank everyone for their interest in my writing a book on Yii and I hope to make that happen. If you follow the blog and/or subscribe to my newsletter, you&#8217;ll get updates as to how this is progressing, when and if it does actually progress.</p> ]]></content:encoded> <wfw:commentRss>http://www.larryullman.com/2011/11/03/my-yii-book-update/feed/</wfw:commentRss> <slash:comments>36</slash:comments> </item> <item><title>What is Larry Thinking? #42 =&gt; Doing What I Do, Part 3</title><link>http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/</link> <comments>http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/#comments</comments> <pubDate>Mon, 04 Jul 2011 21:02:19 +0000</pubDate> <dc:creator>Larry</dc:creator> <category><![CDATA[Adobe AIR]]></category> <category><![CDATA[Flex]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[app]]></category> <category><![CDATA[book]]></category> <category><![CDATA[ecom]]></category> <category><![CDATA[flash builder]]></category> <category><![CDATA[mobile]]></category> <category><![CDATA[newsletter]]></category> <category><![CDATA[phpmsyql4]]></category> <category><![CDATA[phpvqs4]]></category> <category><![CDATA[stored procedures]]></category> <category><![CDATA[writing]]></category> <category><![CDATA[yii]]></category><guid
isPermaLink="false">http://www.larryullman.com/?p=2674</guid> <description><![CDATA[In this edition… About This Newsletter What Were You Thinking? =&#62; The JavaScript Book On the Web =&#62; Flash Builder 4.5/Flex 4.5 for Mobile Apps On the Blog =&#62; Cookies and Sessions in Yii On the Forum =&#62; FALSE Comparisons in PHP Q&#38;A =&#62; Could You Say More About Stored Procedures? What is Larry Thinking [...]]]></description> <content:encoded><![CDATA[<p>In this edition…</p><ul><li><a
href="http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/#about">About This Newsletter</a></li><li><a
href="http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/#you">What Were You Thinking? =&gt; The JavaScript Book</a></li><li><a
href="http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/#web">On the Web =&gt; Flash Builder 4.5/Flex 4.5 for Mobile Apps</a></li><li><a
href="http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/#blog">On the Blog =&gt; Cookies and Sessions in Yii</a></li><li><a
href="http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/#forum">On the Forum =&gt; FALSE Comparisons in PHP</a></li><li><a
href="http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/#qa">Q&amp;A =&gt; Could You Say More About Stored Procedures?</a></li><li><a
href="http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/#thinking">What is Larry Thinking =&gt; Doing What I Do: Web Development</a></li><li><a
href="http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/#news">Larry Ullman&#8217;s Book News =&gt; &#8220;PHP and MySQL for Dynamic Web Sites&#8221; (4th Edition) and &#8220;Modern JavaScript: Develop and Design&#8221;</a></li></ul><p><span
id="more-2674"></span></p><h2 id="about">About This Newsletter</h2><p>Another three weeks(-ish), another newsletter! It may only matter to me, but I&#8217;m happy to say that since I started using <a
href="http://www.literatureandlatte.com/scrivener.php">Scrivener</a> to write this newsletter (in late 2010), I&#8217;ve done a much better job in getting these out regularly. Although, since they only go out once a month, or slightly better, it may always seem to you that the newsletters come from out of the blue. Anyway&#8230;in this newsletter I present a random collection of stuff, including the conclusion of my on-going series on building a career in IT. In my next newsletter, I plan on speaking, briefly, about quantum computing, having recently read a <em>fascinating</em> article on the subject.</p><p>As always, questions, comments, and all feedback are much appreciated. And thanks for your interest in what I have to say and do!</p><h2 id="you">What Were You Thinking? =&gt; The JavaScript Book</h2><p>In the previous newsletter, I <a
href="http://www.larryullman.com/2011/06/09/what-is-larry-thinking-41-doing-what-i-do-part-2/#you">posted a question</a> about whether it matters to you if I self-publish my intended JavaScript book or if I use a traditional publisher. I also asked the general question as to what readers look for in a book, beyond the content and perhaps writer. There was an excellent response and I thank everyone for their thoughts.</p><p>The bottom line was that most people don&#8217;t care about the publisher. Some people specifically like, say, O&#8217;Reilly books or the Visual Quick* Series, but many don&#8217;t pay much attention to the publisher (I&#8217;ve always suspected that many readers don&#8217;t pay much attention to who the writer is either). The strongest feedback was just for it being made available in specific formats—PDF, print, what-have-you, and that it be of good quality.</p><p>It was also nice, and quite flattering, to hear many people express their interest in purchasing the book, regardless of whether I self-publish or use a traditional publisher. I am, indeed, fortunate to have the readership that I do.</p><p>Thanks again to everyone that responded and to those of you interested in this book. The actual decision regarding this JavaScript book can be found in the &#8220;Larry Ullman&#8217;s Book News&#8221; section at the end of this newsletter (this is called &#8220;burying the lead&#8221;!).</p><h2 id="web">On the Web =&gt; Flash Builder 4.5/Flex 4.5 for Mobile Apps</h2><p>Version 4.5 of both the Flex framework and the Flash Builder IDE just came out and the outlook is very exciting. As announced some time ago, the focus in Flex 4.5 is on developing for mobile apps. This means a new wave of components optimized for mobile platforms. That alone might sound &#8220;kind of cool&#8221;, but this release is much, much bigger than that.</p><p>Instead of using Flex to write Flash content that runs in a Web browser in a mobile device (but not on Apple devices), thanks to <a
href="http://www.adobe.com/go/air/">Adobe AIR 2.6</a>, <em>you&#8217;ll be able to write true mobile apps in Flex</em>. With the initial release, you&#8217;re able to create apps for the Google Android platform (the largest platform, in terms of sales of mobile devices today). Version 4.5.1 was just released, which adds support for iOS (iPod Touch, iPhone, and iPad) devices and the Blackberry Tablet OS. To summarize:</p><blockquote><p>If you know Flex, you can create mobile applications that run on all major mobile platforms in no time at all!</p></blockquote><p>This could not come at a better time for me. I have a couple of mobile app ideas that I want to develop and was planning on learning how to do so later this year (yes, yes, I&#8217;m totally on the cutting edge of the mobile app craze, eh?). I was still hemming and hawing over whether to pursue the iOS route, which would be natural for me (I primarily use Macs and am comfortable with the C family of languages), or go the Google Android route, which would be harder (Java is the default language there), but technically has a broader market. And now, thanks to Flex 4.5 and Adobe AIR, I won&#8217;t have to choose between them.</p><p>To see the development process, and the output, in action, check out <a
href="http://tv.adobe.com/watch/adobe-technology-sneaks-2011/sneak-peek-of-mobile-application-development-with-flex-and-flash-builder/">this sneak peek video at Adobe</a>. There&#8217;s also <a
href="http://www.adobe.com/devnet/flex/articles/mobile-development-flex-flashbuilder.html">this pretty good article</a> on mobile development using Flex and Flash Builder. It&#8217;s a very impressive concept and, as far as I know, the only &#8220;write once, run everywhere&#8221; development solution for mobile apps. This, of course, is the promise of Adobe AIR itself, which allows you to write one application that can run on multiple operating systems (I still seem to be a bigger fan of AIR than the world at large).</p><h2 id="blog">On the Blog =&gt; Cookies and Sessions in Yii</h2><p>In my ever-ongoing series on the <a
href="http://www.yiiframework.com">Yii framework</a>, I&#8217;ve recently written two postings on managing state using the framework. The <a
href="http://www.larryullman.com/2011/05/03/using-sessions-with-the-yii-framework/">first is on sessions</a>; the <a
href="http://www.larryullman.com/2011/06/04/using-cookies-in-the-yii-framework/">second on cookies</a>. Neither is particularly difficult to do using Yii, once you know the right code, of course. With cookies, Yii has built-in extra security measures you can take, for example, to help prevent Cross-Site Request Forgery (CSRF) attacks.</p><h2 id="forum">On the Forum =&gt; FALSE Comparisons in PHP</h2><p>I&#8217;m hoping that you&#8217;ll take this as a comfort, but you should be aware that we all, no matter how long we&#8217;ve been programming, are capable of creating bugs when programming. Through the <a
href="http://www.larryullman.com/forums/index.php?/topic/301-problems-with-ecommerce-example-2-demo-site/">keen testing of a reader</a>, a bug was caught in the second example site from my &#8220;<a
href="http://www.larryullman.com/books/effortless-e-commerce-with-php-and-mysql/">Effortless E-Commerce with PHP and MySQL</a>&#8221; book. It&#8217;s a common enough mistake that I should have caught it myself and yet&#8230; You can read my formal explanation regarding the specific code <a
href="http://www.larryullman.com/forums/index.php?/topic/301-problems-with-ecommerce-example-2-demo-site/page__pid__2163#entry2163">in the forum</a>, but the premise is this:</p><p>Say you have the conditional <code>if ($var) {</code>. That conditional will be TRUE so long as <strong>$var</strong> has a TRUE value. But what is a TRUE value? It&#8217;s easiest to understand what a TRUE value is by knowing what a FALSE value is. These are all FALSE values:</p><ul><li>FALSE (case-insensitive)</li><li>NULL</li><li>(No actual value)</li><li>&#8220;&#8221; (An empty string)</li><li>0</li><li>0.0</li><li>‘0&#8242;</li></ul><p>There are a couple of other higher-end FALSEhoods, such as an empty array. It should be fairly obvious that FALSE, NULL, no actual value, and an empty string are all FALSE values; the bug arises when you forget that zero, in any form, is also FALSE. And here&#8217;s how it can manifest itself as a bug (this is a different example than the one in the book and referenced in the forum)…</p><p>The <strong>stripos()</strong> function is used to identify whether or not string Needle is found within another string Haystack. If the Needle is not found, <strong>stripos()</strong> returns FALSE. If the Needle is found, <strong>stripos()</strong> <em>does not return TRUE</em>, but rather <em>returns the indexed position where Needle begins in Haystack</em>. This code, therefore, could be a problem:</p><p><code>if (stripos($haystack, $needle)) {…</code></p><p>The intent is to see if <strong>$needle</strong> exists in <strong>$haystack</strong>. However, if <strong>$needle</strong> is the first part of <strong>$haystack</strong>, <strong>stripos()</strong> will return 0, which will be interpreted by that conditional as FALSE. The bug-free solution is to change the conditional to test if the value returned by <strong>stripos()</strong> is not identical to FALSE:</p><p><code>if (stripos($haystack, $needle) !== false) {…</code></p><p>Note that you have to explicitly use the <em>not identical</em> operator (<strong>!==</strong>), as using the <em>not equal</em> operator (<strong>!=</strong>) would again be a bug, as the zero returned by the function would, in fact, be equal (but not identical) to FALSE.</p><p>Again, I hope you can take some solace in knowing that we all make mistakes, no matter the level of experience (or maybe that&#8217;s depressing?). I personally find it frustrating to make mistakes that I&#8217;m already aware of as a possibility, but on the bright side, making mistakes you know about makes them easier to fix!</p><h2 id="qa">Q&amp;A =&gt; Could You Say More About Stored Procedures?</h2><p>Oguz had prompted me to write a bit about stored procedures in general and in MySQL in particular. Stored procedures are one of those higher-end database concepts which you may have heard about but never really used (other examples include VIEWs and UNIONs). I previously wrote about stored procedures in my &#8220;<a
href="http://www.larryullman.com/books/mysql-visual-quickstart-guide-2nd-edition/">MySQL: Visual QuickStart Guide</a>&#8221; and my &#8220;<a
href="http://www.larryullman.com/books/php-5-advanced-visual-quickpro-guide-2nd-edition/">PHP 5 Advanced: Visual QuickPro Guide</a>&#8220;, and then relied upon them extensively in the second example of my &#8220;<a
href="http://www.larryullman.com/books/effortless-e-commerce-with-php-and-mysql/">Effortless E-Commerce with PHP and MySQL</a>&#8220;.</p><p>Both <em>stored procedures</em> and <em>stored functions</em> fall under the category of <a
href="http://dev.mysql.com/doc/refman/5.1/en/stored-routines.html">stored routines</a>, added to MySQL in version 5.1 (and MySQL is still adding features in this area). A stored routine is simply a memorized set of SQL queries and code. Think of it like taking any block of PHP code that interacts with a database, has conditionals, does something with the query data, etc., but store all of that in the database itself. The primary difference between a stored procedure and a stored function is that a stored <em>function</em> can return only a single value whereas a stored <em>procedure</em> can return an entire result set (i.e., multiple rows of multiple columns of data). For example, in &#8220;PHP 5 Advanced&#8221;, a stored function is created that returns the distance in miles between two points on the globe, which involves complicated trigonometry using latitude and longitude. A call to that function is then part of a standard SELECT query, as if it were any other predefined MySQL function. Conversely, in &#8220;Effortless E-Commerce with PHP and MySQL&#8221;, stored procedures are used to update shopping carts, return a list of sale items, and much more. Both types of routines can also take arguments, just like functions in PHP.</p><p>Stored routines offer several benefits, the most important of which is improved security. Because all of the database references—table and column names—are in the stored routines, a PHP script using those routines need not have any knowledge of the particulars of the database. Further, a stored routine can use its arguments in queries with the same security as <em>prepared statements</em>, thereby preventing SQL injection attacks. Applications with the highest level of security requirements, such as banking, rely upon stored routines.</p><p>You can also get better performance using stored routines, both because the routines can be cached and because less data has to be transferred to the database (just the data itself gets transferred; all the SQL is already in the database). Using stored routines also offers improved application portability, in that many different types of clients—PHP scripts, command line tools, GUI applications, etc.—can make use of the same stored routines.</p><p>There are arguments against using stored routines, too. For starters, you&#8217;ll need a relatively current version of MySQL, and the ability to create an execute stored routines (these are permissions not necessarily offered by, for example, shared hosting environments). Stored routines also marry your applications to specific database applications (e.g., MySQL or Oracle), although stored routines are part of the SQL standard and may be somewhat translatable from one database application to the next. And, as with most things, there&#8217;s a learning curve involved and debugging applications that use stored routines becomes a bit harder.</p><p>You can find out more about stored routines in the books I mentioned, in the <a
href="http://dev.mysql.com/doc/refman/5.1/en/stored-routines.html">MySQL manual&#8217;s main page for stored routines</a>, and in the stored routines <a
href="http://dev.mysql.com/doc/refman/5.1/en/faqs-stored-procs.html">FAQ</a> and <a
href="http://dev.mysql.com/doc/refman/5.1/en/stored-program-restrictions.html">restrictions</a> pages of the MySQL manual.</p><h2 id="thinking">What is Larry Thinking? =&gt; Doing What I Do: Web Development</h2><p>In this newsletter I&#8217;m finishing what became a series on IT careers. I first wrote about becoming a better programmer, in two parts(<a
href="http://www.larryullman.com/2011/02/01/what-is-larry-thinking-36-becoming-a-better-programmer-and-more/#thinking">1</a> and <a
href="http://www.larryullman.com/2011/02/25/what-is-larry-thinking-37-becoming-a-better-programmer-part-2/#thinking">2</a>). Then I wrote about <a
href="http://www.larryullman.com/2011/03/22/what-is-larry-thinking-38-building-a-career/#thinking">building a career</a> and <a
href="http://www.larryullman.com/2011/04/16/what-is-larry-thinking-39-how-i-got-here-and-the-future/#thinking">how I got here</a>. Next, I wrote about <a
href="http://www.larryullman.com/2011/05/12/what-is-larry-thinking-40-doing-what-i-do-part-1/#thinking">some of the specifics of what I do</a>, focussing on the writing side. In the <a
href="http://www.larryullman.com/2011/06/09/what-is-larry-thinking-41-doing-what-i-do-part-2/#thinking">previous newsletter</a>, I discussed training. This leaves me with the last thing that I do: Web and application development (i.e., programming).</p><p>Web and application development jobs have a wide range of possibilities with a wide range of potential income. Small, simple jobs may pay a few hundred dollars; big, complex, and well-funded projects can pay tens of thousands or hundreds of thousands. Getting any job, regardless of size, is a two-step process: 1) finding out about the job; and, 2) convincing the client to hire you.</p><p>There are online sites for finding projects, but you&#8217;ll be competing with everyone else there. You&#8217;ll have better luck by networking: connecting with people, businesses, and organizations that might be able to make use of your abilities. For example, for a couple of years I was the outside programmer that did the dynamic functionality for a graphic designer. She got the projects, managed the clients, the contracts, and the billing, and I just did my share of the work. A perfect arrangement for me! Local user groups, schools, and similar communities can be good ways to hook up with people in a casual way that might pan out down the line.</p><p>As for convincing clients to hire you, the most important criteria in my mind are good communication skills. Everyone says that communication skills are important, but not that many people excel in this area, and way too many don&#8217;t even try to communicate well. <em>Be clear, responsive, and punctual in your communications!</em> Doing so demonstrates that you have a level of professionalism needed to do the work itself. If you can&#8217;t clearly express yourself in an email, if you fail to answer questions asked of you, or if you&#8217;re negligent in responding promptly, it suggests that the work you do will be poorly put together, will fail to meet expectations, and not be done on time, either.</p><p>Secondarily, you&#8217;ll need to have a portfolio showing what you&#8217;re capable of. If you don&#8217;t have a portfolio, then give them something that they can look at. One of my very first clients, for whom I&#8217;m still working, wanted a bit of JavaScript coding for his site. At that time I had no portfolio to show him, so as part of my bid, I did the work itself and presented that. Nothing more clearly indicates your ability to do a project than actually doing the project! Further, the client could also see, before he hired me, that the project would be finished quickly (because it already was). Yes, I ran the risk of making no money for my efforts, but at the time I needed the work and had to go out on a limb. It really panned out, and I would do it again if I felt I had to (arguably, I have had to in the past, as getting published involves some amount of writing on spec).</p><p>And this leads me to a point that you&#8217;ll (hopefully) learn in time as you grow your skills and your budget: you&#8217;ll always adjust your bids not just to the project and the client but to your situation. When I&#8217;m especially busy or if a project isn&#8217;t that interesting, clients will get the &#8220;I don&#8217;t really want to do this project but if I am going to do it, I&#8217;m going to get paid well&#8221; bid. When I&#8217;m not that busy or a project is interesting, I&#8217;ll provide a cheaper bid. Life is always a matter of time versus money, and the professional is constantly making adjustments along that scale.</p><p>As a final cornucopia of thoughts, first, don&#8217;t be afraid to overbid. Even if you&#8217;re desperate, you may really come to regret getting a project at a low bid. If anything, it tells you a lot about a client that wants the lowest price: you probably don&#8217;t want to work with people that want things on the cheap. There is no doubt you will sometimes make less money on a project than you should (and hopefully sometimes make more), but try not to plan on shortchanging yourself. For that matter, have a good contract in place with expectations clearly laid out so that you don&#8217;t get steamrolled.</p><p>Next, you could consider becoming a specialist in one area: CMS (e.g., Joomla), WordPress, etc. You run the risk of not being able to get work as easily, because you are so specialized, but you may also be able to make more money, and get better at a smaller set of skills faster, by narrowing your focus.</p><p>And lastly, if you&#8217;re working on a project and you&#8217;re having problems and aren&#8217;t going to make the deadline, handle the situation professionally. Never hide from clients, be as honest as you can, and always reply to emails promptly. For more strategies along these lines, check out <a
href="http://brainzooming.com/project-management-techniques-when-time-running-down/6869/">this nice article</a>.</p><p>So that&#8217;s it on my long series on building a career in IT. As happens with me, all the time, what started off as a simple idea expanded and expanded. I worry that I ran out of steam at the end here, but hopefully you&#8217;ve benefitted from this discussion somehow, and I&#8217;ve helped you, in whatever small way, in pursuing your dream of an IT career (as for me, my dream involves a hammock overlooking the Caribbean Sea).</p><h2 id="news">Larry Ullman&#8217;s Book News =&gt; &#8220;PHP and MySQL for Dynamic Web Sites&#8221; (4th Edition) and &#8220;Modern JavaScript: Develop and Design&#8221;</h2><p>I&#8217;m very pleased to say that I&#8217;ve completed the first draft of the fourth edition of &#8220;PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide&#8221; (and by &#8220;first draft&#8221;, I mean the first draft submitted to the publisher; there are multiple writing drafts just to get to that point). As with the fourth edition of &#8220;<a
href="http://www.larryullman.com/books/php-for-the-web-visual-quickstart-guide-4th-edition/">PHP for the Web: Visual QuickStart Guide</a>&#8220;, I added a &#8220;Review and Pursue&#8221; section to the end of each chapter. I also expanded the coverage of SQL and MySQL, including much more on JOINs. One new chapter introduces the <a
href="http://www.jquery.com">jQuery</a> JavaScript framework, with examples of form validation and performing Ajax requests. Another new chapter introduces the fundamentals of Object-Oriented Programming, using the MySQL Improved extension for several examples, and the <a
href="http://www.php.net/datetime">DateTime</a> class for another. In the appendix, I&#8217;ve included a few pages on configuring the Apache Web server, providing the syntax for performing common tasks such as password protecting directories and URL rewriting.</p><p>Last, but not least, I am pleased to announce that I have in my hands a contract to write the book &#8220;Modern JavaScript: Develop and Design&#8221; for Peachpit Press. This is the publisher I&#8217;ve worked with the most, and so I&#8217;m quite comfortable with them. The book will be in a new series, titled &#8220;Develop and Design&#8221;, specifically created for code-based books (the first title in the series is on ActionScript). The series does <em>not</em> use the two-column format like the Visual QuickStart/QuickPro series (which some people like, some people don&#8217;t), and will be in full color, a first for me. The publisher has allotted me up to 600 pages, which is quite a lot, and by using a publisher, the book will have the widest possible availability (Peachpit Press really worked with me on making this happen). I&#8217;ll begin formally writing the book in late July or early August so that it comes out by the end of the year. Once again, my thanks to everyone for their interest in this book, and for all of the feedback.</p> ]]></content:encoded> <wfw:commentRss>http://www.larryullman.com/2011/07/04/what-is-larry-thinking-42-doing-what-i-do-part-3/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>The CodeLobster PHP IDE</title><link>http://www.larryullman.com/2011/06/23/the-codelobster-php-ide/</link> <comments>http://www.larryullman.com/2011/06/23/the-codelobster-php-ide/#comments</comments> <pubDate>Thu, 23 Jun 2011 14:48:42 +0000</pubDate> <dc:creator>Larry</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[cakephp]]></category> <category><![CDATA[codeigniter]]></category> <category><![CDATA[framework]]></category> <category><![CDATA[ide]]></category> <category><![CDATA[jquery]]></category> <category><![CDATA[smarty]]></category> <category><![CDATA[wordpress]]></category> <category><![CDATA[yii]]></category><guid
isPermaLink="false">http://www.larryullman.com/?p=2627</guid> <description><![CDATA[I&#8217;ve been contacted a couple of times now by the people behind CodeLobster, a PHP-centric IDE, in the hopes that I&#8217;d review/mention CodeLobster on this site. Now, CodeLobster only runs on Windows, which means I haven&#8217;t, and probably won&#8217;t, use it myself (I primarily use a Mac, only using Windows for testing purposes), but I [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been contacted a couple of times now by the people behind <a
href="http://www.codelobster.com/">CodeLobster</a>, a PHP-centric IDE, in the hopes that I&#8217;d review/mention CodeLobster on this site. Now, CodeLobster only runs on Windows, which means I haven&#8217;t, and probably won&#8217;t, use it myself (I primarily use a Mac, only using Windows for testing purposes), but I have no problems mentioning products and sites here that I don&#8217;t personally use, because such things may still be of use to you (you, whoever you are, presumably are a separate entity with your own interests, needs, etc., and are statistically more likely to be running Windows). Anyway&#8230;</p><p>So, CodeLobster is an IDE for PHP that runs on Windows. It&#8217;s available in both a free and &#8220;professional&#8221; version, the professional version costing $100 (US). The free version comes with an HTML editor and inspector, a CSS editor, a JavaScript editor, a PHP editor, and a PHP debugger. This all includes the standard features such as code completion, code collapsing, browser preview, project management, FTP, and so forth. The professional version includes all of those features, plus plug-ins for specific tools and frameworks: CakePHP, CodeIgniter, Drupal, jQuery, Joomla, Smarty, Symfony, WordPress, and Yii. In other words, the professional version gives you code completion, contextual help, and so forth for these additional tools that you may also be programming in.</p><p>As I said, I haven&#8217;t personally used it, but if you&#8217;re looking for a PHP/Web Development IDE, it may be worth checking out.</p> ]]></content:encoded> <wfw:commentRss>http://www.larryullman.com/2011/06/23/the-codelobster-php-ide/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Using Cookies in the Yii Framework</title><link>http://www.larryullman.com/2011/06/04/using-cookies-in-the-yii-framework/</link> <comments>http://www.larryullman.com/2011/06/04/using-cookies-in-the-yii-framework/#comments</comments> <pubDate>Sat, 04 Jun 2011 14:28:06 +0000</pubDate> <dc:creator>Larry</dc:creator> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[cookie]]></category> <category><![CDATA[csrf]]></category> <category><![CDATA[framework]]></category> <category><![CDATA[mvc]]></category> <category><![CDATA[security]]></category> <category><![CDATA[yii]]></category><guid
isPermaLink="false">http://www.larryullman.com/?p=2552</guid> <description><![CDATA[In a previous post, I wrote about . In this one, I&#8217;ll look at using cookies. Neither is that difficult, but as with all things regarding frameworks, the solution may not be obvious at first. And there are some ways to make use cookies in Yii in a more secure manner.To create a cookie in [...]]]></description> <content:encoded><![CDATA[<p>In a previous post, I wrote about <a
href="http://www.larryullman.com/2011/05/03/using-sessions-with-the-yii-framework/">using sessions in Yii-based sites</a>. In this one, I&#8217;ll look at using cookies. Neither is that difficult, but as with all things regarding frameworks, the solution may not be obvious at first. And there are some ways to make use cookies in Yii in a more secure manner.<span
id="more-2552"></span>To create a cookie in PHP without using a framework, you just call the <a
href="http://us.php.net/setcookie">setcookie()</a> function. To create a cookie while using the Yii framework, you don&#8217;t use <strong>setcookie()</strong>, but rather create a new element in the <strong>Yii::app()-&gt;request-&gt;cookies</strong> array. (Note that sessions are stored in <strong>Yii::app()-&gt;session</strong>, but cookies are in <strong>Yii::app()-&gt;request-&gt;cookies</strong>, because cookies are part of the HTTP request a browser makes of a Web server).</p><p>What you&#8217;ll want to do to create a cookie is create a new object of type <a
href="http://www.yiiframework.com/doc/api/1.1/CHttpCookie/">CHttpCookie</a>: Yii&#8217;s class for cookies. Here, then, is the syntax for setting a cookie in Yii:</p><pre class="brush: php; title: ; notranslate">Yii::app()-&gt;request-&gt;cookies['name'] = new CHttpCookie('name', 'value');</pre><p>You must use the same <em>name</em> value in both places, replacing it with the actual cookie name. Remember that the cookie&#8217;s name, and value, are visible to users in their browsers, so one ought to be prudent about what name you use and be extra mindful of what values are being stored.</p><blockquote><p>Tip: Because the cookie&#8217;s name must be used twice in the code, you may want to consider assigning the cookie&#8217;s name to a variable that is used in both instances instead.</p></blockquote><p>Once you&#8217;ve created a cookie, you can access it (on subsequent pages, because cookies are never immediately available to the page that set them), using <strong>Yii::app()-&gt;request-&gt;cookies['name']-&gt;value</strong>. You have to use the extra <strong>-&gt;value</strong> part, because the &#8220;cookie&#8221; being created is actually an object of type <strong>CHttpCookie</strong> (and Yii, internally, takes care of actually sending the cookie to the browser and reading the received cookie from the browser).</p><p>To test if a cookie exists, just use <strong>isset()</strong> on <strong>Yii::app()-&gt;request-&gt;cookies['name']</strong>, as you would any other variable.</p><p>To delete an existing cookie, just unset the element as you would any array element:</p><pre class="brush: php; title: ; notranslate">unset(Yii::app()-&gt;request-&gt;cookies['name']);</pre><p>To delete all existing cookies (for that site), use</p><pre class="brush: php; title: ; notranslate">Yii::app()-&gt;request-&gt;cookies-&gt;clear();</pre><p>By default, cookies will be set to expire when the browser window is closed. To change that, you need to modify the properties of the cookie. You can&#8217;t do so when you create the <strong>CHttpCookie</strong> object (i.e., the only arguments to the constructor are the cookie&#8217;s name and value), so you must separately create a new object of type <strong>CHttpCookie</strong>, to be assigned to <strong>Yii::app()-&gt;request-&gt;cookies</strong> later:</p><pre class="brush: php; title: ; notranslate">$cookie = new CHttpCookie('name', 'value');</pre><p>Then adjust the <strong>expire</strong> attribute:</p><pre class="brush: php; title: ; notranslate">$cookie-&gt;expire = time() + (60*60*24); // 24 hours</pre><p>Then add the cookie to the application:</p><pre class="brush: php; title: ; notranslate">Yii::app()-&gt;request-&gt;cookies['name'] = $cookie;</pre><p>You can manipulate other cookie properties using the above syntax: <strong>domain</strong>, <strong>httpOnly</strong>, <strong>path</strong>, and <strong>secure</strong>. Each of these correspond to the arguments to the <strong>setcookie()</strong> function. (You can also manipulate the value of the cookie through <strong>$cookie-&gt;value</strong> and the cookie&#8217;s name through <strong>$cookie-&gt;name</strong>). For example, if you want to limit a cookie to a specific domain, or subdomain, use <strong>domain</strong>; to limit it to a specific folder, use <strong>path</strong>; and to only transmit the cookie over SSL, set <strong>secure</strong> to <strong>true</strong>.</p><p>You can also improve the security of your cookies by setting Yii&#8217;s <strong>enableCookieValidation</strong> to <strong>true</strong>, in the Yii configuration file:</p><pre class="brush: php; title: ; notranslate">return array(
    'components'=&gt;array(
        'request'=&gt;array(
            'enableCookieValidation'=&gt;true,
        ),
    ),
);</pre><p>Cookie validation prevents cookies from being manipulated in the browser. To accomplish that, Yii stores a hashed representation of the cookie&#8217;s value when it gets sent, and then compares the received cookie&#8217;s value to ensure they are the same. Obviously there&#8217;s extra overhead required to do this, but in some instances, the extra effort is justified by the extra security.</p><p>Finally, one good reason to use cookies in a Yii-based site, even if the site is otherwise using sessions, is to prevent <a
href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">Cross-site Request Forgery (CSRF)</a> attacks. A CSRF works like this: malicious site A has some code on it, such as an image tag whose <strong>src</strong> attribute points to a page on site B that does something meaningful: <em>http://www.example.com/page.php?action=this</em>. When any viewer loads the page on site A, the use of that <strong>src</strong> attribute has the effect of that user performing a request of the page on site B.</p><p>As an example, let&#8217;s say that an administrator at your site logs in and does whatever but doesn&#8217;t log out. The administrator therefore still has a cookie in her or his browser indicating access to the site (i.e., the user could open the browser and perform admin tasks without logging in again). Now let&#8217;s say that the <strong>src</strong> attribute on malicious site A points to a page on your site that deletes a blog posting. If the administrator with the live cookie loads that page on site A, it will have the same effect as if that administrator went to your site and requested that page directly. This is not good.</p><p>To prevent a CSRF attack on your site, first make sure that all significant form submissions use POST instead of GET. You should be using POST for any form that changes server content anyway, but a CSRF POST attack is a bit harder to pull off than a GET attack.</p><p>Second, set <strong>enableCsrfValidation</strong> to <strong>true</strong> in your configuration file:</p><pre class="brush: php; title: ; notranslate">return array(
    'components'=&gt;array(
        'request'=&gt;array(
            'enableCsrfValidation'=&gt;true,
        ),
    ),
);</pre><p>By doing this, Yii will send a cookie with a unique identifier to the user. All forms will then store that same identifier in a hidden input. The form submission will only be handled then if the two identifiers match. With the case of a CSRF attack, the two identifiers will not match because the form&#8217;s identifier will not be passed as part of the request (I hope this is clear; if not, let me know). Note that this only works if you&#8217;re using <a
href="http://www.yiiframework.com/doc/api/1.1/CHtml">CHtml</a> to create your forms (if you manually create the form tags, Yii won&#8217;t insert the necessary code for preventing CSRF attacks).</p><p>The most important thing to remember about cookies, which I&#8217;ve already stated, is that cookies are visible to the user in the browser. And unless you&#8217;re using SSL for the cookies, they are also visible to anyone else while being transmitted back and forth between the server and the client (which happens on every page request). So be careful of what gets stored in a cookie! If the data is particularly sensitive, use sessions instead of cookies.</p> ]]></content:encoded> <wfw:commentRss>http://www.larryullman.com/2011/06/04/using-cookies-in-the-yii-framework/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Yii vs Zend vs Code Igniter Compared</title><link>http://www.larryullman.com/2011/06/01/yii-vs-zend-vs-code-igniter-compared/</link> <comments>http://www.larryullman.com/2011/06/01/yii-vs-zend-vs-code-igniter-compared/#comments</comments> <pubDate>Wed, 01 Jun 2011 17:05:39 +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> <category><![CDATA[zend]]></category><guid
isPermaLink="false">http://www.larryullman.com/?p=2593</guid> <description><![CDATA[I&#8217;m often asked why I like the Yii framework, which is easy enough to answer: for starters it requires PHP 5 and uses jQuery natively. Then I like how it auto-generates a lot of code and folders for you. From there, it just kind of works and makes sense to me. In other words, Yii [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;m often asked why I like the <a
href="http://www.yiiframework.com">Yii framework</a>, which is easy enough to answer: for starters it requires PHP 5 and uses <a
href="http://www.jquery.com">jQuery</a> natively. Then I like how it auto-generates a lot of code and folders for you. From there, it just kind of works and makes sense to me. In other words, Yii feels right. And unless you really investigate the framework&#8217;s underpinnings, how it feels (and can you get it to do what you need to do) is a large part of the criteria in making a selection.</p><p>The question I can&#8217;t really answer is what advantage Yii has over the <em>X</em> framework. The only other PHP framework I&#8217;ve used extensively is the <a
href="http://framework.zend.com">Zend framework</a>. The Zend framework has a lot going for it and is worth anyone&#8217;s consideration. To me, its biggest asset is that you can use it piecemeal and independently (I&#8217;ve often used components of the Zend Framework in Yii-based and non-framework-based sites), but I just don&#8217;t like the Zend Framework as the basis of an entire site. It requires a lot of work, the documentation is overwhelming while still not being that great, and it just doesn&#8217;t &#8220;fell&#8221; right to me.</p><p>Anyway, the point of this post is that there&#8217;s a <a
href="http://www.sheldmandu.com/php/php-mvc-frameworks/yii-vs-zend-vs-code-igniter-compared">nice article at SHELDMANDU</a> from back in January in which the author does a great job of comparing the Yii framework with the Zend framework and <a
href="http://codeigniter.com/">Code Igniter</a> (I&#8217;ve heard many good things about Code Igniter). Moreover, the author lays out some of his criteria for what he wants in a framework, has reasonable and detailed critiques, and also specifically details why he didn&#8217;t consider other frameworks in his comparison. If you&#8217;re looking into frameworks, spend five minutes reading that article to help educate yourself as to what considerations you should have in mind during your research.</p> ]]></content:encoded> <wfw:commentRss>http://www.larryullman.com/2011/06/01/yii-vs-zend-vs-code-igniter-compared/feed/</wfw:commentRss> <slash:comments>14</slash:comments> </item> <item><title>Using Sessions with the Yii Framework</title><link>http://www.larryullman.com/2011/05/03/using-sessions-with-the-yii-framework/</link> <comments>http://www.larryullman.com/2011/05/03/using-sessions-with-the-yii-framework/#comments</comments> <pubDate>Tue, 03 May 2011 01:16:56 +0000</pubDate> <dc:creator>Larry</dc:creator> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[cookie]]></category> <category><![CDATA[framework]]></category> <category><![CDATA[mvc]]></category> <category><![CDATA[session]]></category> <category><![CDATA[yii]]></category><guid
isPermaLink="false">http://www.larryullman.com/?p=2353</guid> <description><![CDATA[I haven&#8217;t written much about the Yii framework lately, mostly because I&#8217;ve been working night and day on the fourth edition of my &#8220;PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide&#8221; book, due out late summer 2011. So I figured I&#8217;d put together another little blurb on the Yii framework (by regularly putting [...]]]></description> <content:encoded><![CDATA[<p>I haven&#8217;t written much about the <a
href="http://www.yiiframework.com">Yii framework</a> lately, mostly because I&#8217;ve been working night and day on the fourth edition of my &#8220;PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide&#8221; book, due out late summer 2011. So I figured I&#8217;d put together another little blurb on the Yii framework (by regularly putting out posts on Yii, it&#8217;ll be that much easier when I go to write a book on Yii later this summer). In this post, I&#8217;m going to talk about using sessions Yii-based sites (in a separate post, I&#8217;ll discuss cookies). While not at all hard, the topic, like quite a few things, is not obvious in Yii, or well documented.</p><p><span
id="more-2353"></span></p><p>The first thing to know about using sessions in Yii is that you don&#8217;t have to do anything to enable them, which is to say you don&#8217;t have to invoke <strong>session_start()</strong>, as you would in a standard PHP script. This is the behavior with Yii&#8217;s <strong>autoStart</strong> session property set to <em>true</em>, which is the default. Even without using <strong>session_start()</strong>, you could, of course, make use of the <strong>$_SESSION</strong> superglobal array, as you would in a standard PHP script, but it&#8217;s best when using frameworks to make total use of the framework. The Yii equivalent to <strong>$_SESSION</strong> is <strong>Yii::app()-&gt;session</strong>:</p><pre class="brush: php; title: ; notranslate">Yii::app()-&gt;session['var'] = 'value';
echo Yii::app()-&gt;session['var']; // Prints &quot;value&quot;</pre><p>And that&#8217;s all there is to it. To remove a session variable, apply <strong>unset()</strong>, as you would to any other variable:</p><pre class="brush: php; title: ; notranslate">unset(Yii::app()-&gt;session['var']);</pre><p>So&#8230;nothing really unexpected there, once you know where to find the session data. The more complex consideration is how to configure sessions for your Yii application. You can do so using the primary configuration file (<strong>protected/config/main.php</strong>). Within that, you would add a &#8220;session&#8221; element to the &#8220;components&#8221; array, wherein you customize how the sessions behave. The key attributes are:</p><ul><li><strong>autoStart</strong>, which defaults to <em>true</em> (i.e., always start sessions)</li><li><strong>cookieMode</strong>, with acceptable values of <em>none</em>, <em>allow</em>, and <em>only</em>, equating to: don&#8217;t use cookies, use cookies if possible, and only use cookies; defaults to <em>allow</em></li><li><strong>cookieParams</strong>, for adjusting the session cookie&#8217;s arguments, such as its lifetime, path, domain, and HTTPS-only</li><li><strong>gCProbability</strong>, for setting the probability of garbage collection being performance, with a default of 1, as in a 1% chance</li><li><strong>savePath</strong>, for setting the directory on the server used as the session directory, with a default of <em>/tmp</em></li><li><strong>sessionName</strong>, for setting the session&#8217;s, um, name, which defaults to <em>PHPSESSID</em></li><li><strong>timeout</strong>, for setting after how many seconds a session is considered idle, which defaults to 1440</li></ul><p>For all of these, the default values are the same as those that PHP sessions commonly run using, except for <strong>autoStart</strong>.</p><p>If your site will not be using sessions at all, you would want to disable them by adding this code to the &#8220;components&#8221; section of <strong>protected/config/main.php</strong>:</p><pre class="brush: php; title: ; notranslate">'session' =&gt; array (
    'autoStart' =&gt; false,
),</pre><p>If you are using sessions, for security purposes, you may want to change the session&#8217;s name, always require cookies, and change the save path:</p><pre class="brush: php; title: ; notranslate">'session' =&gt; array (
    'sessionName' =&gt; 'Site Access',
    'cookieMode' =&gt; 'only',
    'savePath' =&gt; '/path/to/new/directory',
),</pre><p>The save path, in case you&#8217;re not familiar with it, is where the session data is stored on the server. By default, this is a temporary directory, globally readable and writable. Every site running on the sever, if there are many (and shared hosting plans can have dozens on a single server), share this same directory. This means that any site on the server can read any other site&#8217;s stored session data. For this reason, changing the save path to a directory within your own site can be a security improvement. Alternatively, you can store the session data in a database. To do that, add this code to the &#8220;components&#8221; section of <strong>protected/config/main.php</strong>:</p><pre class="brush: php; title: ; notranslate">'session' =&gt; array (
    'class' =&gt; 'system.web.CDbHttpSession',
    'connectionID' =&gt; 'db',
    'sessionTableName' =&gt; 'actual_table_name',
),</pre><p>If you choose this route, Yii will automatically create the table if it does not exist. You can also perform any of the other session configuration changes in that code block, too.</p><p>So&#8230;what else? Frequently, for debugging purposes, and sometimes to store it in the database, I like to know the user&#8217;s current session ID. That value can be found in <strong>Yii::app()-&gt;session-&gt;sessionID</strong>.</p><p>Finally, when the user logs out, you may want to formally eradicate the session. To do so, call <strong>Yii::app()-&gt;session-&gt;clear()</strong> to remove all of the session variables. Then call <strong>Yii::app()-&gt;session-&gt;destroy(</strong>) to get rid of the actual data stored on the server.</p><p>And that&#8217;s what there is to know about using sessions with Yii, at least that&#8217;s all the key information. I hope this helps you with your Yii-based applications. As always, thanks for reading and let me know if you have any comments or questions.</p> ]]></content:encoded> <wfw:commentRss>http://www.larryullman.com/2011/05/03/using-sessions-with-the-yii-framework/feed/</wfw:commentRss> <slash:comments>30</slash:comments> </item> <item><title>What is Larry Thinking? #37 =&gt; Becoming a Better Programmer, Part 2</title><link>http://www.larryullman.com/2011/02/25/what-is-larry-thinking-37-becoming-a-better-programmer-part-2/</link> <comments>http://www.larryullman.com/2011/02/25/what-is-larry-thinking-37-becoming-a-better-programmer-part-2/#comments</comments> <pubDate>Fri, 25 Feb 2011 01:27:06 +0000</pubDate> <dc:creator>Larry</dc:creator> <category><![CDATA[Flex]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[cdn]]></category> <category><![CDATA[cloudfront]]></category> <category><![CDATA[ecom]]></category> <category><![CDATA[newsletter]]></category> <category><![CDATA[yii]]></category><guid
isPermaLink="false">http://www.larryullman.com/?p=2350</guid> <description><![CDATA[In this edition… About This Newsletter What are You Thinking? =&#62; &#8220;PHP and MySQL for Dynamic Web Sites&#8221; On the Web =&#62; Two E-Commerce Articles Published Online On the Web =&#62; Several Excerpts from &#8220;Effortless Flex 4 Development&#8221; On the Web =&#62; Toad for MySQL On the Blog =&#62; Rendering View Files in Yii On [...]]]></description> <content:encoded><![CDATA[<p>In this edition…</p><ul><li><a
href="#about">About This Newsletter</a></li><li><a
href="#you">What are You Thinking? =&gt; &#8220;PHP and MySQL for Dynamic Web Sites&#8221;</a></li><li><a
href="#web1">On the Web =&gt; Two E-Commerce Articles Published Online</a></li><li><a
href="#web2">On the Web =&gt; Several Excerpts from &#8220;Effortless Flex 4 Development&#8221;</a></li><li><a
href="#web3">On the Web =&gt; Toad for MySQL</a></li><li><a
href="#blog1">On the Blog =&gt; Rendering View Files in Yii</a></li><li><a
href="#blog2">On the Blog =&gt; Using Amazon&#8217;s CloudFront as a CDN</a></li><li><a
href="#qa">Q&amp;A =&gt; How Can One Become a &#8220;Real&#8221; Programmer?</a></li><li><a
href="#thinking">What is Larry Thinking =&gt; Becoming a Better Programmer, Part 2</a></li><li><a
href="#news">Larry Ullman’s Book News =&gt; “PHP for the Web”, “PHP and MySQL for Dynamic Web Sites”, and More!</a></li></ul><h2 id="about"><span
id="more-2350"></span>About This Newsletter</h2><p>I managed to come up with a theme for this newsletter: how to become a &#8220;real programmer&#8221;. I&#8217;ve received a couple of questions along these lines, and had begun the conversation <a
href="http://www.larryullman.com/2011/02/01/what-is-larry-thinking-36-becoming-a-better-programmer-and-more/#thinking">in the previous newsletter</a>, so I thought I&#8217;d write about the subject even more. In my next newsletter, I <em>think</em> I&#8217;m going to write about the other side of the equation: for those of you trying to build up a career, what it may be like when you get there. I don&#8217;t know: maybe not. Anyway, I&#8217;m likely to include a book giveaway in the next issue, regardless.</p><p>As always, questions, comments, and all feedback are much appreciated. And thanks for your interest in what I have to say and do!</p><p>Also, for those of you that would like to create an &#8220;official&#8221; connection with me, you can do so via <a
href="http://www.linkedin.com/pub/larry-ullman/0/354/a32">LinkedIn</a> (I don&#8217;t use Twitter, Facebook, or other social media).</p><h2 id="you">What are You Thinking? =&gt; &#8220;PHP and MySQL for Dynamic Web Sites&#8221;</h2><p>In this newsletter I&#8217;m starting a new subsection, titled &#8220;What are You Thinking?&#8221;. In such sections, I&#8217;ll directly ask you, the beloved reader, for your input on a given subject. As always, you&#8217;re not obligated to reply, but if you have any thoughts, brief or long, I would really love to hear them. The purpose of such sections is so that I might better cater what I do to what you really want.</p><p>In this newsletter, I&#8217;m wondering what, if anything, you&#8217;d like to see in the next edition of my &#8220;PHP and MySQL for Dynamic Web Sites&#8221; book. This will be the fourth edition, which I&#8217;m going to start writing soon. The immediate plan is to update all the code for the latest version of PHP, remove references to PHP 6 (PHP 6 died since I started writing the last edition of the book), and add a &#8220;Review and Pursue&#8221; section to the end of each chapter, as I did with the fourth edition of my &#8220;PHP for the Web: Visual QuickStart Guide&#8221;. The good news is that I should have room for a new chapter, so I&#8217;m wondering what you might like to see. Ideas off the top of my head include (in no particular order):</p><ul><li>Another example chapter</li><li>An introduction to a framework</li><li>A quick (very quick) introduction to object-oriented programming</li><li>A JavaScript primer</li><li>More information about Web servers (such as .htaccess files)</li><li>More about databases</li></ul><p>So what would be meaningful to you? What have I missed in other editions of this book or my other work? What haven&#8217;t I covered enough?</p><p>As an added incentive, I&#8217;ll give away 10 copies of the book to those in the pool of respondents.</p><h2 id="web1">On the Web =&gt; Two E-Commerce Articles Published Online</h2><p><a
href="http://www.peachpit.com">Peachpit Press</a> has published online two of four articles I&#8217;ve recently written for them. Both articles are in support of my &#8220;<a
href="http://www.larryullman.com/books/effortless-e-commerce-with-php-and-mysql/">Effortless E-Commerce with PHP and MySQL</a>&#8221; book, although the ideas explained are applicable to any e-commerce project.</p><p>The first article is &#8220;<a
href="http://www.peachpit.com/articles/article.aspx?p=1677579">Creating a Customer Review System in PHP and MySQL</a>&#8220;. The second article is &#8220;<a
href="http://www.peachpit.com/articles/article.aspx?p=1678915">Building an E-Commerce Site with PHP: Making Product Recommendations</a>&#8220;. Two more articles, and a series of blog postings, are forthcoming, probably over the next two weeks.</p><h2 id="web2">On the Web =&gt; Several Excerpts from &#8220;Effortless Flex 4 Development&#8221;</h2><p><a
href="http://www.peachpit.com">Peachpit Press</a>, the publisher of my book &#8220;<a
href="http://www.larryullman.com/books/effortless-flex-4-development/">Effortless Flex 4 Development</a>&#8221; (technically, Peachpit&#8217;s sister company New Riders is the publisher), has posted excerpts from the book available for reading—for free—online. You can read about the following subjects:</p><ul><li><a
href="http://www.peachpit.com/articles/article.aspx?p=1676704">Datagroup</a></li><li><a
href="http://www.peachpit.com/articles/article.aspx?p=1676705">Item Renderers</a></li><li><a
href="http://www.peachpit.com/articles/article.aspx?p=1676707">Four Data Formats</a></li><li><a
href="http://www.peachpit.com/articles/article.aspx?p=1676708">Flash Security Model</a></li><li><a
href="http://www.peachpit.com/articles/article.aspx?p=1676709">Using the Network Monitor</a></li><li><a
href="http://www.peachpit.com/articles/article.aspx?p=1676710">Data Paging</a></li><li><a
href="http://www.peachpit.com/articles/article.aspx?p=1676711">Adding Authentication</a></li></ul><p>You can see all the articles and blog posts that I&#8217;ve written for Peachpit Press by viewing <a
href="http://www.peachpit.com/authors/bio.aspx?a=2a14d669-06f6-48cf-a5b8-907169808b9f">my writer&#8217;s page there</a>.</p><h2 id="web3">On the Web =&gt; Toad for MySQL</h2><p>The technical editor on my past two books is a big advocate of <a
href="http://www.quest.com/toad-for-mysql/">Toad for MySQL</a>, a free MySQL tool for Windows. I don&#8217;t regularly use Windows, so I haven&#8217;t tried it myself, but I take Jay (the technical editor) at his word on such things. Plus, it&#8217;s free!</p><h2 id="blog1">On the Blog =&gt; Rendering View Files in Yii</h2><p>On my blog, I recently wrote up a quick guide to <a
href="http://www.larryullman.com/2011/02/15/rendering-view-files-in-yii/">rendering view files using the Yii framework</a>. If you&#8217;re using <a
href="http://www.yiiframework.com">Yii</a>, the article should help you understand these fundamentals, but even if you&#8217;re not using Yii, I hope the article helps convey how frameworks and the MVC design pattern generate the output seen by the user in the Web browser.</p><h2 id="blog2">On the Blog =&gt; Using Amazon&#8217;s CloudFront as a CDN</h2><p>I just published, on my blog, a post explaining <a
href="http://www.larryullman.com/2011/02/20/using-amazons-cloudfront-as-a-cdn/">how I choose and setup Amazon&#8217;s CloudFront as a Content Delivery Network</a>. I decided to finally utilize a CDN in order to improve my site&#8217;s sluggish performance. So far, the experience has been remarkably simple and even more remarkably affordable.</p><h2 id="qa">Q&amp;A =&gt; How Can One Become a &#8220;Real&#8221; Programmer?</h2><p>Celia had sent in this question:</p><blockquote><p>Can a person become a &#8220;real&#8221; web programmer from studying books and online resources, or is it necessary to take college classes and study programming languages such as C++?</p></blockquote><p>I expect many people have wondered this same thing, as you hear about C++ and Java and formal training and certification and can easily believe those things are required to be &#8220;real.&#8221; Well, as a counterpoint, there&#8217;s an argument to be made that I&#8217;m a &#8220;real&#8221; programmer, and my entire body of formal training consists of…one high school Pascal class (twenty years ago). In fact, I expect that a good percentage of people who read my work have more formal computer training than I have. I&#8217;m not saying that to be dismissive of my abilities but rather to say that many paths will get you where you want to go.</p><p>There are really two issues to this question: becoming an able programmer and being employed as a programmer. You can most assuredly become a &#8220;real&#8221; and capable programmer without formal training and without learning a more advanced language like C or C++. First, whatever training you have, formal or not, the fact is that you only master a language by using it. It&#8217;s just as possible to take a course on, or become certified in, a language and never truly master it as it is to teach that same language to yourself and become quite skilled.</p><p>As for the type of language, PHP, my favorite language and the one I use the most, is quite approachable, but that doesn&#8217;t mean it&#8217;s inconsequential. I can program in C and C++ (even Java, to a lessor degree), but don&#8217;t regularly have the need to. There is clearly more than enough that you&#8217;ll be able to do by just picking up PHP, or any other language, through books and online resources.</p><p>The second issue that I think is implied by the question involves &#8220;marketability.&#8221; In this regard, formal training and certification is often necessary (sadly). There are many technical jobs that I wouldn&#8217;t qualify for on paper because I don&#8217;t have a college degree in computer science (it&#8217;s in English). However, there are always ways around such things. Bill Gates doesn&#8217;t have a college degree (not a legitimate one, anyway), and he made out okay. This is to say that you can, with enough talent, imagination, and hard work, invent your own success. Or you can get your foot in the door at a company by performing an apprenticeship. Even when it comes to marketability, the fact is that formal training and certification can only, at best, get you over any initial qualification hurdles when you&#8217;re looking for a job.</p><p>At the end of the day, you can only ever become a &#8220;real&#8221; programmer by <em>doing</em>: creating functional, practical, Web sites, scripts, and applications.</p><h2 id="thinking">What is Larry Thinking? =&gt; Becoming a Better Programmer, Part 2</h2><p>In <a
href="http://www.larryullman.com/2011/02/01/what-is-larry-thinking-36-becoming-a-better-programmer-and-more/#thinking">my previous newsletter</a>, I wrote about how one becomes a better programmer. In the article, I came up with a simple mantra: <em>Read. Do. Review.</em> If it&#8217;s simple, it&#8217;s got to be right, right? A second, related question to how one becomes a better programmer is what actual qualities should a good (or better) programmer have? I haven&#8217;t come up with a pithy answer for that one, but here&#8217;s what I do know…</p><p>First, let&#8217;s distinguish between the &#8220;competent&#8221; programmer and the &#8220;incompetent&#8221; one. The primary basis for the quality of any programming task is: does it work? In other words, does the script or application do what it needs to do? For a competent programmer, the answer is &#8220;yes&#8221;. For an incompetent programmer, it&#8217;s &#8220;no&#8221;. For an incompetent programmer to become a competent one, she or he first needs to overcome this hurdle. To be fair, a competent programmer may write code that has bugs (in fact, is likely to) and the program might not be optimal, but basic functionality is always the first criteria. So the rest of this article is intended to differentiate among the strata of competent programmers.</p><blockquote><p>(If &#8220;competent&#8221; and &#8220;incompetent&#8221;  sound too harsh—because every one of us is incompetent when we begin, you could say &#8220;capable&#8221; and &#8220;incapable&#8221; instead.)</p></blockquote><p>I&#8217;ve come up with three criteria for identifying the quality of code (and therefore, the quality of the programmer): <em>security</em>, <em>usability/maintainability</em>, and <em>performance</em>. You may think I&#8217;m missing something with just three items (and I may be), but sub-factors go into them. Let&#8217;s look at the least important of the criteria: performance.</p><p>On the bright side, performance is easily quantified: run tests and compare numbers. If you write two versions of a PHP script, run them both on the same server, and if one is consistently faster than the other, then it performs better. Better programmers, in my opinion, know how to write code that will perform better. This means that better programmers know things like:</p><ul><li>How to properly design a database</li><li>How to use database indexes appropriately</li><li>To avoid using <strong>include_once()</strong> and <strong>require_once()</strong> (when using PHP)</li><li>How to use caches</li><li>And so forth</li></ul><p>The problem with performance is that this knowledge takes effort to learn. You&#8217;ll have to read a lot, run benchmarks, pay attention, etc. But over time better programmers learn these more optimal programming habits. Also, performance is less important as a criteria because it&#8217;s easily overcome. Not an ideal solution, but if code performs poorly, more hardware can always be thrown at the problem. Conversely, no hardware solution can remedy code that&#8217;s difficult to use or maintain.</p><p>A more critical skill for the better programmer is the ability to write code that&#8217;s easier to use, reuse, and maintain. This skill, while more valuable than being able to write code that performs well, is harder to quantify. But I can say what qualities go into such code.</p><p>Most importantly, code that is well documented is easier to use, reuse, and maintain than code that is not. In fact, if you were to ask me what is the most important quality of a better programmer, I would say <em>better programmers write better documentation.</em> I used to teach an online PHP course for the University of California at Berkeley and I expect that &#8220;document your code more!&#8221; was probably the feedback I gave most often. The last time I did a code review for a client, the code was so poorly documented that there was no way I could have told the client that what their in-house programmer was doing was good or valuable. So if you want to become a better programmer today, start doing a better job of documenting your code! Also, do make sure you update your comments as you change your code. It&#8217;d be better to have no comments at all than to have comments that contradict what the code actually does.</p><p>Second, code that is easier to use, reuse, and maintain is <em>organized well</em>, in terms of files, folders, and functions (I love alliteration; like simplicity, it just has to imply truth). The better programmer makes proper use of subdirectories, included files, and user-defined functions. As for a couple of concrete examples, the better programmer writes included files so that they don&#8217;t make assumptions about what has happened previous to their execution. And the better programmer writes good user-defined functions, with appropriate use of arguments, no reliance upon global variables or other external data, and a &#8220;black box&#8221; mentality (i.e., you don&#8217;t have know how the function does what it does in order to use it correctly).</p><p>Third, code that is easier to use, reuse, and maintain handles errors gracefully and reports them only when appropriate. In an ideal world, the best programmer is writing code without errors, but in the real world, applications have external dependencies that can undermine what you&#8217;ve done. Watching for, and handling, such exceptions is a hallmark of the experienced programmer.</p><p>Finally, and probably most importantly, the better programmer is aware of security: common hacks and how to prevent them, protecting the server, protecting the user, etc. This is a life-long pursuit.</p><p>So those are the qualities that I think of when it comes to differentiating between good and better programmers. I&#8217;m sure I forgot something (feel free to send in your thoughts). I will add that some people see a benefit to brevity when it comes to code. This is particularly true in object-oriented languages, such as Ruby and JavaScript, where multiple actions can take place in a single line. I don&#8217;t personally honor brevity as some great goal, at the very least because brevity often comes at a cost of legibility, which is more important to me. But even if you do value brevity, it&#8217;s really just window dressing compared to these other qualities.</p><h2 id="news">Larry Ullman&#8217;s Book News =&gt; &#8220;PHP for the Web&#8221;, &#8220;PHP and MySQL for Dynamic Web Sites&#8221;, and More!</h2><p>As mentioned already, some of the articles I wrote for <a
href="http://www.Peachpit.com">Peachpit Press&#8217;s Web site</a>, supporting my <a
href="http://www.larryullman.com/books/effortless-e-commerce-with-php-and-mysql/">Effortless E-Commerce with PHP and MySQL</a> book, have been published and more will be soon. I&#8217;ll post links to the new ones on my Web site, and in future newsletters, as they go live.</p><p>The fourth edition of &#8220;PHP for the Web: Visual QuickStart Guide&#8221; has gone to press. I&#8217;ll post updates when it should be available, and give away some copies in the next newsletter. Along with fixing any minor problems, updating the code for the latest version of PHP, and adding a &#8220;Review and Pursue&#8221; section to the end of each chapter, the book includes one new chapter, called &#8220;Putting It All Together.&#8221; The chapter demonstrates how to use everything covered in the book to assemble a mini-Web application, with authentication and full <em>CRUD</em> (Create, Retrieve, Update, and Delete) functionality.</p><p>Either this week or next, I begin writing the fourth edition of my &#8220;PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide.&#8221; Near the beginning of this newsletter I explain my intentions for this edition, and ask for any input you may have. The book should be available come August.</p><p>I have finally begun working on my self-published JavaScript book, although not as regularly as I would like. But starting is a key step. Once I get a decent first draft completed, I&#8217;ll begin looking for volunteer editors and tech reviewers (I&#8217;ll also figure out how to reasonably compensate them!).</p> ]]></content:encoded> <wfw:commentRss>http://www.larryullman.com/2011/02/25/what-is-larry-thinking-37-becoming-a-better-programmer-part-2/feed/</wfw:commentRss> <slash:comments>15</slash:comments> </item> <item><title>Rendering View Files in Yii</title><link>http://www.larryullman.com/2011/02/15/rendering-view-files-in-yii/</link> <comments>http://www.larryullman.com/2011/02/15/rendering-view-files-in-yii/#comments</comments> <pubDate>Tue, 15 Feb 2011 16:08:58 +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[view]]></category> <category><![CDATA[yii]]></category><guid
isPermaLink="false">http://www.larryullman.com/?p=2139</guid> <description><![CDATA[In the MVC architecture, the Controller reacts to a user request. In doing so, the Controller often loads an instance of a particular Model and then renders a specific View. &#8220;Rendering&#8221; just means compiling all the pieces together, including static text (HTML and such) and the output from executed PHP code. For example, when a [...]]]></description> <content:encoded><![CDATA[<p>In the MVC architecture, the Controller reacts to a user request. In doing so, the Controller often loads an instance of a particular Model and then <em>renders</em> a specific View. &#8220;Rendering&#8221; just means compiling all the pieces together, including static text (HTML and such) and the output from executed PHP code. For example, when a user goes to a page for updating a record, the Controller loads the associated record, and then renders the &#8220;update&#8221; View, which will display the pre-populated form:</p><pre class="brush: php; title: ; notranslate">public function actionUpdate($id) {
    $data=$this-&gt;loadModel($id);

    $this-&gt;render('update',array(
        'model'=&gt;$data
    ));
}</pre><blockquote><p>Note: That method would also have code in it for handling the submission of the update form, but I&#8217;m trying not to complicate the discussion.</p></blockquote><p>As you can see in that code, the <strong>render()</strong> method, defined in the <strong>CController</strong> class, is how a View file is chosen for rendering. The first argument to the method is the View file to be rendered, without its <strong>.php</strong> extension. The <strong>render()</strong> method will render the View file within the appropriate layout file. In other words, the View file will be rendered with its context. The above code renders <strong>update.php</strong>, for the associated Controller, wrapped within the <strong>views/layouts/main.php</strong> layout file (the default).</p><p>The second argument to <strong>render()</strong> is an array of data that can be sent to the View file. In the above code, the Model instance is being passed along. In <strong>update.php</strong>, references to the <strong>$model</strong> variable will refer to the loaded data (note that the View gets its variable names from the indexes used in the array).</p><p>The <strong>render()</strong> method takes an optional third argument, which is a Boolean indicating if the rendered result should be returned to the Controller instead of sent to the Web browser. This would be useful if you wanted to render the page and then send the output in an email or write it to a text file on the server (to act as a cached version).</p><p>Sometimes you&#8217;ll want to render a View file without incorporating the layout. To do that, invoke <strong>renderPartial()</strong>. For example, both the <strong>update.php</strong> and <strong>create.php</strong> View files, auto-generated by Yii, just provide a context, and then include the form file:</p><pre class="brush: php; title: ; notranslate">&lt;?php echo $this-&gt;renderPartial('_form', array('model'=&gt;$model)); ?&gt;</pre><p>Since the initial View file will have already be rendered within the layout context, the layout shouldn&#8217;t be rendered again. The <strong>renderPartial()</strong> method will render just the named View file. Its second argument, as with <strong>render()</strong>, can be used to pass data to the View file. In the above, the Model instance is passed along.</p><blockquote><p>Tip: The <strong>renderPartial()</strong> method is also used for Ajax calls, where the layout isn&#8217;t appropriate.</p></blockquote><p>As mentioned already, the file being rendered comes from the directory associated with the current Controller. For example, when updating an <strong>Employee</strong> record, the URL is something like <span
style="text-decoration: underline;">www.example.com/index.php/employee/update/id/23</span>. This calls the <strong>actionUpdate()</strong> method of the <strong>EmployeeController</strong> class (whose code is partially shown above). That method renders the &#8220;update&#8221; View, which is to say <strong>protected/views/employee/update.php</strong>. But there are rare cases where you&#8217;ll need to render View files from other subdirectories. For example, you may want to include a search form on a page, with that form found within another View directory. To change the reference point, start the View reference with a double slash, which means to start in the <strong>views</strong> folder. Then indicate the subdirectory and file, still omitting the extension:</p><pre class="brush: php; title: ; notranslate">&lt;?php echo $this-&gt;renderPartial('//search/_form'); ?&gt;</pre><p>And that&#8217;s all there is to it!</p><p>View rendering is one of the most important concepts to grasp in an MVC design. Fortunately, it&#8217;s not that hard to follow in Yii. Just remember that if you want your layout file, use <strong>render()</strong>. If not, use <strong>renderPartial()</strong>. If you need to pass data to the View file, use the second argument to send along an array, whose indexes will become the names of the variables within the View. Finally, if you need to change the include path, begin with a double slash.</p> ]]></content:encoded> <wfw:commentRss>http://www.larryullman.com/2011/02/15/rendering-view-files-in-yii/feed/</wfw:commentRss> <slash:comments>17</slash:comments> </item> </channel> </rss>
<!-- Served from: www.larryullman.com @ 2012-02-05 15:58:31 by W3 Total Cache -->
