Domain: sitepoint.com
Stories and comments across the archive that link to sitepoint.com.
Stories · 28
-
JavaScript Devs: Is It Still Worth Learning jQuery?
Nerval's Lobster writes: If you're learning JavaScript and Web development, you might be wondering whether to learn jQuery. After nearly a decade of existence, jQuery has grown into a fundamental part of JavaScript coding in Web development. But now we're at a point where many of the missing pieces (and additional features) jQuery filled in are present in browsers. So do you need to learn jQuery anymore? Some developers don't think so. The official jQuery blog, meanwhile, is pushing a separate jQuery version for modern browsers, in an attempt to keep people involved. And there are still a few key reasons to keep learning jQuery: Legacy code. If you're going to go to work at a company that already has JavaScript browser code, there's a strong possibility it has jQuery throughout its code. There's also a matter of preference: People still like jQuery and its elegance, and they're going to continue using it, even though they might not have to. -
Book Review: Build Mobile Websites and Apps For Smart Devices
Michael J. Ross writes "With the proliferation of handheld devices that allow access to the Web, more business owners and other technology decision-makers are demanding that their organizations' websites be fully accessible on those devices, and even be repackaged as new web-based applications. But designers and developers who may be quite proficient in making non-mobile websites and web apps, can feel uncertain as to how to craft those products, or even where to start the process of learning how to do so. Recently, several books have been published to address this need, including Build Mobile Websites and Apps for Smart Devices, authored by Earle Castledine, Myles Eftos, and Max Wheeler." Read on for the rest of Michael's review Build Mobile Websites and Apps for Smart Devices author Earle Castledine, Myles Eftos, Max Wheeler pages 300 pages publisher SitePoint rating 8/10 reviewer Michael J. Ross ISBN 978-0987090843 summary An approachable guide to getting started building mobile web apps. This title was published by SitePoint on 29 June 2011, under the ISBN 978-0987090843. The book's contents span 300 pages, and are organized into a preface, eight chapters, an appendix, and an index. The preface contains the usual meta information about a technical book; but what really shines is its intro section, which enthusiastically entices the reader to jump into the burgeoning field of mobile web development. The appendix, comprising little more than two pages, presents only the most basic information on how to utilize whatever native web server might be running on the reader's Linux, OS X, or Windows Vista/7 machine. The more than 49 percent of computer owners still using Windows XP (as of this writing), will need to look elsewhere for information on installing and configuring Apache, IIS, or some other web server, should they want to test their apps locally. In terms of prerequisites for this book, readers are expected to be proficient in HTML, CSS, and JavaScript, but not necessarily HTML5 and CSS3, whose concepts are explained as needed throughout the text.
The publisher maintains a web page for the book, where visitors can find the table of contents, errata (none as of this writing), the book's index, and three free sample chapters (Chapters 1, 2, and 4) in PDF format. Visitors can order the print version of the book, the electronic version (in three different formats: PDF, EPUB, and MOBI), and an online course hosted by Learnable (comprising lessons, video tutorials, Q&A sessions, and the example code).
The first chapter introduces the basic concepts and rationale of mobile apps, as well as some of the key decisions one will face in creating them, such as whether to make a web app versus a native app, and the options for providing a mobile experience. The authors briefly describe the example app — a tool for recording and sharing celebrity sightings — which is designed and created sequentially in the material that follows. But the chapter does not fulfill the promise made for it in the preface, where the reader is told he will "be guided through the process of designing and building a mobile web application"; on the contrary, the chapter does not explain how to design and build one.
That effort begins in the second chapter, where the authors discuss some high-level considerations for designing the user interfaces of mobile devices, as well as the benefits and drawbacks of various navigation and content structuring options. The bulk of the narrative involves wireframing the design for the example app, selecting colors and fonts, and crafting an appropriate icon for it. Readers learn of the advantages of using relative units in their CSS, but not how to get all the elements positioned properly regardless of the target device's resolution, when mixing relative units for text and pixel units for images. The section "Scalable Images," later in the subsequent chapter, is a start, but is not sufficient for non-SVG images.
Chapter 3, "Markup for Mobile," is the longest of them all, primarily because it presents much if not all of the source code written by the authors for the initial version of their example app. The majority of the code is in HTML and CSS, with a focus upon the effects made possible using HTML5 and CSS3. Also discussed are the resource limitations of typical mobile devices, content and menu display options, image techniques and scalability, viewport meta element settings, icons, multimedia, and more. Oddly, on pages 71-72, the resource limitations of iOS are repeated, with only slightly different wording. How could the proofreaders have missed this glaring redundancy?
The fourth chapter, "Mobile Web Apps," addresses the logical next step: enhancing a mobile website so it can function as a web app — for which JavaScript is used extensively. After briefly mentioning a couple of the better-known mobile development frameworks, the authors select jQuery as a library for working with the DOM, to speed development and make the example code more platform neutral. There follows an interesting discussion of touch events on mobile devices, how they compare to mouse events, and techniques for best handling them. But the main goal is to show how to load, swap, and go back to pages so as to most closely simulate the snappy behavior of native apps. The extensive code and narrative in this chapter are the most complex of any in the book, and thus will likely be the most challenging for any reader who is not adept with JavaScript and/or jQuery, or who does not have the patience to work through the example code.
At first glance, it would appear that native apps have a huge advantage over web apps, in that they can access information from their mobile devices' capabilities — such as accelerometers and cameras — historically unavailable to mobile web browsers. Fortunately, an increasing number of standard interfaces are allowing web apps to access that data — and this is the topic of the fifth chapter. The reader is shown how to capture and utilize geolocation data, device rotation and acceleration, as well as shake and touch gestures. The chapter concludes with coverage of how to use HTML5 Offline Web Applications API for enabling an app to work when no network access is available. The subsequent chapter, "Polishing up Our App," shows the reader how to do just that — specifically, preventing the navigation header from scrolling off the screen, handling click processing delays, displaying dialog boxes, storing data on the client device, and other differences. The narrative is clear, except for a perplexing ornithological expression, "Duck-type" (page 182). Experienced developers will appreciate the section on mobile coding best practices, based on controllers and custom events — for minimizing programming headaches as a project's code becomes sizable.
The last two chapters explain how to convert a web app into a native app, using PhoneGap, an HTML5 application platform that allows a Web app to access those resources of the mobile device that would otherwise be unavailable, such as data in the filesystem and images from any built-in camera. Before demonstrating the details of how to implement those capabilities, the authors show how to install the development environments for all of the supported platforms (including Apple iOS and Google Android), and then PhoneGap itself. Lastly, readers learn how to try to monetize their finished web apps by uploading them to the various app stores.
The authors make extensive use of example source code, to illustrate the ideas being discussed, which works well, partly because the code is generally explained clearly and commented as needed. A code archive is available containing the source code used in the book, except that of the first two chapters and the last two, which collectively is minimal. (Look for the "Downloads" button on that GitHub page to avoid having to download all the files separately.) Beware that some of the sample code appears to be incorrect or incomplete, e.g., stars.html in the directories "ch3" and "ch4" appear to be unstyled, and "javascripts/ch3/untitled file" is empty. Readers who elect to type in any code directly from the book, should watch out for "curly quotes" (e.g., page 230), and instead substitute the corresponding straight equivalents.
In terms of the physical presentation of the book, at 9.9 x 8 inches, it is taller and wider than the standard nowadays, allowing for what appears to be a relatively larger font, which makes the text more readable. The attractive color figures are a welcome change from the usual black-and-white screenshots found in most computer books. They enhance the overall appearance of the book's interior and the experience of reading the narrative.
Speaking of which, most of the narrative is quite clear. However, one critical topic for mobile design is screen resolution, including how to best defensively account for that in one's design and coding. This book's coverage of the topic is divided into at least two different places (pages 40 and 55), and should have been consolidated, in the third chapter. Unlike most programming books littered with chapter summaries, this one appears to have only one section with a summary, which oddly does not summarize the information presented in the section, but instead offers some interpretation thereof. Also, American readers might stumble over a few of the words that use the English/Australian spelling, e.g., "license" (page 239).
Some of the phrasing will likely befuddle the majority of readers, especially in cases where the authors fail to define their terms, e.g., the first bullet point on page 47. There are a few minor inconsistencies in the writing, such as "fill out forms" and "fill in a form" (on the same page, 32), but nothing that would cause confusion on the reader's part. The overall writing style is friendly, although sometimes overdone with an excessive use of exclamation marks (e.g., page 40). The text contains some errata (including several that suggest that the SitePoint copyeditors are unfamiliar with the ability of even a common word processor such as Microsoft Word to detect duplicate words): "to thank to" (page xxi), "the the" (pages 8 and 84), "for for" (13), "look at [in] Chapter 6" (34), "let[']s break" (44), ", (" (54 and 142), "no way to we can used" (55), "[up] to this point" (82), "try and" (82, 93, 131, and 167; should read "try to"), "support [for] standalone mode" (89), "are are" (139), "it's" (162; should read "its"), "if there are" (172; should read "if there were"), "ultimately .depend" (196), "On[c]e you've installed" (203), "we're yet" (212; should read "we've yet"), "an an" (225), "more detail that" (238; should read "more detail than"), and "a a" (240).
Yet none of the aforementioned problems are of great significance, and do not detract from the value of the material presented. All three authors have extensive experience in designing and developing mobile web applications, and this is reflected in the authority with which they not only offer the technical details, but also make recommendations to the reader. This book would serve as an excellent starting point for any web programmer who wishes to learn how to create mobile web sites and applications.
Michael J. Ross is a freelance web developer and writer.
You can purchase Build Mobile Websites and Apps for Smart Devices from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
Grad Student Project Uses Wikis To Stash Data, Miffs Admins
Anonymous writes "Two graduate students at the Ivy League's Brown University built a P2P system to use abandoned wiki sites to store data. The students were stealing bandwidth from open MediaWiki sites to send data between users as an alternative to BitTorrent. There was immediate backlash as site operators quickly complained to the University. The project appears to be shutdown, but many of the pages still remain on the web. The project homepage was also taken down and the students posted an apology this afternoon." The same submitter links to two different forum discussions on the project. -
Managing Online Forums
stoolpigeon writes "I vividly remember the first time I was able to dial up a BBS with my Commodore VIC-20. It was Star Trek themed, and I was excited to see that the Sysop was online. We typed a few lines of text back and forth while I hollered to everyone in the house that I was talking to someone through the computer. Things have come a long way since then, and I've put in quite a few hours experiencing one of the more exciting sides of the internet: participating in community. Of course it hasn't all been great. Communities on-line are just like any other, in that there are differences of opinion and issues that arise. Some are handled well, some are not. Social interaction can be very complicated, and learning how to manage a social site can be a process that involves a lot of painful lessons. Fortunately not all of our learning has to come through direct experience. Sometimes we have the opportunity to learn from the experience of others. Patrick O'Keefes book Managing Online Forums is that guide to the budding leader of the web's next great community. Keep reading for the rest of JR's review. Managing Online Forums author Patrick O'Keefe pages 312 publisher AMACOM rating 9/10 reviewer JR Peck ISBN 978-0-8144-0197-2 summary Everything you need to know to create and run successful community discussion boards. Since the reader will be relying on O'Keefes experience and opinions, his personal history in the subject at hand is extremely relevant. He has been involved in web site design since 1998 and managing online communities since 2000. As the founder and owner of the iFroggy Network he has extensive experience in managing site policy, staff and members. O'Keefe is also active in other communities including his role as a moderator for Sitepoint. Patrick has also published articles there on forum management.
The book's byline is that it provides everything that you need to know to run a successful community discussion board. There is a wide range of topics covered though the emphasis is primarily placed on what I would call the soft side of community management. The technical discussion is limited, though it is there. There is no real discussion of how to go about setting up software. There are some suggestions as to choosing a domain name and software. Two options are given for software, vBulletin and phpBB. Each is described in a summary consisting of a few paragraphs of basic information. There is little discussion of installation from a technical standpoint. The most technical information deals with the core issues of security and backing up data. I didn't see this as a real weakness as there is already plenty of documentation on these choices and many more. Adding it all in would have really bulked up the book while distracting from the primary mission which is informing the reader on building successful communities.
While there is not much technical detail, there is discussion of features from a social perspective. O'Keefe doesn't discuss whether or not a feature should be used because performance or storage ramification but rather focuses on the positives or negatives in terms of managing how participants might view or use those options. This is the information that is not already out there in multiple places. O'Keefe is able to discuss from experience how he has seen users react to these features in the past as well as warning of any possible benefits or pitfalls. This is of course his opinion on these matters. This fact about the nature of the book is going to make or break it for the reader.
I envision that someone would come to this book from three possible positions. They may already have a strong opinion of the issues presented and disagree with the author. On the other hand they may agree. The last group would be people who come without strong presuppositions. I think that the first group would not enjoy the book, there is no objective evidence or argument that will bring these people over. This is after all, subjective opinion. The other two groups I think have a lot to gain, the third group most of all. A person who comes to the material with an open mind, looking for options and guidance will I gain a strong preparation for dealing with a number of issues that are almost certain to arise in online groups.
The book begins by quickly reviewing a set of basic questions that should be asked before a site is set up for a new community. They are fundamental but important and I think it is surprising how many endeavors to build communities don't seem to have considered them. The are, "What will your community cover?", "Whom do you want to attract?", "What will the benefits of your community be?", and "How will you support the community financially?". All of these questions, the naming of the community and site, hosting and software are covered up front.
In each of the following major sections, the author's advice is accompanied by example templates and policies. In chapter three, "Developing Guidelines", the community guidelines for KarateForums.com and SitePoint.com are printed. There are excellent documents in the chapter on managing staff that give good examples of staff guidelines that can be used in those communities that grow and the work of management needs to be shared. All of these are built on real policies and guidelines. The staff section also includes a nice decision matrix for various situations that may arise, such as hot linking or cross posting.
The chapter "Banning Users and Dealing with Chaos" is of course full of interesting examples and history. It is also very valuable. The fact is any successful community will need to deal with adverse conditions and this is where inexperience can be the most costly. O'Keefe outlines likely scenarios and how to handle them. He also gives further examples of guidelines that can help the administrator in staying above the fray and maintaining their sanity when things can be very contentious. From the personal anecdotes, O'Keefe has already been through much of the worse that the web has to offer. This chapter and all that it entails is balance by a chapter on creating a good and healthy environment as well as the importance of keeping things interesting.
Two other chapters deal with what I think of as the business side of running forums. There is a chapter on developing traffic. I was glad to see that this included not only what to do but also what not to do. And there are similar warning within methods that can be used in a positive way or a negative way. O'Keefe cautions against activities that may bring what appear to be short term gains but do not really build sustainable community. While physically separate in the book, I found that this section dovetailed with the chapter on generating income. O'Keefe basically runs down all the various methods for making money with a site. Once again he give the pros and cons as well as strong warnings against the things that are going to be counter productive.
There are three appendices. The first is a list of resources, the second is a set of blank templates that match the examples given in the body of the book and the third is a glossary. I think that glossary is an important because I believe that this book would be an excellent guide to anyone who wants to not only form an online community but is new to the whole idea. These folks may be very caught off guard by the things they will probably need to deal with, beyond the technical issues of getting a site up and running. This book would probably be something that anyone out there setting up sites for others could quickly recommend to help the new manager to be be successful once the site is up and live.
I think there is a lot here also for those with some experience on-line if they don't have a lot of experience running a community site or if they are just looking for some new ideas. I've been corresponding with others electronically for quite a while and I still found quite a bit here that was of value. There is also the strength of going in with policies and actions that are built to head off problems rather than respond to them once they have taken place. I would think this gives any new community a much higher chance of growing and thriving. Managing Online Forums is unique in this regard, to my knowledge. Taking on the human side of managing a site rather than just the technical components.
You can purchase Managing Online Forums from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
The Ultimate CSS Reference
stoolpigeon writes "Cascading Style Sheets are now the dominant method used to format web pages. Even something as simple as modifying a WordPress blog can involve digging around a bit in CSS. A quick search at Amazon on CSS returns over 7 thousand books in the computer category alone. This book claims to be the ultimate, though, and that made me approach it with a bit of skepticism. Sure, it could be a decent reference, but is it truly the ultimate reference? I admit I was curious to see." Read on for the rest of JR's review. The Ultimate CSS Reference author Tommy Olsson & Paul O'Brien pages 420 publisher SitePoint rating 9/10 reviewer JR Peck ISBN 978-0-9802858-5-7 summary All the CSS knowledge you'll ever need. If any book is going to be an acceptable reference there are a few things that are going to need to be in place, no matter what the subject matter. I'd like to discuss those first, from front to back. The table of contents takes up 9 pages. It is specific enough to easily get the reader pointed in the right direction.
The first two chapters cover introductory material, discussing just what CSS is, what it does, and syntax/nomenclature issues. After that, every chapter is reference material, until chapter 16. The last three chapters cover vendor specific properties, various hacks and work-arounds as well as the difference between html and xhtml. Those five chapters are presented more as straight out prose compared to the reference chapters between, though they still use extensive highlighting and background colors to divide and organize content.
The reference chapters are extremely well laid out. A command, property or other item is in bold at the beginning. Below it, highlighted in grey are various arguments that can be used with that item. An example will be given in a colored box. There are two grids. One covers three aspects of the spec for this item; if it is inherited, the initial value and thecss version of the item. There is also a list of browser support for the item in IE6+, FF1+, Saf 1.3+ and Op9.2+. The second grid shows compatibility for three versions of Internet Explorer (5.5, 6.0 and 7.0), three versions ofFirefox (1.0, 1.5 and 2.0), three versions of Safari (1.3, 2.0 and 3.0) and Opera 9.2. When appropriate there is also a discussion of or list of appropriate values and discussion of usage.
At the end of the book is a single appendix which contains an alphabetical index of properties. There is no proper index for the full book, which is not as bad as it could have been, without the other tools, but is still disappointing.
The typography is clear. The book is concise and clear with little wasted space or verbiage. The color scheme for highlighting the various sections is extremely easy to read and pleasant.
There is one more feature of the book that, aside from content, makes it very useful. There is an online edition of The Ultimate CSS Reference and as far as I can tell, it is completely open to use by anyone without any kinds of restrictions. I couldn't find any in my copy of the book, I didn't have to sign up for anything to use the site. This really makes up for the lack of an index as the entire book is searchable from the site. For me, it is the best of both worlds. I have the dead-tree version on my shelf, ready to pull down and satisfy my curiosity. I have the electronic version freely available on the web site, should I need it. The site has the added bonus of including an area for comments on the contents of the book, and there are already some helpful comments and tips there.
I think then, it is safe to say that mechanically this is a more than acceptable reference. The other important piece aside from it being usable, is the quality of the information itself. Good information is useless if one cannot get to it, and a great access system is useless if the information is no good.
The authors, O'Brien and Olsson are themselves extremely experienced in the field and I think it is safe to say they are experts in regards to CSS. The book also had two experienced "Expert Reviewers" in Natalie Downe and Roger Johansson. I couldn't find any problems with the content, and I think that it is safe to say that these four, along with others have done due diligence to provide an accurate guide to CSS.
Is this the ultimate CSS reference? I haven't read the others, and ultimate seems to imply comparison to me. So while it might not be the ultimate, I do feel comfortable recommending it to anyone who needs an extremely usable, accurate reference to CSS. I would even recommend it to a beginner who wants to learn CSS, though they should probably augment this book with something aimed at teaching CSS, not just providing a reference.
You can purchase The Ultimate CSS Reference from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
The PHP Anthology 2nd Edition
Michael J. Ross writes "When veteran PHP developers have specific and nontrivial functionality that they want to implement in their code, they can do so from scratch, but this can be time-consuming or essentially reinventing the wheel. They can adopt completed code posted in an online discussion forum, but such code tends to be buggy. They can use an open source library or other packaged code, but this approach can oftentimes prove to be overkill. Consequently, many developers prefer focused solutions found in PHP cookbooks, such as The PHP Anthology: 101 Essential Tips, Tricks & Hacks." Read on for the rest of Michael's review. The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition author Davey Shafik, Matthew O'Phinney, Ligaya Turmelle, Harry Fuecks, and Ben Balbo pages 542 publisher SitePoint rating 9/10 reviewer Michael J. Ross ISBN 0975841998 summary A tasty cookbook of PHP recipes The second edition of this book was published by SitePoint on 23 October 2007, under the ISBNs 0975841998 and 978-0975841990. On the book's Web page, the publisher makes available an overview of the book, links to the authors' sites, chapter descriptions, the table of contents, the index, editorial and customer reviews, the book's sample code, and errata (there are none as of this writing). In addition, there is a link for downloading three sample chapters (2, 10, and 11), in PDF format. The pop-up window for entering an e-mail address for receiving the download link, also gives one a chance to subscribe to SitePoint's Web development newsletters.
All of the authors of The PHP Anthology — Davey Shafik, Matthew O'Phinney, Ligaya Turmelle, Harry Fuecks, and Ben Balbo — appear to have plenty of experience with the language, and probably also have spent time interacting with other PHP programmers in online forums, including SitePoint's own PHP forum. Experience reading the questions posted by programmers of all skill levels, and especially trying to answer them, can give anyone a better understanding of what are the most common challenges encountered by the typical PHP coder. In the book's preface, the authors note that, for choosing the particular problems for their book, they chose ones frequently seen in the SitePoint forum, which is likely representative of all active PHP forums.
This new edition of the book has been updated for PHP version 5, including PHP's major improvements to its implementation of classes and objects, among other aspects of the language. It is one of a growing number of PHP books that depart from the traditional tutorial and reference formats, and is instead written in the increasingly popular "cookbook style." Each section presents first a common problem that Web programmers often encounter, followed by generally complete source code that solves the problem, and commentary that explains the overall solution, along with special considerations that the programmer should watch out for in adapting the given source code to their own situation.
As seen in the majority of cookbook-style programming books, this one groups the problem-and-solution sections into chapters, of which there are 13: an introduction; working with databases using the PHP Data Objects (PDO) extension; strings; dates and times; forms, tables, and clean URLs; files; e-mail; digital images; error handling; access control; client- and server-side caching; XML and Web services; PHP coding best practices. In addition to the preface and index, the book also has four appendices: configuring PHP; a checklist for choosing a Web hosting service; a security checklist; and working with the PHP Extension and Application Repository (PEAR). In total, the book is 542 pages long, and yet it is not visually overwhelming, partly because of the large and readable font chosen by the publisher, as well as the innumerable code snippets and browser screen shots interspersed throughout the narrative.
The primary strength of this book is the significant amount of information provided to the reader, in the form of summaries of critical Web programming problems, working PHP code that addresses those problems, discussion as to why each particular approach was taken, and occasional asides that warn the reader about special difficulties that they might encounter as they implement the solutions within their own development environments and for their own projects. Some of the material may be of little interest to the average reader — such as the chapters on PDO and XML — but most of the material would be of interest and benefit to any conscientious PHP programmer. The chapters on error handling and access control are alone worth the price of the book.
However, this second edition of the book has some weaknesses that may or may not have been introduced since the first edition (which was not readily available for comparison). But none of them are overwhelming or unfixable. Firstly, a reader hoping for a well-edited book will likely become distrustful by the authors' misuse of the term "that" in place of "who." Secondly, there are far too many ambiguous comments in the first-person, e.g., "I would dare to say that..." In a book written by five authors, the reader naturally has no idea who is speaking. Thirdly, there is a fair amount of inconsistency in the formatting of the code throughout the book, including indentation and other spacing, as well as variable naming. Also, every instance of a "{" on its own line (presumably to line up vertically with the corresponding "}"), is an antiquated waste of space, since any decent programmer's editor or integrated development environment (IDE) can do brace matching automatically.
Lastly, almost all of the section titles begin with the phrase "How do I." That is fine within the body of the book, at the beginning of every section. But when dozens of these section titles are listed together in the table of contents, that phrase could be excised so each section's topic would be faster to spot, and there would be fewer unnecessary words. In fact, the section titles don't necessarily have to be posed as questions. For instance, "Using Sessions" would be just as clear as "How do I use sessions?" and faster to read.
It should be noted that this book is best suited for intermediate to advanced PHP programmers, who will certainly get the most out of it. A programmer new to PHP, who would like to begin learning the language, should start with any one of the many tutorial-style PHP books available.
For readers who prefer the portability or environmental benefits of e-books, a PDF version of The PHP Anthology is available from the publisher, on the aforesaid Web page. Any programmer who is — or anticipates — doing PHP work away from their print technical library, should definitely consider obtaining the e-book, which thus can be added to their laptop's development environment, and be readily available for quick reference. The e-book contains all of the content of the print version. It also makes good use of color, for screenshots and other illustrations, as well as using a blue background for the sample code, which is a bit easier to read than the gray used in the print version.
Overall, this new edition of The PHP Anthology offers practical solutions to many common PHP problems, clear explanations of those solutions, and working code — in print and online — that can be quickly used as is or modified as needed. PHP developers should find this book an informative and valuable part of their technical library.
Michael J. Ross is a Web developer, writer, and freelance editor.
You can purchase The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
The PHP Anthology 2nd Edition
Michael J. Ross writes "When veteran PHP developers have specific and nontrivial functionality that they want to implement in their code, they can do so from scratch, but this can be time-consuming or essentially reinventing the wheel. They can adopt completed code posted in an online discussion forum, but such code tends to be buggy. They can use an open source library or other packaged code, but this approach can oftentimes prove to be overkill. Consequently, many developers prefer focused solutions found in PHP cookbooks, such as The PHP Anthology: 101 Essential Tips, Tricks & Hacks." Read on for the rest of Michael's review. The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition author Davey Shafik, Matthew O'Phinney, Ligaya Turmelle, Harry Fuecks, and Ben Balbo pages 542 publisher SitePoint rating 9/10 reviewer Michael J. Ross ISBN 0975841998 summary A tasty cookbook of PHP recipes The second edition of this book was published by SitePoint on 23 October 2007, under the ISBNs 0975841998 and 978-0975841990. On the book's Web page, the publisher makes available an overview of the book, links to the authors' sites, chapter descriptions, the table of contents, the index, editorial and customer reviews, the book's sample code, and errata (there are none as of this writing). In addition, there is a link for downloading three sample chapters (2, 10, and 11), in PDF format. The pop-up window for entering an e-mail address for receiving the download link, also gives one a chance to subscribe to SitePoint's Web development newsletters.
All of the authors of The PHP Anthology — Davey Shafik, Matthew O'Phinney, Ligaya Turmelle, Harry Fuecks, and Ben Balbo — appear to have plenty of experience with the language, and probably also have spent time interacting with other PHP programmers in online forums, including SitePoint's own PHP forum. Experience reading the questions posted by programmers of all skill levels, and especially trying to answer them, can give anyone a better understanding of what are the most common challenges encountered by the typical PHP coder. In the book's preface, the authors note that, for choosing the particular problems for their book, they chose ones frequently seen in the SitePoint forum, which is likely representative of all active PHP forums.
This new edition of the book has been updated for PHP version 5, including PHP's major improvements to its implementation of classes and objects, among other aspects of the language. It is one of a growing number of PHP books that depart from the traditional tutorial and reference formats, and is instead written in the increasingly popular "cookbook style." Each section presents first a common problem that Web programmers often encounter, followed by generally complete source code that solves the problem, and commentary that explains the overall solution, along with special considerations that the programmer should watch out for in adapting the given source code to their own situation.
As seen in the majority of cookbook-style programming books, this one groups the problem-and-solution sections into chapters, of which there are 13: an introduction; working with databases using the PHP Data Objects (PDO) extension; strings; dates and times; forms, tables, and clean URLs; files; e-mail; digital images; error handling; access control; client- and server-side caching; XML and Web services; PHP coding best practices. In addition to the preface and index, the book also has four appendices: configuring PHP; a checklist for choosing a Web hosting service; a security checklist; and working with the PHP Extension and Application Repository (PEAR). In total, the book is 542 pages long, and yet it is not visually overwhelming, partly because of the large and readable font chosen by the publisher, as well as the innumerable code snippets and browser screen shots interspersed throughout the narrative.
The primary strength of this book is the significant amount of information provided to the reader, in the form of summaries of critical Web programming problems, working PHP code that addresses those problems, discussion as to why each particular approach was taken, and occasional asides that warn the reader about special difficulties that they might encounter as they implement the solutions within their own development environments and for their own projects. Some of the material may be of little interest to the average reader — such as the chapters on PDO and XML — but most of the material would be of interest and benefit to any conscientious PHP programmer. The chapters on error handling and access control are alone worth the price of the book.
However, this second edition of the book has some weaknesses that may or may not have been introduced since the first edition (which was not readily available for comparison). But none of them are overwhelming or unfixable. Firstly, a reader hoping for a well-edited book will likely become distrustful by the authors' misuse of the term "that" in place of "who." Secondly, there are far too many ambiguous comments in the first-person, e.g., "I would dare to say that..." In a book written by five authors, the reader naturally has no idea who is speaking. Thirdly, there is a fair amount of inconsistency in the formatting of the code throughout the book, including indentation and other spacing, as well as variable naming. Also, every instance of a "{" on its own line (presumably to line up vertically with the corresponding "}"), is an antiquated waste of space, since any decent programmer's editor or integrated development environment (IDE) can do brace matching automatically.
Lastly, almost all of the section titles begin with the phrase "How do I." That is fine within the body of the book, at the beginning of every section. But when dozens of these section titles are listed together in the table of contents, that phrase could be excised so each section's topic would be faster to spot, and there would be fewer unnecessary words. In fact, the section titles don't necessarily have to be posed as questions. For instance, "Using Sessions" would be just as clear as "How do I use sessions?" and faster to read.
It should be noted that this book is best suited for intermediate to advanced PHP programmers, who will certainly get the most out of it. A programmer new to PHP, who would like to begin learning the language, should start with any one of the many tutorial-style PHP books available.
For readers who prefer the portability or environmental benefits of e-books, a PDF version of The PHP Anthology is available from the publisher, on the aforesaid Web page. Any programmer who is — or anticipates — doing PHP work away from their print technical library, should definitely consider obtaining the e-book, which thus can be added to their laptop's development environment, and be readily available for quick reference. The e-book contains all of the content of the print version. It also makes good use of color, for screenshots and other illustrations, as well as using a blue background for the sample code, which is a bit easier to read than the gray used in the print version.
Overall, this new edition of The PHP Anthology offers practical solutions to many common PHP problems, clear explanations of those solutions, and working code — in print and online — that can be quickly used as is or modified as needed. PHP developers should find this book an informative and valuable part of their technical library.
Michael J. Ross is a Web developer, writer, and freelance editor.
You can purchase The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
The PHP Anthology 2nd Edition
Michael J. Ross writes "When veteran PHP developers have specific and nontrivial functionality that they want to implement in their code, they can do so from scratch, but this can be time-consuming or essentially reinventing the wheel. They can adopt completed code posted in an online discussion forum, but such code tends to be buggy. They can use an open source library or other packaged code, but this approach can oftentimes prove to be overkill. Consequently, many developers prefer focused solutions found in PHP cookbooks, such as The PHP Anthology: 101 Essential Tips, Tricks & Hacks." Read on for the rest of Michael's review. The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition author Davey Shafik, Matthew O'Phinney, Ligaya Turmelle, Harry Fuecks, and Ben Balbo pages 542 publisher SitePoint rating 9/10 reviewer Michael J. Ross ISBN 0975841998 summary A tasty cookbook of PHP recipes The second edition of this book was published by SitePoint on 23 October 2007, under the ISBNs 0975841998 and 978-0975841990. On the book's Web page, the publisher makes available an overview of the book, links to the authors' sites, chapter descriptions, the table of contents, the index, editorial and customer reviews, the book's sample code, and errata (there are none as of this writing). In addition, there is a link for downloading three sample chapters (2, 10, and 11), in PDF format. The pop-up window for entering an e-mail address for receiving the download link, also gives one a chance to subscribe to SitePoint's Web development newsletters.
All of the authors of The PHP Anthology — Davey Shafik, Matthew O'Phinney, Ligaya Turmelle, Harry Fuecks, and Ben Balbo — appear to have plenty of experience with the language, and probably also have spent time interacting with other PHP programmers in online forums, including SitePoint's own PHP forum. Experience reading the questions posted by programmers of all skill levels, and especially trying to answer them, can give anyone a better understanding of what are the most common challenges encountered by the typical PHP coder. In the book's preface, the authors note that, for choosing the particular problems for their book, they chose ones frequently seen in the SitePoint forum, which is likely representative of all active PHP forums.
This new edition of the book has been updated for PHP version 5, including PHP's major improvements to its implementation of classes and objects, among other aspects of the language. It is one of a growing number of PHP books that depart from the traditional tutorial and reference formats, and is instead written in the increasingly popular "cookbook style." Each section presents first a common problem that Web programmers often encounter, followed by generally complete source code that solves the problem, and commentary that explains the overall solution, along with special considerations that the programmer should watch out for in adapting the given source code to their own situation.
As seen in the majority of cookbook-style programming books, this one groups the problem-and-solution sections into chapters, of which there are 13: an introduction; working with databases using the PHP Data Objects (PDO) extension; strings; dates and times; forms, tables, and clean URLs; files; e-mail; digital images; error handling; access control; client- and server-side caching; XML and Web services; PHP coding best practices. In addition to the preface and index, the book also has four appendices: configuring PHP; a checklist for choosing a Web hosting service; a security checklist; and working with the PHP Extension and Application Repository (PEAR). In total, the book is 542 pages long, and yet it is not visually overwhelming, partly because of the large and readable font chosen by the publisher, as well as the innumerable code snippets and browser screen shots interspersed throughout the narrative.
The primary strength of this book is the significant amount of information provided to the reader, in the form of summaries of critical Web programming problems, working PHP code that addresses those problems, discussion as to why each particular approach was taken, and occasional asides that warn the reader about special difficulties that they might encounter as they implement the solutions within their own development environments and for their own projects. Some of the material may be of little interest to the average reader — such as the chapters on PDO and XML — but most of the material would be of interest and benefit to any conscientious PHP programmer. The chapters on error handling and access control are alone worth the price of the book.
However, this second edition of the book has some weaknesses that may or may not have been introduced since the first edition (which was not readily available for comparison). But none of them are overwhelming or unfixable. Firstly, a reader hoping for a well-edited book will likely become distrustful by the authors' misuse of the term "that" in place of "who." Secondly, there are far too many ambiguous comments in the first-person, e.g., "I would dare to say that..." In a book written by five authors, the reader naturally has no idea who is speaking. Thirdly, there is a fair amount of inconsistency in the formatting of the code throughout the book, including indentation and other spacing, as well as variable naming. Also, every instance of a "{" on its own line (presumably to line up vertically with the corresponding "}"), is an antiquated waste of space, since any decent programmer's editor or integrated development environment (IDE) can do brace matching automatically.
Lastly, almost all of the section titles begin with the phrase "How do I." That is fine within the body of the book, at the beginning of every section. But when dozens of these section titles are listed together in the table of contents, that phrase could be excised so each section's topic would be faster to spot, and there would be fewer unnecessary words. In fact, the section titles don't necessarily have to be posed as questions. For instance, "Using Sessions" would be just as clear as "How do I use sessions?" and faster to read.
It should be noted that this book is best suited for intermediate to advanced PHP programmers, who will certainly get the most out of it. A programmer new to PHP, who would like to begin learning the language, should start with any one of the many tutorial-style PHP books available.
For readers who prefer the portability or environmental benefits of e-books, a PDF version of The PHP Anthology is available from the publisher, on the aforesaid Web page. Any programmer who is — or anticipates — doing PHP work away from their print technical library, should definitely consider obtaining the e-book, which thus can be added to their laptop's development environment, and be readily available for quick reference. The e-book contains all of the content of the print version. It also makes good use of color, for screenshots and other illustrations, as well as using a blue background for the sample code, which is a bit easier to read than the gray used in the print version.
Overall, this new edition of The PHP Anthology offers practical solutions to many common PHP problems, clear explanations of those solutions, and working code — in print and online — that can be quickly used as is or modified as needed. PHP developers should find this book an informative and valuable part of their technical library.
Michael J. Ross is a Web developer, writer, and freelance editor.
You can purchase The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
The PHP Anthology 2nd Edition
Michael J. Ross writes "When veteran PHP developers have specific and nontrivial functionality that they want to implement in their code, they can do so from scratch, but this can be time-consuming or essentially reinventing the wheel. They can adopt completed code posted in an online discussion forum, but such code tends to be buggy. They can use an open source library or other packaged code, but this approach can oftentimes prove to be overkill. Consequently, many developers prefer focused solutions found in PHP cookbooks, such as The PHP Anthology: 101 Essential Tips, Tricks & Hacks." Read on for the rest of Michael's review. The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition author Davey Shafik, Matthew O'Phinney, Ligaya Turmelle, Harry Fuecks, and Ben Balbo pages 542 publisher SitePoint rating 9/10 reviewer Michael J. Ross ISBN 0975841998 summary A tasty cookbook of PHP recipes The second edition of this book was published by SitePoint on 23 October 2007, under the ISBNs 0975841998 and 978-0975841990. On the book's Web page, the publisher makes available an overview of the book, links to the authors' sites, chapter descriptions, the table of contents, the index, editorial and customer reviews, the book's sample code, and errata (there are none as of this writing). In addition, there is a link for downloading three sample chapters (2, 10, and 11), in PDF format. The pop-up window for entering an e-mail address for receiving the download link, also gives one a chance to subscribe to SitePoint's Web development newsletters.
All of the authors of The PHP Anthology — Davey Shafik, Matthew O'Phinney, Ligaya Turmelle, Harry Fuecks, and Ben Balbo — appear to have plenty of experience with the language, and probably also have spent time interacting with other PHP programmers in online forums, including SitePoint's own PHP forum. Experience reading the questions posted by programmers of all skill levels, and especially trying to answer them, can give anyone a better understanding of what are the most common challenges encountered by the typical PHP coder. In the book's preface, the authors note that, for choosing the particular problems for their book, they chose ones frequently seen in the SitePoint forum, which is likely representative of all active PHP forums.
This new edition of the book has been updated for PHP version 5, including PHP's major improvements to its implementation of classes and objects, among other aspects of the language. It is one of a growing number of PHP books that depart from the traditional tutorial and reference formats, and is instead written in the increasingly popular "cookbook style." Each section presents first a common problem that Web programmers often encounter, followed by generally complete source code that solves the problem, and commentary that explains the overall solution, along with special considerations that the programmer should watch out for in adapting the given source code to their own situation.
As seen in the majority of cookbook-style programming books, this one groups the problem-and-solution sections into chapters, of which there are 13: an introduction; working with databases using the PHP Data Objects (PDO) extension; strings; dates and times; forms, tables, and clean URLs; files; e-mail; digital images; error handling; access control; client- and server-side caching; XML and Web services; PHP coding best practices. In addition to the preface and index, the book also has four appendices: configuring PHP; a checklist for choosing a Web hosting service; a security checklist; and working with the PHP Extension and Application Repository (PEAR). In total, the book is 542 pages long, and yet it is not visually overwhelming, partly because of the large and readable font chosen by the publisher, as well as the innumerable code snippets and browser screen shots interspersed throughout the narrative.
The primary strength of this book is the significant amount of information provided to the reader, in the form of summaries of critical Web programming problems, working PHP code that addresses those problems, discussion as to why each particular approach was taken, and occasional asides that warn the reader about special difficulties that they might encounter as they implement the solutions within their own development environments and for their own projects. Some of the material may be of little interest to the average reader — such as the chapters on PDO and XML — but most of the material would be of interest and benefit to any conscientious PHP programmer. The chapters on error handling and access control are alone worth the price of the book.
However, this second edition of the book has some weaknesses that may or may not have been introduced since the first edition (which was not readily available for comparison). But none of them are overwhelming or unfixable. Firstly, a reader hoping for a well-edited book will likely become distrustful by the authors' misuse of the term "that" in place of "who." Secondly, there are far too many ambiguous comments in the first-person, e.g., "I would dare to say that..." In a book written by five authors, the reader naturally has no idea who is speaking. Thirdly, there is a fair amount of inconsistency in the formatting of the code throughout the book, including indentation and other spacing, as well as variable naming. Also, every instance of a "{" on its own line (presumably to line up vertically with the corresponding "}"), is an antiquated waste of space, since any decent programmer's editor or integrated development environment (IDE) can do brace matching automatically.
Lastly, almost all of the section titles begin with the phrase "How do I." That is fine within the body of the book, at the beginning of every section. But when dozens of these section titles are listed together in the table of contents, that phrase could be excised so each section's topic would be faster to spot, and there would be fewer unnecessary words. In fact, the section titles don't necessarily have to be posed as questions. For instance, "Using Sessions" would be just as clear as "How do I use sessions?" and faster to read.
It should be noted that this book is best suited for intermediate to advanced PHP programmers, who will certainly get the most out of it. A programmer new to PHP, who would like to begin learning the language, should start with any one of the many tutorial-style PHP books available.
For readers who prefer the portability or environmental benefits of e-books, a PDF version of The PHP Anthology is available from the publisher, on the aforesaid Web page. Any programmer who is — or anticipates — doing PHP work away from their print technical library, should definitely consider obtaining the e-book, which thus can be added to their laptop's development environment, and be readily available for quick reference. The e-book contains all of the content of the print version. It also makes good use of color, for screenshots and other illustrations, as well as using a blue background for the sample code, which is a bit easier to read than the gray used in the print version.
Overall, this new edition of The PHP Anthology offers practical solutions to many common PHP problems, clear explanations of those solutions, and working code — in print and online — that can be quickly used as is or modified as needed. PHP developers should find this book an informative and valuable part of their technical library.
Michael J. Ross is a Web developer, writer, and freelance editor.
You can purchase The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
Deliver First Class Web Sites
Michael J. Ross writes "Experienced and conscientious Web developers, in their efforts to learn from the mistakes of others and to avoid repeating them on their own projects, tend to accumulate tips and recommendations for the many aspects of successfully creating Web sites. These best practices take the form of bookmarked Web pages, saved articles, downloaded PDF files, scribbled notes on scraps of paper, and hastily created documents that will be better organized one of these days, when the developer's schedule becomes less hectic (sure...). Being difficult if not impossible to find later, these pearls of wisdom are rarely consulted before or during each new Web site project. What the developer needs is a book that brings together as many of these best practices as possible, without being overwhelming. Deliver First Class Web Sites: 101 Essential Checklists may be the answer." Read the rest of Michael's review. Deliver First Class Web Sites author Shirley Kaiser pages 331 publisher SitePoint rating 8 reviewer Michael J. Ross ISBN 0975841904 summary A collection of Web site development best practices.
Authored by Shirley Kaiser, this book was published by SitePoint in July 2006, under the ISBN 0975841904. The publisher maintains a Web page devoted to the book, where visitors will find the book's table of contents online, a free preview (chapters 6, 12, and 14, in PDF format), editorial and customer reviews, a link to download all of the checklists (also in PDF) for all customers, links and an FAQ for ordering directly from SitePoint, and errata (none reported, as of this writing). The fact that SitePoint is willing to allow readers to post unmoderated comments and ratings of their books, suggests that it has real confidence in the quality of the book's material and readers' evaluations of it.
The aforesaid Web page also offers an online version of the index, but without any of the book's page numbers. At first glance, this might seem rather odd, but it does make some sense: Page numbers online would be of little use without the book itself, which of course already contains the index. Perhaps the index keys are offered to supplement the table of contents in helping the prospective customer learn what topics are covered in the book. In any case, this is the first time that I have seen a book's index online, and it will likely not be the last, if other publishers see the value in following suit.
In the preface, Shirley Kaiser explains that the book is intended to be "...a single source of solid information on best practices for everything from planning, designing, developing, and testing, to launching a web site and maintaining it in the long term. By compiling all this information into checklists, we've turned a vast wealth of detail into convenient, easy-to-scan, simple-to-use chunks organized by topic." A technical reader quickly scanning the book, would likely conclude that the author's goal has been achieved, because the book's 101 checklists comprise over 500 checkpoints, and almost all of them are expanded with at least a paragraph of more detailed explanation; many have accompanying code or images to illustrate the checkpoint.
The book's 331 pages of material are organized into 16 chapters, followed by an appendix that focuses on e-commerce advice. The topics covered in the chapters are: how to get started on a Web development project; planning the Web site with a client; assembling the site's content; managing that content; site usability; color schemes and functionality; information architecture; designing the site's navigation; W3C standards and recommendations; site accessibility; optimization of site performance; search engine optimization; design principles; site testing, including accessibility and usability; launch preparation and execution; post-launch follow-up and maintenance.
In terms of the specificity and usefulness of the checkpoints, they are not all consistently stellar, which arguably would have been an impossible expectation anyway. They range from the obvious (e.g., "Use consistent markup") to the not-so-obvious but equally valid (e.g., "Perform content audits"). Some of the checkpoints may on the surface appear mundane, but they could be a lifesaver further down the road, should a project turn sour (e.g., "Archive a copy of the handover package"). Some of them may seem painfully obvious to any decent developer (e.g., "Check all hyperlinks" and "Test all scripting functions"), but even the majority of those are violated on a daily basis, even by major Web sites, which have no excuse for such sloppiness.
The primary value of this book is how it neatly consolidates a considerable amount of worthy advice culled from the author's research and decade in the trenches of the Internet. The book probably will not replace all of the best practices that any top-notch developer will have assembled over the years — especially as none of it addresses advanced topics — but it could easily serve as a solid foundation upon which to add any supplemental recommendations that the book does not cover. Moreover, the book's material is presented in a fairly concise and quite readable format, making use of what appears to be a font slightly larger than is found in the typical computer programming book.
My only complaint with this title is the way that SitePoint continues to include a growing number of advertising pages, at the end of the book, with the bulk of each page black (sometimes even a bit smeared), and containing absolutely no details about the books being advertised. When SitePoint first began publishing books, if memory serves, they would only include one or two such over-the-top pages — possibly because they had so few titles to advertise at the inception. But now they are truly overdoing it. In Deliver First Class Web Sites: 101 Essential Checklists, no fewer than a dozen pages are wasted on this unwanted advertising. It would have been far more effective and efficient to simply list the 11 books' titles with a brief summary of each. Whoever decided to waste all that paper and ink, clearly did not read and understand some of the most basic checkpoints presented earlier in the book concerning type size and page content.
But overall, Deliver First Class Web Sites: 101 Essential Checklists is a much-needed book that brings together a wide range of valuable Web development best practices.
Michael J. Ross is a computer consultant, freelance writer, and the editor of PristinePlanet.com's free newsletter."
You can purchase Deliver First Class Web Sites from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
Web Services and Open Source at OSCON
I spend a lot of time with my head buried in code, and every time I pick my head up it feels like the future is closer than I thought. So I like coming to OSCON. A week of looking ahead leaves me more confident I won't get future shock anytime soon. OSCON, like all conferences, is aimed at corporations, the intangible entities that send humans as their proxies. But open source has its roots in individuals working outside the corporation for their community of programmers. Are the two cultures coming together, or colliding? And how will the "open source ideal" evolve, as the chief social act of programming changes from trading disks of source code to processing each others' data and mashing up web APIs?
I'm an open-source programmer who's lucky enough to be paid by a corporation. Between sessions this week I'm working on turning Slash's metamoderation into a plugin, making Slash more useful for other site admins. I'm a human first and employee second. And I'm concerned about how the community based around this software ideal of not welding shut the car's hood is going to hold together.
Markets aren't designed for goods with zero cost of reproduction, but because property is such a powerful tool for efficiency and prosperity, societies have been artificially constructing markets for creative works since even before the founders wrote up their support for "science and the useful arts." Often, markets in ideas work pretty well.
There have been three societal "bow shocks" in the collision between programming and capitalism. The first hit in 1976 when Bill Gates insisted that charging for software made sense. The second was in the late 90s when open source proved better than corporate hierarchy at certain types of development. And then there's the one that's about to hit now, when web services and interoperability concerns obviate open source licenses.
There's a growing understanding here that web services are big: that the laptops and desktops of the future will rely not on software goods that have been bought for those machines, but software services that run on a server a thousand miles away. Google calls its Ajax web services "the world's largest platform."
Yesterday, Tim O'Reilly hosted a stimulating all-day series of panels and talks on web services and "Web 2.0" generally. The most interesting part of the discussion was about tying web services together. Web mashups are hot. It's hard to look at a list of websites offering an API -- Google Maps, Yahoo Geocoding, eBay, craigslist, Flickr, YouTube -- and not start thinking about great ways to combine them. Interoperability plus programming creativity equals... well, something pretty neat, we're hoping.
But a web services API doesn't necessarily offer the freedom that might seem analogous to open source, which is why Tim is also putting out the call for an "open services" definition. Flickr offers its corporate API to some sites, and refuses to permit it to others. Zooomr was judged to be too much of a potential competitor, so Zooomr users don't get to copy the photos they've uploaded to Flickr. [Update: Sorta. Read that comment thread to see important context for Flickr's decision. To be clear, given that context, Tim thinks Flickr found a good answer, and I tend to agree.]
As Flickr says, and they have a very good point, "why should we burn bandwidth and CPU cycles sending stuff directly to [a potential competitor's] server?" That makes sense from a corporate point of view, but a user who's uploaded a thousand of their photos might be puzzled why it's no longer exactly "their" data. Is that a right that user should have, or not? I ran into Julian Cash, who vehemently argues that it is; he's started MoveMyData.org to try to build a client-side way for users to route around APIs, to suck down "their" data and maybe reupload it to other sites. No code yet, but he's looking for volunteers.
AttentionTrust goes even further, starting off its manifesto with "you own your attention and can store it wherever you wish." That's something I hadn't considered before but it has an interesting ring to it. They have a Firefox extension I haven't tried yet (does it work? post comments).
Interoperability is a concern even without the web. Yesterday morning, Danese Cooper got a half-hour to grill Bill Hilf, Microsoft's General Manager of Platform Strategy, on Microsoft's relationship with open-source. Some think that's the same relationship as the butcher to the hog, and Bill's job is to persuade them Microsoft has no such intentions.
Asked directly, in the context of embrace-extend-extinguish and web APIs that can be crushed at any time, "why should we trust Microsoft?", Bill's answer was to look at the company's actions: "consistent action, over time, in the right direction."
I sat down with him afterwords to probe into this a little more (with someone from Waggener Edstrom standing nearby). He has some examples of Microsoft working with open-source projects like JBoss and SugarCRM, but I asked for specifics of how we know Microsoft isn't going to try to kill more-directly competing projects like Mono or OpenOffice by eliminating interoperability, possibly with patents, at any random time in the future. The only real sign I got was the Covenant Not to Sue (over patents) that came with the OpenXML format earlier this year. That's a step in the right direction. I don't think it's a terribly big one.
I asked if we'd see more steps from Microsoft disavowing patents as weapons against open-source projects. Obviously that's a big risk for a company to take, but one that's probably necessary to convince skeptics Microsoft is friendlier than the butcher. While Bill couldn't make any promises, he affirmed the CNS was "not a one-off... and not just to placate people." I'll keep an eye out for more action in the right direction.
Exciting as the opportunities are for different projects' software working together, one thing's for sure: the remote sites that run their algorithms and store your data leapfrog open source licensing. The server a thousand miles away can run software with its hood welded shut, with no obligations to the open-source community that come along with the benefits. Today, while some companies are trying to build goodwill with that community, there is nothing like a GPL for web services. No one's discovered a legal foundation that would establish open services, openly shared web services, with the same kinds of rights that we insist on in open-source code. No one's even sure what "open services" might mean, indeed, there's no consensus that we even need such a thing.
Even the FSF is unable to decide how v3 of the GPL should read. And I'm not smart enough to know if the GPL is even the right tool for this. Maybe tacking clever licensing terms on top of copyright's restriction is a temporary hack whose time has passed (you know, like the RIAA). Maybe the next hack to build a community of software sharing and tinkering will have to be totally different.
I don't think I know the answers but maybe one of you does. If you have thoughts about the open-source community in the age of capitalism, please post them to this story. If you're at OSCON and want to chat about it, email me (or AIM 'jamiekzoo' if you catch me online). At the end of the week, I'll have more updates on what's happening here -- it's not all philosophy and futurism.
-
No Nonsense XML Web Development with PHP
Alex Moskalyuk writes "PHP and XML seems like a marriage made in heaven. Powerful manipulation functions and support on the core language level in PHP5 combined with universal extensibility of XML make it a technology of choice for quite a few Web enthusiasts and companies out there. However, anyone inspired by PHP's ease of use can probably find a good cure from insomnia when facing with XML specs. With all the DTD's, XML Schemas, XSLT and XPath queries one can easily get the impression that the world is changing on them, and perhaps sticking to hard-coded HTML with PHP statements combined with SQL statements for data retrieval would be within the zone of comfort." Read the rest of Alex's review. No Nonsense XML Web Development with PHP author Thomas Myer pages 354 publisher SitePoint rating 9/10 reviewer Alex Moskalyuk ISBN 097524020X summary XML, XSLT, XPath and DOM primer for PHP developers
Thomas Myer's No Nonsense XML Web Development with PHP is an XML primer for those who have been exposed to PHP, but are yet waiting to appreciate the elegance of PHP+XML solutions. Throughout 10 chapters and 2 appendices Myer is introducing the reader to different aspects of XML, their best-practice implementations in LAMP (where last P stands for PHP) environment, and their relevance to the real world. For the real-world example Myer decides to guide the reader through writing a custom content management system - complete with publishing/admin interface, templating/presentation layer, search engine, RSS feeds and other commonly expected features.
The book is not an introduction to PHP, but it does assume that the Web developer knows what XML is, but has never dealt with it. So the first chapter just talks about properly parsing XML with IE and Firefox, validating an XML document, differences between a well-formed and a valid XML document. Overall, it provides a very good introduction to XML for someone who has never dealt with it, and could probably be skipped by developers with XML exposure.
Chapter 2, XML in Practice, goes into nitty-gritty details of XML, and 26 pages later the reader knows how to create an XML file to display in the browser, declare proper namespaces, attach a CSS file to existing XML file and display the proper XML+CSS file (look, Ma, no <html>!) in the browser. The author earns instant geek credibility by displaying Firefox screenshots, with the exception of IE screenshot whenever IE is discussed. At the end of the chapter the author takes us through the basic XSLT.
DTD's, XSLT and writing a practical PHP app take up the next three chapters, followed by XML manipulation chapters. JavaScript enthusiasts will probably find Chapter 6 pretty useful, as it discusses manipulating XML on the client side, working with XSLT, and creating dynamic site navigation based on the XML source. Chapter 7 is what one would expect from the book that has the words PHP and XML in the title - discussion of SAX, DOM and SimpleXML parsers, examples of their implementation, discussion of proper use cases for each one of the technologies. The SimpleXML subchapter also contains a good primer on XPath - a query language that allows the developer to provide the parser with a query to navigate down the XML document.
Chapter 8 takes the reader through RDF and RSS, discusses the ways the syndication feeds are used on the Web nowadays. Since throughout all these chapters we're building a content management system, this is the right time to add the RSS headlines functionality to the site. The next chapter discusses another practical implementation of XML on the Web - XML-RPC calls between the sites and proper ways of exchanging data via XML Web services. The chapter discusses SOAP, although not a whole lot, and just mentions REST as another way to implement Web Services. As a practical exercise, the author takes readers on a tour of building an XML-RPC client, server and connecting those two together.
The last chapter talks about using XML with databases. Native XML databases are discussed, but let's face it - most of the PHP development is done with relational databases anyway. Myer talks about exporting MySQL database contents into XML with phpMyAdmin and mysqldump. The first appendix includes function reference for SAX, DOM and SimpleXML parsing in PHP, while the second one completes the CMS project by providing the rest of the necessary files.
I found the author's style very easy to follow and approachable. The code samples are succinct and to the point, there are also no generic discussions, such as "Why PHP?" The project chosen for the practical implementation is a bit boring, but at the same time quite real-world. The screenshots are clear, and code examples are nicely highlighted. The errata is provided on the book Web site. Code archive is available as a single file download as well. The book site also provides 100% money back guarantee (less shipping and handling fees) to anyone who bought the title, and didn't feel like they were getting their money's worth.
However, there are a few drawbacks that I noticed as well. With topics like XSLT and XPath broken into several chapters and discussed in smaller chunks, it's hard to use the book as a reference later on. Appendix A with PHP function reference for XML parsing hardly seems like a worthy addition, since PHP manual page on the subject contains equivalent information with more real-life examples contributed by users.
With all that, the book is quite informative, educational and useful. The author manages to tackle quite a few difficult topics in 260 pages provided to him (the count excludes preface and appendices). However, kudos to the author for writing chapters on XML without sounding boring, redundant or too academic. I would highly recommend this book to anyone interested in developing PHP-driven Web sites that provide or consume Web services, work with XML data or generate XML for others to use."
You can purchase No Nonsense XML Web Development with PHP from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
No Nonsense XML Web Development with PHP
Alex Moskalyuk writes "PHP and XML seems like a marriage made in heaven. Powerful manipulation functions and support on the core language level in PHP5 combined with universal extensibility of XML make it a technology of choice for quite a few Web enthusiasts and companies out there. However, anyone inspired by PHP's ease of use can probably find a good cure from insomnia when facing with XML specs. With all the DTD's, XML Schemas, XSLT and XPath queries one can easily get the impression that the world is changing on them, and perhaps sticking to hard-coded HTML with PHP statements combined with SQL statements for data retrieval would be within the zone of comfort." Read the rest of Alex's review. No Nonsense XML Web Development with PHP author Thomas Myer pages 354 publisher SitePoint rating 9/10 reviewer Alex Moskalyuk ISBN 097524020X summary XML, XSLT, XPath and DOM primer for PHP developers
Thomas Myer's No Nonsense XML Web Development with PHP is an XML primer for those who have been exposed to PHP, but are yet waiting to appreciate the elegance of PHP+XML solutions. Throughout 10 chapters and 2 appendices Myer is introducing the reader to different aspects of XML, their best-practice implementations in LAMP (where last P stands for PHP) environment, and their relevance to the real world. For the real-world example Myer decides to guide the reader through writing a custom content management system - complete with publishing/admin interface, templating/presentation layer, search engine, RSS feeds and other commonly expected features.
The book is not an introduction to PHP, but it does assume that the Web developer knows what XML is, but has never dealt with it. So the first chapter just talks about properly parsing XML with IE and Firefox, validating an XML document, differences between a well-formed and a valid XML document. Overall, it provides a very good introduction to XML for someone who has never dealt with it, and could probably be skipped by developers with XML exposure.
Chapter 2, XML in Practice, goes into nitty-gritty details of XML, and 26 pages later the reader knows how to create an XML file to display in the browser, declare proper namespaces, attach a CSS file to existing XML file and display the proper XML+CSS file (look, Ma, no <html>!) in the browser. The author earns instant geek credibility by displaying Firefox screenshots, with the exception of IE screenshot whenever IE is discussed. At the end of the chapter the author takes us through the basic XSLT.
DTD's, XSLT and writing a practical PHP app take up the next three chapters, followed by XML manipulation chapters. JavaScript enthusiasts will probably find Chapter 6 pretty useful, as it discusses manipulating XML on the client side, working with XSLT, and creating dynamic site navigation based on the XML source. Chapter 7 is what one would expect from the book that has the words PHP and XML in the title - discussion of SAX, DOM and SimpleXML parsers, examples of their implementation, discussion of proper use cases for each one of the technologies. The SimpleXML subchapter also contains a good primer on XPath - a query language that allows the developer to provide the parser with a query to navigate down the XML document.
Chapter 8 takes the reader through RDF and RSS, discusses the ways the syndication feeds are used on the Web nowadays. Since throughout all these chapters we're building a content management system, this is the right time to add the RSS headlines functionality to the site. The next chapter discusses another practical implementation of XML on the Web - XML-RPC calls between the sites and proper ways of exchanging data via XML Web services. The chapter discusses SOAP, although not a whole lot, and just mentions REST as another way to implement Web Services. As a practical exercise, the author takes readers on a tour of building an XML-RPC client, server and connecting those two together.
The last chapter talks about using XML with databases. Native XML databases are discussed, but let's face it - most of the PHP development is done with relational databases anyway. Myer talks about exporting MySQL database contents into XML with phpMyAdmin and mysqldump. The first appendix includes function reference for SAX, DOM and SimpleXML parsing in PHP, while the second one completes the CMS project by providing the rest of the necessary files.
I found the author's style very easy to follow and approachable. The code samples are succinct and to the point, there are also no generic discussions, such as "Why PHP?" The project chosen for the practical implementation is a bit boring, but at the same time quite real-world. The screenshots are clear, and code examples are nicely highlighted. The errata is provided on the book Web site. Code archive is available as a single file download as well. The book site also provides 100% money back guarantee (less shipping and handling fees) to anyone who bought the title, and didn't feel like they were getting their money's worth.
However, there are a few drawbacks that I noticed as well. With topics like XSLT and XPath broken into several chapters and discussed in smaller chunks, it's hard to use the book as a reference later on. Appendix A with PHP function reference for XML parsing hardly seems like a worthy addition, since PHP manual page on the subject contains equivalent information with more real-life examples contributed by users.
With all that, the book is quite informative, educational and useful. The author manages to tackle quite a few difficult topics in 260 pages provided to him (the count excludes preface and appendices). However, kudos to the author for writing chapters on XML without sounding boring, redundant or too academic. I would highly recommend this book to anyone interested in developing PHP-driven Web sites that provide or consume Web services, work with XML data or generate XML for others to use."
You can purchase No Nonsense XML Web Development with PHP from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
What Makes a Good Web Font
SitePoint writes "We've published an article on the way in which fonts are used on the Web. We found that a large "x-height" (the height of a lowercase 'x' in relation to the total height of the font) makes fonts more readable on a computer screen, as does a wide "punch width" (the width of the hole inside letters such as 'o' and 'b'). Helvetica is a good font to use online. The designer's choice of fonts is usually limited by the user's OS, but techniques such as SIFr (example) are allowing Web designers to provide their own fonts." -
What Makes a Good Web Font
SitePoint writes "We've published an article on the way in which fonts are used on the Web. We found that a large "x-height" (the height of a lowercase 'x' in relation to the total height of the font) makes fonts more readable on a computer screen, as does a wide "punch width" (the width of the hole inside letters such as 'o' and 'b'). Helvetica is a good font to use online. The designer's choice of fonts is usually limited by the user's OS, but techniques such as SIFr (example) are allowing Web designers to provide their own fonts." -
Blog Software Smackdown
An anonymous reader writes "With published numbers saying there are approximately 70,000 new blogs being created each day, and the total number of blogs doubling every 5 months, it's no wonder that everyone and their dog is wondering whether to setup their own blog for a chance at fame, or perhaps a book publishing deal. The question then becomes: What software should you use? SitePoint has just published The Blog Software Smackdown which takes a look at Movable Type, WordPress, and Textpattern. Pick one, and take your stab at fame or notoriety." -
Open Source Design in risk?
Stylissimo writes "OSWD.org, the biggest source for free open source web templates, has been offline for several weeks, which has caused a dilemma for the large number of webmasters who rely on open source design. While some of the OSWD.org designers are doing their best to keep the open source design scene alive, others are worried that the absence of OSWD.org will hit the internet hard and maybe even kill the scene. Aaron Nikula, administrator of OSWD.org, has published a statement about the situation and the site may be back again." -
Open Source Design in risk?
Stylissimo writes "OSWD.org, the biggest source for free open source web templates, has been offline for several weeks, which has caused a dilemma for the large number of webmasters who rely on open source design. While some of the OSWD.org designers are doing their best to keep the open source design scene alive, others are worried that the absence of OSWD.org will hit the internet hard and maybe even kill the scene. Aaron Nikula, administrator of OSWD.org, has published a statement about the situation and the site may be back again." -
The CSS Anthology
Bruce Lawson writes "I've read a lot of CSS books, but this one is the one I wished that I'd read when I was learning, and I suspect that other slashdotters may concur. It is firmly pitched at the coder rather than the designer, takes you from CSS virgin to upper intermediate level, with good attention to the process of (re)designing with CSS, legal issues such as Accessibility (section 508), and assumes that you're not scared of mark-up." Lawson offers this disclosure: "I should immediately disclose that I've worked for two different companies that have published the author, Rachel Andrew, but I have no connection with the publishers, or this book." Read on for the rest of his review. The CSS Anthology: 101 Essential Tips, Tricks & Hacks author Rachel Andrew pages 380 publisher SitePoint rating 8 reviewer Bruce Lawson ISBN 0957921888 summary Structured Q&A guide for CSS beginners
Author's credentialsAndrew is a long-term member of the Web Standards Project (WaSP) and programmer, technical project manager, technical team leader/senior developer and webmaster, according to her own bio.
Who's the book for?The book's subtitle is somewhat misleading. There probably are 101 tips'n'tricks (I didn't count) but it's not the random miscellany that it implies. The information is structured so that a n00b could become proficient by reading the book from start to finish (I tested this out on a colleague). The tips'n'tricks structure does allow you to find what you're looking for in a hurry. The table of contents is easily scanned, and there is an excellent index.
The book doesn't offer advice on how to sex up the beauty of your site. That's fine for me; my current work involves replicating someone else's designs using xhtml and CSS, and as a coder I'm pathologically unable to design the type of showcases that you see at the CSS Zen Garden. A graphic designer might therefore find this book hard work; it jumps straight into a discussion of syntax, and there's occasional geek-directed statements (CSS supports multi-line C-style comments). Similarly, if you're completely new to html, this book probably isn't for you; there's lots of references to pre-CSS ways of working which could potentially be mystifying. Unusually for CSS books, there's a refreshing lack of polemic telling you why you should use style-sheets. If I read another history of the browser wars in a technical book, I shall scream.
So the book's constituency would seem to be those who know how to present information via html, and wish to take advantage of the smaller filesizes, greater flexibility and logical separation of the presentation layer from the mark-up that the (x)html/ CSS combination offers. The logical purity is my personal reason for moving to Web Standards; the trauma of writing text processing applications with VAX Fortran in the late '80s left me with the propensity to weep when I see html as sorely abused I mangled dear old Fortran.
Are you sitting comfortably? Then I'll begin.Anthology kicks off in the conventional way for CSS books - controlling fonts and colours, styling hyperlinks, headings and the like. Each chunk is structured as a problem (How do I remove the indented left margin from a list?), a solution and sample code, and generally a discussion of related applications of the code, compatibility issues, accessibility notes etc. This is a pretty compact method of explication, and the basics of styling, syntax, pseudo-class order and the like are romped through in 40 pages, but not glossed over. The key to this is that Anthology assumes you know what you want to do, and shows you how to do it.
Chapter 4 (Navigation) is where the real meat begins - making navigation menus that are solely html unordered lists (because a menu is logically a list of links) and styling with CSS, adding rollover effects, styling navigation as buttons, changing the styling to a horizontal navbar, or even Amazon-style tabs without changing the mark-up. I suspect that, although these are techniques that can be found in most CSS books, the brevity and simplicity of the explanation will be revelatory to many. Chapter 5 (Tabular Data) may come as a surprise to those who mistakenly believe that web standards disallows the use of html tables, as it shows how to style tabular data - the examples are a spreadsheet and a calendar. Chapter 6 repeats the trick with that most mundane aspect of web development, the form.
Chapter 7 (Browser and Device Support) is about real-world CSS development. Unlike most books which instruct you to test in loads of browsers and leave it at that, this chapter lists all the main permutations of OS and browser (including tips on installing multiple versions of IE/ Win), and begins discussion of the tried and tested hacks to hide styles from Netscape 4, IE etc. All of this information is available on the web -- but for a newbie who isn't yet aware that it's possible to hide styles from certain browsers, it's a great way to introduce them to the murky practices of real-world CSS development. What's also refreshing in a computer book for n00bs is a discussion of how to seek help on lists and forums, with a guide to etiquette.
Chapter 8 (CSS Positioning and Layout) is where the stuff that stumps many a table-based designer begins. Along with fonts and colours etc, CSS can lay out the stuff on your page. I'm unsure about the success of this chapter; the Q&A structure is great if you're looking to build one of the sites that are explained (and the list is pretty comprehensive), but I came to the chapter hoping to cure a couple of bugs I'd found in a project I'd previously semi-successfully laid out with absolute positioning (A.P.).
Generally, I layout using floats as I also write the html, so it's easy to ensure that the markup spits out <div>s (sections) in the left-to-right, top-to-bottom order that I want to lay them out in. Suddenly, I had two projects that required A.P. for the first time, as it was not cost-effective to change the way that the client's CMS spat out the markup, so AP was required to position sections on the page regardless of where they appeared in the markup.
Anthology served me fine until I tested the page in IE and the layout was off. Nothing in the book gave me any pointers, and in the end I gave up Googling and just used a hack which exploits an IE parser bug to serve different co-ordinates to IE, after finding the hack co-ordinates through trial and error:
#APthing {position:absolute; top:34px; left: 758px; width:108px; height:88px;}
* html #APthing {position:absolute; top:19px; left: 785px;} /*for IE */OK, so there may be a simple mistake I'm making -- but then, as far as absolute positioning goes, I'm the kind of newbie at whom this book is aimed, and I imagine that others will make the same mistake that I did. If the book had explained where I was going wrong, or given me the above hack, I'd've spent less time with Google and more time with Guinness.
Chapter 9 (Experimentation, Browser Specific CSS and Future Techniques) is successful, except for one small gripe. I'm glad that the author, although a member of the Web Standards Project, isn't an uber-purist. (I'm of the opinion that a little invalid code, if it's the only way to get the job done, isn't a hanging offense). So she shows how to implement IE-only proprietary CSS that can make colourful scrollbars, should you wish to do this. There's also a Mozilla-only CSS trick to allow curved edges to CSS boxes, which I implemented on my homepage that very evening.
However (here's the gripe), the most useful technique shown is one which allows fully-CSS flyout menus that don't rely on JavaScript. The author notes that it won't work for most people, as IE incorrectly restricts the hover pseudo-class to <a> tags only, while the CSS requires hovering over <li> elements.
Well, Yes and No. There's a well-documented and elegant hack which allows a proprietary Microsoft behaviour to be attached to the CSS that attaches a small JScript that corrects the IE bug, and thus allows this extremely useful CSS-only flyout menu to work in IE. I've used the technique myself when required to mimic the look and feel of a client's site while making it DDA/ADA accessible, and it works perfectly. To me, the omission of the IE hack from Anthology is an unfortunate oversight.
SummaryThere's a couple of flaws in the book, though I suspect that in order to explain them, I've over-emphasised them. All in all, it's a solid, professional no-B.S. way for someone with a code-oriented mind to get them up to speed, satisfactorily and quickly; a motivated reader could be churning out standards-compliant, bandwidth-friendly sites after a few hour's experimentation. Ordering the book from the publisher's website was a good experience and, unusually, they have a money-back guarantee. As I said, I wish that I'd had access to Anthology when I was learning.
You can purchase The CSS Anthology: 101 Essential Tips, Tricks & Hacks from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
The CSS Anthology
Bruce Lawson writes "I've read a lot of CSS books, but this one is the one I wished that I'd read when I was learning, and I suspect that other slashdotters may concur. It is firmly pitched at the coder rather than the designer, takes you from CSS virgin to upper intermediate level, with good attention to the process of (re)designing with CSS, legal issues such as Accessibility (section 508), and assumes that you're not scared of mark-up." Lawson offers this disclosure: "I should immediately disclose that I've worked for two different companies that have published the author, Rachel Andrew, but I have no connection with the publishers, or this book." Read on for the rest of his review. The CSS Anthology: 101 Essential Tips, Tricks & Hacks author Rachel Andrew pages 380 publisher SitePoint rating 8 reviewer Bruce Lawson ISBN 0957921888 summary Structured Q&A guide for CSS beginners
Author's credentialsAndrew is a long-term member of the Web Standards Project (WaSP) and programmer, technical project manager, technical team leader/senior developer and webmaster, according to her own bio.
Who's the book for?The book's subtitle is somewhat misleading. There probably are 101 tips'n'tricks (I didn't count) but it's not the random miscellany that it implies. The information is structured so that a n00b could become proficient by reading the book from start to finish (I tested this out on a colleague). The tips'n'tricks structure does allow you to find what you're looking for in a hurry. The table of contents is easily scanned, and there is an excellent index.
The book doesn't offer advice on how to sex up the beauty of your site. That's fine for me; my current work involves replicating someone else's designs using xhtml and CSS, and as a coder I'm pathologically unable to design the type of showcases that you see at the CSS Zen Garden. A graphic designer might therefore find this book hard work; it jumps straight into a discussion of syntax, and there's occasional geek-directed statements (CSS supports multi-line C-style comments). Similarly, if you're completely new to html, this book probably isn't for you; there's lots of references to pre-CSS ways of working which could potentially be mystifying. Unusually for CSS books, there's a refreshing lack of polemic telling you why you should use style-sheets. If I read another history of the browser wars in a technical book, I shall scream.
So the book's constituency would seem to be those who know how to present information via html, and wish to take advantage of the smaller filesizes, greater flexibility and logical separation of the presentation layer from the mark-up that the (x)html/ CSS combination offers. The logical purity is my personal reason for moving to Web Standards; the trauma of writing text processing applications with VAX Fortran in the late '80s left me with the propensity to weep when I see html as sorely abused I mangled dear old Fortran.
Are you sitting comfortably? Then I'll begin.Anthology kicks off in the conventional way for CSS books - controlling fonts and colours, styling hyperlinks, headings and the like. Each chunk is structured as a problem (How do I remove the indented left margin from a list?), a solution and sample code, and generally a discussion of related applications of the code, compatibility issues, accessibility notes etc. This is a pretty compact method of explication, and the basics of styling, syntax, pseudo-class order and the like are romped through in 40 pages, but not glossed over. The key to this is that Anthology assumes you know what you want to do, and shows you how to do it.
Chapter 4 (Navigation) is where the real meat begins - making navigation menus that are solely html unordered lists (because a menu is logically a list of links) and styling with CSS, adding rollover effects, styling navigation as buttons, changing the styling to a horizontal navbar, or even Amazon-style tabs without changing the mark-up. I suspect that, although these are techniques that can be found in most CSS books, the brevity and simplicity of the explanation will be revelatory to many. Chapter 5 (Tabular Data) may come as a surprise to those who mistakenly believe that web standards disallows the use of html tables, as it shows how to style tabular data - the examples are a spreadsheet and a calendar. Chapter 6 repeats the trick with that most mundane aspect of web development, the form.
Chapter 7 (Browser and Device Support) is about real-world CSS development. Unlike most books which instruct you to test in loads of browsers and leave it at that, this chapter lists all the main permutations of OS and browser (including tips on installing multiple versions of IE/ Win), and begins discussion of the tried and tested hacks to hide styles from Netscape 4, IE etc. All of this information is available on the web -- but for a newbie who isn't yet aware that it's possible to hide styles from certain browsers, it's a great way to introduce them to the murky practices of real-world CSS development. What's also refreshing in a computer book for n00bs is a discussion of how to seek help on lists and forums, with a guide to etiquette.
Chapter 8 (CSS Positioning and Layout) is where the stuff that stumps many a table-based designer begins. Along with fonts and colours etc, CSS can lay out the stuff on your page. I'm unsure about the success of this chapter; the Q&A structure is great if you're looking to build one of the sites that are explained (and the list is pretty comprehensive), but I came to the chapter hoping to cure a couple of bugs I'd found in a project I'd previously semi-successfully laid out with absolute positioning (A.P.).
Generally, I layout using floats as I also write the html, so it's easy to ensure that the markup spits out <div>s (sections) in the left-to-right, top-to-bottom order that I want to lay them out in. Suddenly, I had two projects that required A.P. for the first time, as it was not cost-effective to change the way that the client's CMS spat out the markup, so AP was required to position sections on the page regardless of where they appeared in the markup.
Anthology served me fine until I tested the page in IE and the layout was off. Nothing in the book gave me any pointers, and in the end I gave up Googling and just used a hack which exploits an IE parser bug to serve different co-ordinates to IE, after finding the hack co-ordinates through trial and error:
#APthing {position:absolute; top:34px; left: 758px; width:108px; height:88px;}
* html #APthing {position:absolute; top:19px; left: 785px;} /*for IE */OK, so there may be a simple mistake I'm making -- but then, as far as absolute positioning goes, I'm the kind of newbie at whom this book is aimed, and I imagine that others will make the same mistake that I did. If the book had explained where I was going wrong, or given me the above hack, I'd've spent less time with Google and more time with Guinness.
Chapter 9 (Experimentation, Browser Specific CSS and Future Techniques) is successful, except for one small gripe. I'm glad that the author, although a member of the Web Standards Project, isn't an uber-purist. (I'm of the opinion that a little invalid code, if it's the only way to get the job done, isn't a hanging offense). So she shows how to implement IE-only proprietary CSS that can make colourful scrollbars, should you wish to do this. There's also a Mozilla-only CSS trick to allow curved edges to CSS boxes, which I implemented on my homepage that very evening.
However (here's the gripe), the most useful technique shown is one which allows fully-CSS flyout menus that don't rely on JavaScript. The author notes that it won't work for most people, as IE incorrectly restricts the hover pseudo-class to <a> tags only, while the CSS requires hovering over <li> elements.
Well, Yes and No. There's a well-documented and elegant hack which allows a proprietary Microsoft behaviour to be attached to the CSS that attaches a small JScript that corrects the IE bug, and thus allows this extremely useful CSS-only flyout menu to work in IE. I've used the technique myself when required to mimic the look and feel of a client's site while making it DDA/ADA accessible, and it works perfectly. To me, the omission of the IE hack from Anthology is an unfortunate oversight.
SummaryThere's a couple of flaws in the book, though I suspect that in order to explain them, I've over-emphasised them. All in all, it's a solid, professional no-B.S. way for someone with a code-oriented mind to get them up to speed, satisfactorily and quickly; a motivated reader could be churning out standards-compliant, bandwidth-friendly sites after a few hour's experimentation. Ordering the book from the publisher's website was a good experience and, unusually, they have a money-back guarantee. As I said, I wish that I'd had access to Anthology when I was learning.
You can purchase The CSS Anthology: 101 Essential Tips, Tricks & Hacks from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. -
The PHP Anthology - Volume II, 'Applications'
sympleko (Matthew Leingang) writes "In Volume I of The PHP Anthology, Harry Fuecks showed some of the basic PHP functionality to solve a few simple problems, including how to object-orient your code, how to use PHP's hundreds of built-in functions, and how to use well-developed existing classes, be they from PEAR or other sites. In Volume II, he intends to 'blow your socks off by tackling some traditionally complex problems with the same principles--to great effect.' It's summertime and I'm sandals-only for the time being, so my socks remain safely in the top drawer. But the volume is nonetheless exciting." (Read on for the rest of Leingang's review, and check out last week's review of Volume I.)There are seven chapters in this volume, each dealing with real-world problems. Many problems are those you've seen solved on sites you admire and wondered "How did they do that?" Others are frameworks that allow your site to run smoothly, with nobody getting accidentally logged out or having to wait too long while your script gluttonously pulls the same data out of the database for the Nth time. At the end, Fuecks goes back to the beginning, to show how proper design and development can save you time when you start your next project.
Chapter 1: Access Control
Authentication is the process by which users identify themselves. This is difficult in HTTP, a stateless protocol in which the server handles one request at a time and instantly forgets you. Luckily HTTP allows cookies, which are bits of data the server sends to the client for to reveal upon revisiting. At first cookies were used only to annoy ("Hello, Steve! You have visited this page 3 times"), but a cookie can hold the ID of a session record in a database, which contains any state-information that you like.You can authenticate without sessions via HTTP server configuration, as long as you like the dull dialog box the browser pops up when users enter a restricted area. Oh, and you don't mind the fact that users won't be able to "log out" without quitting their browser, nor can you force a logout after a certain timeout value. Nor can you allow users to register themselves... these are all existing, solved problems and the author shows some of the best solutions. Common tasks like allowing users to change their passwords, recover their passwords if (I mean when) they forget them, and arranging users in groups to which you assign common permissions are also covered.
My favorite example from this chapter is the humans-only registration application. Remember when online voting for the Major League Baseball All-Star Game first started? Anyone who knew how to write a web client could have automated a task to vote as many times as the server could handle, and have his favorite players be the all-star team.* To bring it closer to home, what if somebody decides to bog down your site by automatically registering a huge number of times and filling up your database? You can keep these things from happening by making users look at images which contain text but are hard for computers to "read." PHP is in use at all stages of this game, from writing the registration form's HTML to generating the obscured image on-the-fly.
Chapter 2: XML
XML is a fact of life and, hype aside, is a great way to store and transmit machine-readable data. One of the most visible applications is the thousands of bloggers and news sites providing XML feeds of their headlines. You can write portal sites that grab these headlines, parse them all and present them on your site with links to the full text at the source.There are two ways to parse XML: with events, or by using the Document Object Model (DOM). The methodologies are similar to reading a plain-text file line-by-line or all at once. Using events you can implement a finite-state machine based on which tags and text come down the pike. Or you can slurp the whole document into memory and find any part of it with ease. The built-in library for the former is based on the popular Simple API for XML (or SAX; don't you like those nested acronyms?), while the latter often uses Xpath to find the particular document nodes you want.
The author shows how to parse RSS feeds with both SAX and the DOM, and how to render a feed with DOM. Further, you can use Extensible Stylesheet Language Transformations (known as XSLT) to transform XML -- whether it's to XHTML for regular browser reading, WML (Wireless Markup Language) for viewing on mobile phones, or even SQL to communicate with a database.
Another exciting XML application is in the area of web services, in which agents (often but not necessarily web servers) communicate with each other over an XML-based protocol built on top of PHP. The two most popular protocols are XML-RPC (the RPC stands for "Remote Procedure Calls") and SOAP (which used to stand for "Simple Object Access Protocol" but now is just a name). Often-changing information such as stock prices and weather are often offered through web services, but they can also be used as an object API between agents over the network. What's cool about using SOAP is you can publish to clients exactly what services you offer and how they can call them using the Web Services Description Language (WSDL).
Chapter 3: Alternative Content Types
If you've ever printed out a web page that was designed for browser viewing, you know the less-than-desired effect. The navigational elements, search boxes, and banners, while necessary for the web page, are useless once a static copy is printed. Furthermore, you need to extend your site to include users with less-featured browsers, such as mobile phones.Fortunately, PHP has been taught many languages. PDF is the standard for print-quality documents, and there are several libraries (free and non-free) which allow you to generate them. WML is the HTML of cell phone browsers, in which screen space is at a premium and bandwidth scarce. SVG is an XML application which allows vector-based images like PostScript does. The coolest example, however, uses XUL (the XML User interface Language, not to be confused with Zool) to make full GUI applications that you run through Mozilla. This isn't useful for the outside world where you can't force your users to use Mozilla (sigh), but works well for intranet applications that run on a variety of platforms.
The author also brings up in this chapter an HTML SAX parser he has written. You can process HTML pages chunk-by-chunk and extract the pieces you want. I hadn't known about such a class until I read the book and I'm very excited I know about it now. For sometimes it's necessary to parse a web page meant for humans to read (perhaps to pretend to be a user and automate your all-star voting), and most HTML pages won't validate as HTML, let alone XML.
A good point here is that a well-designed, tiered application will allow you to swap out different presentation classes with little code rewrite. Separating the tasks of extracting the data from the database and presenting to the user in variety of formats is a common task that when done right becomes subsequently easier.
Chapter 4: Stats and Tracking
Once your site is up and running, you'll be interested to know which parts are the most active, and how much traffic you're getting. Into a dynamic page you can obviously insert any logging mechanism, but a great place to put it is inside your site's logo. PHP can send binary data as easily as text. Why would you want to do this?- The logo is usually on every page (or it should be). You don't have to cut-and-paste code.
- You can serve the image, then use the flush command to send the output on and do extra processing. This way logging doesn't get in the way of page rendering.
There are lots of packages available to collect and analyze data. The author goes through phpOpenTracker which is quite rich in features. There are also ways to collect data on what links users follow to leave your site, and to keep requests from search engines from cluttering your log files.
Chapter 5: Caching
Another possible knock against PHP is that, while it's good to have dynamic pages, some pages are unnecessarily so. This is a waste of server resources to keep rendering the same page anew. There are different ways to conserve.On the client side, you can use HTTP 1.1 headers like Cache-control and Expires to tell browsers when it's okay to store cached copies locally
On the server side, as can be expected, you have a greater level of control. You can use output buffering to delay sending of output to the browser, then save a copy of the output locally. On subsequent requests, you can serve the file rather than generate the HTML all over again. This can be implemented on a chunk (or block) level, so that you can keep some parts ultra-time sensitive and others not so much. The package PEAR::Cache_Lite can help with this.
Chapter 6: Development Technique
The last two chapters were my favorites of the two-volume set. They are on a higher level of abstraction than the features of PHP's library of functions, or previous five chapters on real-world solutions. After you've reached a certain level of expertise in PHP coding, you being to wonder about the "right" way to do things. The author shows how to use Xdebug to find bottlenecks in your code, as well as a few quick optimization tips (for instance, design your flow control so that the first choice is the one most often taken).He then discusses the principles of N-tiered design. N is usually 5, but the data layer (usually a database or file system) and presentation layer (usually the browser) are most often handled outside of PHP, so you normally have three levels to worry about:
- Data Access: Getting data from the outside world into your application
- Application Logic: Doing whatever unique thing your application is supposed to do
- Presentation Logic: Forming a response in a format acceptable to your client
Keeping these layers separate and restricting them to communicating through well-defined interfaces allows you maximum flexibility. If you need to change databases (say you just got venture capital money and can afford Oracle now), you can do so only changing one layer. If you want to serve different flavors of HTML, or different markup languages altogether, or binary data, you can do so by only changing one layer. You can even strive for maximum distributability by enabling your layers to "live" on physically independent machines and communicate with XML-RPC or SOAP.
Documenting your code is essential. Anybody who's been programming for over a year has gone back to code he or she's written and thought, "Now what the heck was this supposed to do?" It's even more essential when you write something and wish to distribute it for the benefit of others. You can expect them to grok your code at an even lower rate since they didn't write it the first time.
Luckily, scripted languages like PHP are excellent at parsing text files, including PHP scripts themselves. Using well-defined documentation formats akin to JavaDoc, you can embed documentation in your code inside comments, and use tools like phpDocumentor to extract these documentation blocks and format them as nice, cross-reference HTML. In fact, writing doc blocks before your code is a good way to think ahead about how you want your classes and methods to work.
Unit Testing, one of the most digestible dogmas of Extreme Programming, is an awesome way to test your code for logic errors. You build up tiny test cases (using mock objects to isolate the class you're testing) and build as many as you like. Once you do this (PHPUnit and SimpleTest are two rich frameworks), you keep your tests and each time you add features, you run your test to make sure you haven't added bugs as well.
Chapter 7: Design Patterns
Design Patterns is one of the modern classics in information technology. After having done OOP for a while, you will inevitably get the feeling of deja vu that you've solved a problem before. Not so concretely as "I need a database abstraction layer," or "I need a templating system," but as in "I need a way to create objects without specifying exactly what class they belong to," or "I'm tired of writing so many if statements." Design patterns are common object architectures which can be used to solve common (though unique) problems.Many design patterns are more suited to state-equipped applications with GUIs, but there are plenty to assist the PHP coder. The Factory Method is a pattern through which an object can create other objects of varying classes. So instead of writing mysql_connect everywhere, then having to change every occurrence of that function, you can abstract all database interaction to a class, then instantiate a database connection through a class method of another class: $db = MyApp::getDatabaseConnection(). This is useful when the connection (not just the RDBMS, but the actual database) you want varies depending on whether you are developing, testing, or going live with your application. Factory methods are also a good way to avoid global configuration variables.
The Iterator Pattern and the Observer Pattern are two others mentioned in this chapter. Iterators are used often in paging through database results. Observers are used to let objects notify other objects of changes in their state. This chapter will make you want to go read the whole Gang-of-Four book if you haven't already.
My biggest beef with the book is that this wasn't presented earlier on, perhaps at the beginning of Volume II. As a climax, it leaves me flat, wondering how the rest of the volume could have been derived from this very cool concept. But most PHP books conclude with chapters on how to extended PHP on the C level, or giant case studies involving massive code dumps, and I'm often not satisfied with them. This is a nice philosophical note to go out on. And there's something to be said for the argument that books like these aren't written to be read cover-to-cover.
Appendices
The book closes with the same indices as in Volume I. Since I don't know the URL of my review of that volume, I'll just copy: You can read about which configuration directives you're probably most interested in (the complete list you can get on PHP's web site), some common security breaches, and how to install PEAR, PHP's version of CPAN. My favorite appendix is the "Hosting Provider Checklist," a great reference for evaluating whether kewlhosting.com is going to give you the freedom and support you need to make a great hosted web site.This volume was informative, well-written, and inspirational in that it made me want to go out and add cool and useful features to my web sites. Check it out if you can.
*Not really (not that I tried or anything), but they've always been a little bit smarter about it. You get my point, though. This did happen on an ESPN.com Page 2 mascot popularity contest, but they noticed through request headers that millions of votes were coming from the same place, and invalidated all those votes.
In real life, Matthew Leingang is Preceptor in Mathematics at Harvard University. He promises to review any book sent to him for free, and sometimes actually does it. Both volumes of The PHP Anthology are available from SitePoint. Slashdot welcomes readers' book reviews; to see your own review here, carefully read the book review guidelines, then visit the submission page.
-
The PHP Anthology - Volume I, 'Foundations'
sympleko (Matt Leingang) writes "What a beautiful world anthology is. It comes from the Greek for a gathering of flowers, and in literature means a collection of works. Harry Fuecks, a very frequent contributor to the SitePoint community PHP forums, has gathered a bouquet of PHP best practices in a new book. The book comes in two volumes. The audience for Volume I, "Foundations," is the advanced beginner who's done one or two things in PHP, but you wants to know how to do more. Volume II, "Applications," is a design volume, mainly, and is good for people who have lots of experience with PHP but want to be better programmers. It's nice that the two volumes are separate; if you already know the syntax and mechanics of PHP you can buy Volume II and maximize d!/d$.*" Read on for Leingang's review of Volume I, and watch for his followup on Volume II. The PHP Anthology: Volume I: Foundations author Harry Fuecks pages 376 publisher SitePoint rating 7 reviewer Matthew Leingang ISBN 0957921853 summary Good start; for the real story read Volume II as well.The book is very well-written, often using a question-and-answer heading style that makes searching the table of contents easy. In the preface, we already meet the first cool aspect of the book: lots of links to sites in the form of footnotes.** Yes, most books of this genre include links to web sites, but this way makes a couple of things clear: first, that there are lot of references, so you have many places to jump to for more information, and it's a sleeker text flow: embedding URLs in dead text makes line breaking hard and detracts from the flow of the language. As you read a page, you can note, "OK, that's an online resource," and keep reading without having to stumble over an incomprehensible URL.
Each volume has numerous code examples, and they're all on the book's web page to save you from transcribing. The web site is the best place also to buy the books; they're generally not available in stores.
Chapter 1: PHP Basics
These are the foundations of the book. Quick highlights:How does one exactly RTFM? The author directs the novice to the PHP web site and explains what each part of the online manual corresponds to. But also, the coolest aspect of the PHP web site is its search-by-url feature. It looks up a function or language reference page, finds a set of likely matches, or just googles the site for you. Try it: http://php.net/array, http://php.net/sprintf, http://php.net/error.
How to understand error messages. Remember your first "cannot add header information -- headers already sent" error. Huh? Learn the difference between parse errors (what you wrote is not valid code), semantic errors (you're asking PHP to do something illegal), environment errors (PHP is not equipped to do what you want), and logic errors (PHP is happy but you're not). The last is particularly insidious (no E_PEBKAC level of reporting), but unit testing (see Volume II) gives you hope to find and fix those.
How to include. What is the difference between include and require (answer: require forces a fatal error if it can't find the file you want, while include only warns)?
How to write portable and reusable code There are hundreds of configuration directives, and using them can make one of your applications simpler. But some are to be used only with careful consideration. The magic_quotes_gpc directive, for instance, sounded like a good idea at the time it was developed. It automatically escapes user input so backslashes remain backslashes and not escape characters. A common use of this directive allowed you to insert user-supplied data directly into a database without checking to make sure any embedded quotes wouldn't create unintended SQL statements. While this does guard against SQL injection attacks, you could still end up with garbage in the database. So you still have to check user data to make sure it complies to your standards. This is easier to do before escaping magic characters, so it's better to wait until just before storage; then add all the backslashes you need. Nowadays it's considered good form to not rely on this directive and just use addslashes when you need it.
For maximal code reuse, consider object orientation. But there's a whole chapter on that...
Chapter 2: Object Oriented PHP
"Be lazy," the author writes; "Write good code." One of the ways to organize your code is through object-oriented programming. Most readers know the basic concepts of OOP, and are probably tired of the few over-simplified examples. Beyond that this chapter wants to get you to think OO, to "no longer think about long lists of tasks that a single script should accomplish; instead, [to] see programming as the putting together of a set of tools to which your script will delegate work."I know my first PHP classes were just namespaced scripts. The attributes and methods weren't at all related. This chapter (as well as Chapter 7 of Volume II) helps you distinguish where your classes are and how they connect. One of the aids for this is the use of Unified Modeling Language (UML) class diagrams. These diagrams, which use boxes for classes and arrows for the relationships between them, are really cool programming and teaching tools that require no code!
Here I think the book's physical workflow got caught in a gap between major PHP releases. The cover says this book says "PHP5 ready," which is a bit of a misnomer because all the code examples and rules are all written for PHP4. Minor text mentioning how things are going to be different in PHP5 has been inserted. It's true that none of the OO code written here will break in PHP5, but there are major additions to PHP5 especially in the OO implementation (no more ampersands! actual private variables! Exceptions! Much, much more!). Still, the author makes the point that you the programmer may not be using PHP5 for a while (PHP 5.0.0 is only a few weeks old today), and that you shouldn't put off learning PHP until version 5 is agreed to be stable.
I've read the comments of PHP bashers, arguing that using it for OO programming is a waste of overhead. The author has heard that argument, too, and rebuts:
"What they forget to mention is the drastic increase in your performance that object oriented programming delivers. After all, fast programmers cost more than fast microprocessors!"
Hear, hear. RAM and disk space are commodities, while programmers are not (yet).
Chapter 3: PHP and MySQL
This goes beyond the simple HOWTO on connecting to a database. A suite of PHP classes is developed for database connections, querying, and result handling, not as much to use as for your "health"--i.e., to see a well-done class from start to finish. For your real applications, use a real, well-maintained and tested class such as those found in PEAR. This is another principle of good programming: Somebody has probably had the same problem you are having right now, and already solved it (also known as Ecclesiastes 1:9, "...there is nothing new under the sun.")If you've done lots of SQL queries, you get to thinking that there's got to be a better way to access a database. In fact, you can build a layer of abstraction over the database connection layer to create interface classes to individual tables. This is called a persistence layer. For an implementation, see PEAR::DB_DataObject.
Any web programmer fears insecurity, and I don't mean self-doubt. The author weaves discussions of security into each chapter. For instance, you must be careful to guard against allowing users to seriously alter the nature of your SQL queries. Trust no user-supplied data! Also, this chapter gives a PHP-based solution for creating MySQL dumps.
Once you've got the data in the database, making sure users can find it is another problem. You can use LIKE relations in your queries to search field strings. The author shows how to use FULLTEXT indexes (a MySQL 4 feature) to assist in searching the entire table or any set of fields you like, all at once.
Chapter 4: Files
Sometimes databases are overkill for data storage, or you need to extract data from text files. The author gives several examples of uses of interacting with a local or remote file system. He explains:- how to slurp whole files into memory or to process them chunk-by-chunk.
- how to use the PHP built-in functions to interface with the file system (so you can make a self-updating "Last updated: " item on your pages).
- how to use .ini-style files to store configuration data -- a common configuration style which is much faster than keeping it in a RDBMS or XML file.
- how to use FTP with PHP.
- how to compress and decompress with tar through PHP.
- how to send create a file and send it to your web user (custom files generated on-the-fly and ready for download!).
Again, the security threat is raised, and the author gives pointers on how to prevent from crackers getting you to execute their code by including one of their files rather than your own.
Chapter 5: Text Manipulation
When building dynamic web sites, being able to manipulate code is a must. You need to validate the data that users send to you, as well as guard against simple HTML error or malicious cross-site scripting (XSS) attacks. There are lots of built in functions (strip_tags to remove the HTML from a string), but using regular expressions you can validate and filter just about anything. You can reimplement a restricted set of markup tags a la BBCode, or set up a custom, easily-updated profanity filter.Chapter 6: Dates and Times
Another real-world problem is formatting dates and times in a human-readable (and perhaps localizeable) way, and on the machine level manipulating dates correctly. Luckily these are all solved problems and PHP connects you to the C functions which do it. Whether you store dates as MySQL timestamps (e.g., 2004-08-03 20:07:00) or UNIX timestamps (1091578114 seconds since the epoch) is up to you, although if you use the former you'll probably have to convert to the latter at some point. Putting it all together you can create dynamic calendars where clicking on a day brings you to your appointments for that day. Another good use of date functions is a implementation of cron written entirely in PHP for those not on a unix platform.Chapter 7: Images
Once you've mastered the art of producing HTML with PHP (developed even further in Chapter 9), you'll wonder what else can do. It turns out that PHP, using glue to the GD image library, can output images as well. You can generate thumbnails of your images to create galleries. You can watermark images with text to discourage stealing them. You can hide your images behind a PHP script that protects people other than you from linking directly to your images. And you can analyze data with enough charts and graphs to make Ross Perot ecstatic.Chapter 8: Email
Contacting your users off-site is a must if you want them to come back. Furthermore, it's a nice way to register users by sending them links to an address they provide. PHP can send email natively using the mail function, but as always there are nice classes which jazz up the features. You can send HTML attachments (known by some as "spam", but we're not here to judge), even including the images in the mail. You can even use PHP as a replacement for procmail by parsing incoming mail and triggering actions based on headers.Chapter 9: Web Page Elements
Eventually you get tired of writing HTML, and interweaving markup and presentation logic can give you a headache. Can't PHP be told to format the table the right way? Another solved problem! Displaying data in a table is a common task, and classes such as PEAR::HTML_Table can take a simple data structure and beautify it for you. Forms are another area in which PHP-generated code can save you time. You can also use PHP to produce "breadcrumbs" (there's one at the top of every slashdot page) and drop-down menus that show your users where in the hierarchy of information they are. Finally the author shows how to use apache's url_rewrite module to get those question marks, file extensions, and ampersands out of your URLS and sex them up. (You can also do this without url_rewrite, completely inside PHP, but using a custom error document and examining the path requested.)Chapter 10: Error Handling
So you're all excited about your next web app, and you dive into coding, and something goes wrong. What then? This chapter is about errors. You can use the error_reporting function to customize which exceptions actually produce error messages, or create your own error messages that handle errors your own way. You can choose to log them in a database, send an e-mail to a coding team, and most importantly, recover gracefully so that your users don't see an error message. Not only is it unprofessional, it may reveal information about your program, file system, or database structure that can harm you.Appendices
There are several good appendices, which tell you which configuration directives you're probably most interested in (the complete list you can get on PHP's web site), some common security breaches, and how to install PEAR, PHP's version of CPAN. My favorite appendix is the "Hosting Provider Checklist," a great reference for evaluating whether kewlhosting.com is going to give you the freedom and support you need to make a great hosted web site.All in all, I liked this volume. Having read probably a dozen PHP books I wouldn't say it offers new information. But even though you know the plot, it's possible to enjoy a well-told story. See Volume II for heavier-duty ideas.
* My made-up calculus notation for "bang for your buck"
**Like this: http://books.slashdot.org/
In real life, Matthew Leingang is Preceptor in Mathematics at Harvard University. He promises to review any book sent to him for free, and sometimes actually does it. Slashdot welcomes readers' book reviews. To see your own review here, carefully read the book review guidelines, then visit the submission page. -
The PHP Anthology - Volume I, 'Foundations'
sympleko (Matt Leingang) writes "What a beautiful world anthology is. It comes from the Greek for a gathering of flowers, and in literature means a collection of works. Harry Fuecks, a very frequent contributor to the SitePoint community PHP forums, has gathered a bouquet of PHP best practices in a new book. The book comes in two volumes. The audience for Volume I, "Foundations," is the advanced beginner who's done one or two things in PHP, but you wants to know how to do more. Volume II, "Applications," is a design volume, mainly, and is good for people who have lots of experience with PHP but want to be better programmers. It's nice that the two volumes are separate; if you already know the syntax and mechanics of PHP you can buy Volume II and maximize d!/d$.*" Read on for Leingang's review of Volume I, and watch for his followup on Volume II. The PHP Anthology: Volume I: Foundations author Harry Fuecks pages 376 publisher SitePoint rating 7 reviewer Matthew Leingang ISBN 0957921853 summary Good start; for the real story read Volume II as well.The book is very well-written, often using a question-and-answer heading style that makes searching the table of contents easy. In the preface, we already meet the first cool aspect of the book: lots of links to sites in the form of footnotes.** Yes, most books of this genre include links to web sites, but this way makes a couple of things clear: first, that there are lot of references, so you have many places to jump to for more information, and it's a sleeker text flow: embedding URLs in dead text makes line breaking hard and detracts from the flow of the language. As you read a page, you can note, "OK, that's an online resource," and keep reading without having to stumble over an incomprehensible URL.
Each volume has numerous code examples, and they're all on the book's web page to save you from transcribing. The web site is the best place also to buy the books; they're generally not available in stores.
Chapter 1: PHP Basics
These are the foundations of the book. Quick highlights:How does one exactly RTFM? The author directs the novice to the PHP web site and explains what each part of the online manual corresponds to. But also, the coolest aspect of the PHP web site is its search-by-url feature. It looks up a function or language reference page, finds a set of likely matches, or just googles the site for you. Try it: http://php.net/array, http://php.net/sprintf, http://php.net/error.
How to understand error messages. Remember your first "cannot add header information -- headers already sent" error. Huh? Learn the difference between parse errors (what you wrote is not valid code), semantic errors (you're asking PHP to do something illegal), environment errors (PHP is not equipped to do what you want), and logic errors (PHP is happy but you're not). The last is particularly insidious (no E_PEBKAC level of reporting), but unit testing (see Volume II) gives you hope to find and fix those.
How to include. What is the difference between include and require (answer: require forces a fatal error if it can't find the file you want, while include only warns)?
How to write portable and reusable code There are hundreds of configuration directives, and using them can make one of your applications simpler. But some are to be used only with careful consideration. The magic_quotes_gpc directive, for instance, sounded like a good idea at the time it was developed. It automatically escapes user input so backslashes remain backslashes and not escape characters. A common use of this directive allowed you to insert user-supplied data directly into a database without checking to make sure any embedded quotes wouldn't create unintended SQL statements. While this does guard against SQL injection attacks, you could still end up with garbage in the database. So you still have to check user data to make sure it complies to your standards. This is easier to do before escaping magic characters, so it's better to wait until just before storage; then add all the backslashes you need. Nowadays it's considered good form to not rely on this directive and just use addslashes when you need it.
For maximal code reuse, consider object orientation. But there's a whole chapter on that...
Chapter 2: Object Oriented PHP
"Be lazy," the author writes; "Write good code." One of the ways to organize your code is through object-oriented programming. Most readers know the basic concepts of OOP, and are probably tired of the few over-simplified examples. Beyond that this chapter wants to get you to think OO, to "no longer think about long lists of tasks that a single script should accomplish; instead, [to] see programming as the putting together of a set of tools to which your script will delegate work."I know my first PHP classes were just namespaced scripts. The attributes and methods weren't at all related. This chapter (as well as Chapter 7 of Volume II) helps you distinguish where your classes are and how they connect. One of the aids for this is the use of Unified Modeling Language (UML) class diagrams. These diagrams, which use boxes for classes and arrows for the relationships between them, are really cool programming and teaching tools that require no code!
Here I think the book's physical workflow got caught in a gap between major PHP releases. The cover says this book says "PHP5 ready," which is a bit of a misnomer because all the code examples and rules are all written for PHP4. Minor text mentioning how things are going to be different in PHP5 has been inserted. It's true that none of the OO code written here will break in PHP5, but there are major additions to PHP5 especially in the OO implementation (no more ampersands! actual private variables! Exceptions! Much, much more!). Still, the author makes the point that you the programmer may not be using PHP5 for a while (PHP 5.0.0 is only a few weeks old today), and that you shouldn't put off learning PHP until version 5 is agreed to be stable.
I've read the comments of PHP bashers, arguing that using it for OO programming is a waste of overhead. The author has heard that argument, too, and rebuts:
"What they forget to mention is the drastic increase in your performance that object oriented programming delivers. After all, fast programmers cost more than fast microprocessors!"
Hear, hear. RAM and disk space are commodities, while programmers are not (yet).
Chapter 3: PHP and MySQL
This goes beyond the simple HOWTO on connecting to a database. A suite of PHP classes is developed for database connections, querying, and result handling, not as much to use as for your "health"--i.e., to see a well-done class from start to finish. For your real applications, use a real, well-maintained and tested class such as those found in PEAR. This is another principle of good programming: Somebody has probably had the same problem you are having right now, and already solved it (also known as Ecclesiastes 1:9, "...there is nothing new under the sun.")If you've done lots of SQL queries, you get to thinking that there's got to be a better way to access a database. In fact, you can build a layer of abstraction over the database connection layer to create interface classes to individual tables. This is called a persistence layer. For an implementation, see PEAR::DB_DataObject.
Any web programmer fears insecurity, and I don't mean self-doubt. The author weaves discussions of security into each chapter. For instance, you must be careful to guard against allowing users to seriously alter the nature of your SQL queries. Trust no user-supplied data! Also, this chapter gives a PHP-based solution for creating MySQL dumps.
Once you've got the data in the database, making sure users can find it is another problem. You can use LIKE relations in your queries to search field strings. The author shows how to use FULLTEXT indexes (a MySQL 4 feature) to assist in searching the entire table or any set of fields you like, all at once.
Chapter 4: Files
Sometimes databases are overkill for data storage, or you need to extract data from text files. The author gives several examples of uses of interacting with a local or remote file system. He explains:- how to slurp whole files into memory or to process them chunk-by-chunk.
- how to use the PHP built-in functions to interface with the file system (so you can make a self-updating "Last updated: " item on your pages).
- how to use .ini-style files to store configuration data -- a common configuration style which is much faster than keeping it in a RDBMS or XML file.
- how to use FTP with PHP.
- how to compress and decompress with tar through PHP.
- how to send create a file and send it to your web user (custom files generated on-the-fly and ready for download!).
Again, the security threat is raised, and the author gives pointers on how to prevent from crackers getting you to execute their code by including one of their files rather than your own.
Chapter 5: Text Manipulation
When building dynamic web sites, being able to manipulate code is a must. You need to validate the data that users send to you, as well as guard against simple HTML error or malicious cross-site scripting (XSS) attacks. There are lots of built in functions (strip_tags to remove the HTML from a string), but using regular expressions you can validate and filter just about anything. You can reimplement a restricted set of markup tags a la BBCode, or set up a custom, easily-updated profanity filter.Chapter 6: Dates and Times
Another real-world problem is formatting dates and times in a human-readable (and perhaps localizeable) way, and on the machine level manipulating dates correctly. Luckily these are all solved problems and PHP connects you to the C functions which do it. Whether you store dates as MySQL timestamps (e.g., 2004-08-03 20:07:00) or UNIX timestamps (1091578114 seconds since the epoch) is up to you, although if you use the former you'll probably have to convert to the latter at some point. Putting it all together you can create dynamic calendars where clicking on a day brings you to your appointments for that day. Another good use of date functions is a implementation of cron written entirely in PHP for those not on a unix platform.Chapter 7: Images
Once you've mastered the art of producing HTML with PHP (developed even further in Chapter 9), you'll wonder what else can do. It turns out that PHP, using glue to the GD image library, can output images as well. You can generate thumbnails of your images to create galleries. You can watermark images with text to discourage stealing them. You can hide your images behind a PHP script that protects people other than you from linking directly to your images. And you can analyze data with enough charts and graphs to make Ross Perot ecstatic.Chapter 8: Email
Contacting your users off-site is a must if you want them to come back. Furthermore, it's a nice way to register users by sending them links to an address they provide. PHP can send email natively using the mail function, but as always there are nice classes which jazz up the features. You can send HTML attachments (known by some as "spam", but we're not here to judge), even including the images in the mail. You can even use PHP as a replacement for procmail by parsing incoming mail and triggering actions based on headers.Chapter 9: Web Page Elements
Eventually you get tired of writing HTML, and interweaving markup and presentation logic can give you a headache. Can't PHP be told to format the table the right way? Another solved problem! Displaying data in a table is a common task, and classes such as PEAR::HTML_Table can take a simple data structure and beautify it for you. Forms are another area in which PHP-generated code can save you time. You can also use PHP to produce "breadcrumbs" (there's one at the top of every slashdot page) and drop-down menus that show your users where in the hierarchy of information they are. Finally the author shows how to use apache's url_rewrite module to get those question marks, file extensions, and ampersands out of your URLS and sex them up. (You can also do this without url_rewrite, completely inside PHP, but using a custom error document and examining the path requested.)Chapter 10: Error Handling
So you're all excited about your next web app, and you dive into coding, and something goes wrong. What then? This chapter is about errors. You can use the error_reporting function to customize which exceptions actually produce error messages, or create your own error messages that handle errors your own way. You can choose to log them in a database, send an e-mail to a coding team, and most importantly, recover gracefully so that your users don't see an error message. Not only is it unprofessional, it may reveal information about your program, file system, or database structure that can harm you.Appendices
There are several good appendices, which tell you which configuration directives you're probably most interested in (the complete list you can get on PHP's web site), some common security breaches, and how to install PEAR, PHP's version of CPAN. My favorite appendix is the "Hosting Provider Checklist," a great reference for evaluating whether kewlhosting.com is going to give you the freedom and support you need to make a great hosted web site.All in all, I liked this volume. Having read probably a dozen PHP books I wouldn't say it offers new information. But even though you know the plot, it's possible to enjoy a well-told story. See Volume II for heavier-duty ideas.
* My made-up calculus notation for "bang for your buck"
**Like this: http://books.slashdot.org/
In real life, Matthew Leingang is Preceptor in Mathematics at Harvard University. He promises to review any book sent to him for free, and sometimes actually does it. Slashdot welcomes readers' book reviews. To see your own review here, carefully read the book review guidelines, then visit the submission page. -
Apple and the Open Source Community
Dozix007 writes "Sitepoint reports an interesting article on the increasing interconnection between Apple's recently released Tiger, and the open source community. Tiger includes improved releases of Apple's directory services (LDAP), secure authentication (Kerberos), mail server (Postfix), web server (Apache) and many more features, nearly all based on existing open source software. Most significant may be the release of Rendezvous for Java, Linux/Unix and Windows. This is a zero-configuration tool for networking that includes network protocols, identification and configuration of devices and services such as printers and local/remote servers, and was based on open source technology." -
Apple and the Open Source Community
Dozix007 writes "Sitepoint reports an interesting article on the increasing interconnection between Apple's recently released Tiger, and the open source community. Tiger includes improved releases of Apple's directory services (LDAP), secure authentication (Kerberos), mail server (Postfix), web server (Apache) and many more features, nearly all based on existing open source software. Most significant may be the release of Rendezvous for Java, Linux/Unix and Windows. This is a zero-configuration tool for networking that includes network protocols, identification and configuration of devices and services such as printers and local/remote servers, and was based on open source technology." -
Introduction to Debian
[vmlinuz] writes "SitePoint has an article that I wrote that introduces Debian and has guidelines on installing it. This could be usefull for managers, new users and other people that may be interested in using Debian." And honestly, who among us isn't interested in using the obviously superior Linux Distribution against which there can be no other contenders? (Oh dear god don't flame me! It's a joke people!) -
Introduction to Debian
[vmlinuz] writes "SitePoint has an article that I wrote that introduces Debian and has guidelines on installing it. This could be usefull for managers, new users and other people that may be interested in using Debian." And honestly, who among us isn't interested in using the obviously superior Linux Distribution against which there can be no other contenders? (Oh dear god don't flame me! It's a joke people!) -
Content Syndication With RSS
Alex Moskalyuk writes "Ben Hammersley's Content Syndication with RSS is a step-by-step guide to implementing RSS. This standard is gaining popularity among the Web community, and some of your favorite sites might syndicate their content as RSS feeds. The new O'Reilly publication focuses on many aspects of this standard, and is of primary interest to developers, Web site designers, data architects and anyone interested in distributing their data around the Web." So if you have a steady stream of information for your customers, family, or fans, read on for the rest of Alex's review. Content Syndication With RSS author Ben Hammersley pages 222 publisher O'Reilly rating 8/10 reviewer Alex Moskalyuk ISBN 0596003838 summary Introduction and guide for RSS implementationsThe first three chapters are primarily discussing the multiplicity of RSS standards. While with some other technologies it might seem a bit excessive, remember that RSS is a forked project with the forks at this moment bearing little resemblance to one another. The abbreviations even have different abbreviations - RSS means Really Simple Syndication if you are using RSS 0.91 or RSS 0.92, that was developed by Dave Winer. RSS means RDF Site Summary if the version you're using RSS 1.0. The development credits in this case go to RSS DEV team. To confuse you even more, the RSS 2.0 standard is deciphered as... correct, Really Simple Syndication again.
Hence chapter 4 discusses Winer's implementation (simplistic and user-friendly), while chapter 6 focuses on RSS 1.0 (RDF-compliant and data-architect-friendly), and chapter 8 talks about RSS 2.0 (improved RSS 0.9x). Chapter 4 is available online as a PDF file. Section 4.4 is recommended for those interested in promoting their RSS feeds as it provides pretty good reference to meta data.
Chapter 9 is perhaps of special interest to Web developers and administrators out there. It presents several code samples to properly parse RSS and present the result in readable HTML. The examples include (a) parsing with XML::Simple in Perl, (b) parsing with Perl regular expressions, (c) parsing with XML::Simple and sending the headlines to cell phones via WWW::SMS, (d) parsing via XSLT transformation. Python, PHP and ASP folks might feel left out due to the abundance of Perl examples, but if you got so far in the book, you can probably apply the regular expressions example or search for appropriate support for RSS format in your preferred language.
Going beyond the standard itself, RSS directories, aggregators and readers are discussed. Author makes a distinction between the last two by classifying Meerkat-like services into aggregators and desktop or Web applications designed to present the information to the user into readers. The chapter also provides information about Syndic8, its API, and describes the feed registration process. OReilly's Meerkat is also discussed in chapter, together with reference table for its API (you can make Meerkat generate HTML or RSS news headlines on certain topic or using certain keywords by providing a right query to its Web interface).
The book is quite a smooth read for a text describing the details of data specification. The chapters are informative and the book is not overloaded with useless information just to increase the page count. The tips are quite useful for someone, who is knew to the field and answers some questions not covered by standards (e.g., how often should you request an RSS feed, what to do if you're being screen-scraped, etc.)
I like the way the author divided the chapters into RSS 0.9x/2.0 and RSS 1.0 and kept two worlds apart. Most of the time you probably won't be interested in developing a feed to support both standards, but would like to focus just on one. The examples in Perl are perfect with me, although for someone new to Perl or programming in general those examples with abundant regular expressions might look a bit convoluted. Kudos to the author for not expanding on the topic, like many do, and providing an example of a script for RSS manipulation in every possible language out there.
What's missing? I wish more pages were dedicated to desktop RSS readers. FeedReader, HotSheet, Syndirella, Beaver and SharpReader are excellent end user applications currently gaining some popularity among those who'd prefer to browse the favorite headlines at a glance, instead of going to a dozen of sites every morning. To be fair, there's a huge list of readers in Appendix, and some applications mentioned above only came around in the last few months, which was probably after the book hit the press. Some sites also didn't make it into the book. I like DailyRotation and FreshNews that borrow from Meerkat's versatility and provide their own feed portal.
Overall, the book is a pretty good developer's guide to RSS standard. Accompanied with helpful illustrations and numerous tips it's an excellent resource for those unfamiliar with RSS and a helpful reference for those who have been doing Web syndication for a while.
You can purchase Content Syndication With RSS from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.