Hands-on Testing with PHPUnit How-to – A short, well-focused guide – #programming #bookreview

Instant Hands-on Testing with PHPUnit How-to
A practical guide to getting started with PHPUnit to improve code quality
Michael Lively
(Packt Publishing – paperback, Kindle)

PHPUnit is considered by many to be the leading tool for testing PHP code. This “Short, Fast, Focused” book (82 pages digital, 69 pages in paperback) is a recent addition to Packt Publishing’s “Instant” series. It zeroes in on how to install and use PHPUnit to create and run “easy-to-maintain tests.”

One strength of Michael Lively’s new book is his experience with PHP and PHPUnit. Another strength is the book’s step-by-step structure. It rates each key step as “Simple”, “Intermediate”, or “Advanced” and provides subheadings such as “Getting ready…”, “How to do it…”, “How it works…”, and “There’s more…” to help keep descriptions short and clear.

Code examples and screenshots also help the reader get comfortable with running tests using the PHPUnit framework.

Aside from skipping commas in some of the text, Michael Lively’s writing is clear and concise, and his descriptions and code examples have been reviewed by two experienced software developers.

The book is “written for anyone who has an interest in unit testing but doesn’t necessarily know where to start in integrating it with their project,” Lively states.

“It will provide useful tips and insights into how PHPUnit can be used with your projects and it should give you enough information to whet your appetite for the various features offered by PHPUnit.”

The code examples in Lively’s book “were written using PHP 5.3.24 and PHPUnit 3.7. All code samples were verified against a Linux box with Ubuntu 12.04 LTS.”

As with several other Packt books recently reviewed, if you use a Windows PC or a Mac instead of a Linux system, you pretty much are left on your own to figure out the installation process and certain commands.

—   Si Dunn


Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition – Dynamic websites #programming #bookreview

Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition
Robin Nixon
(O’Reilly, paperbackKindle)

Robin Nixon recently has updated and expanded his popular 2009 “step-by-step guide to creating dynamic websites.” The new edition has an added section that focuses on Cascading Style Sheets (CSS), so the book “now covers all four of the most popular web development technologies.”

Nixon notes: “The real beauty of PHP, MySQL, JavaScript, and CSS is the way in which they all work together to produce dynamic web content: PHP handles the main work on the web server, MySQL manages all of the data, and the combination of CSS and JavaScript looks after web page presentation. JavaScript can also talk with your PHP code on the web server whenever it needs to update something (either on the server or on the web page).”

The book’s opening chapters introduce (1) what dynamic web content means and (2) how to set up a development server on your Windows PC, Mac, or Linux machine. After that, Learning PHP, MySQL, JavaScript, & CSS, 2nd Edition follows the structure outlined by its title. First, you get a five-chapter tutorial on PHP programming. Then, two chapters show how to use MySQL. One additional chapter shows how to access MySQL using PHP, and two related chapters deal with (1) form handling and (2) cookies, sessions and authentication, using PHP and MySQL.

Three chapters introduce JavaScript programming. A fourth chapter covers “JavaScript and PHP Validation and Error Handling.” And one additional chapter describes “how to implement Ajax using JavaScript.”

Ajax, Nixon explains, “not only substantially reduces the amount of data that must be sent back and forth [between a browser and a server] but also makes web pages seamlessly dynamic, allowing them to behave more like self-contained applications.”

CSS gets its turn next, with an introductory chapter, a chapter on advanced CSS with CSS3, and a chapter on accessing CSS from JavaScript.

Finally, in the “Bringing It All Together” chapter, Nixon shows how to build a simple social networking site, using all of the tools introduced in the book.

Learning PHP, MySQL, JavaScript, & CSS, 2nd Edition is an excellent how-to guide for web development beginners who have moderate computer skills and a little bit of experience with HTML and static web pages. The book is nicely written and well-illustrated, and the code examples generally are easy to follow. Screen shots and other descriptions of expected results also can help keep you moving forward on the right path.

No book can cover everything you need to know, of course, particularly when several different types of software are involved. You may need occasional help from someone who has used one or more of the described programs. And some of the screen examples may appear a bit different on your machine as new software updates are released. But Robin Nixon’s updated edition can take you a long way toward the goal of learning how to design, create, post, and maintain dynamic web pages, using free, open source tools.

Si Dunn

CouchDB and PHP Web Development Beginner’s Guide – #programming #bookreview

CouchDB and PHP Web Development Beginner’s Guide
Tim Juravich
(Packt Publishing, paperbackKindle)

CouchDB and PHP can be a formidable team when used to create web applications. 

“CouchDB is a database that completely embraces the web,” according to the Apache CouchDB website. Data is stored with JSON documents; documents can be accessed with a web browser via HTTP; and JavaScript can be used to “query, combine, and transform” documents. “You can even serve web apps directly out of CouchDB,” the site states.

Meanwhile, PHP is “a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML,” its website notes.

The new CouchDB and PHP Web Development Beginner’s Guide by Tim Juravich is an excellent source for learning how to make the two packages work together. His focus, in the book, is on developing and honing skills by discovering “the ins and outs of building a simple but powerful website using CouchDB and PHP.”

After installing CouchDB and PHP, you learn how to create and enhance a simple, Twitter-like social network called “Verge.” It is an application that “will allow users to sign up, log in, and create posts,” the author states.

CouchDB and PHP Web Development Beginner’s Guide is available through Amazon, Barnes & Noble, and Safari, and also can be ordered direct from the Packt Publishing website in digital formats as well as print.

The book is packed with how-to steps and explanatory details. And it is organized into 10 well-defined chapters.

  • Chapter 1: Introduction to CouchDB
  • Chapter 2: Setting up your Development Environment
  • Chapter 3: Getting Started with CouchDB and Futon
  • Chapter 4: Starting Your Application
  • Chapter 5: Connecting Your Application to CouchDB
  • Chapter 6: Modeling Users
  • Chapter 7: User Profiles and Modeling Posts
  • Chapter 8: Using Design Documents for Views and Validation
  • Chapter 9: Adding Bells and Whistles to Your Application
  • Chapter 10: Deploying Your Application

A key strength of this book is its structure and use of focused headings. For example, when it is time to do something at your computer, there is a “Time for action” heading, such as: “Time for action – creating new databases in CouchDB.”

The step-by-step procedures that you then perform are laid out clearly in numbered order. And you get more than a brief description or illustration of what is supposed to happen. Juravich follows up with summary paragraphs labeled “What Just Happened?”  These summaries describe the purposes of the steps just performed and what they achieved.

Also, at the end of each chapter, he includes a helpful summary of the key points he has covered.

CouchDB and PHP Web Development Beginner’s Guide is well written and follows a classic and effective teaching model: “Tell them what you are going to tell them, tell them, and then tell them what you just told them.”

Its example code files can be downloaded from the Packt website or sent to you by email after you have registered with Packt.

The second chapter includes instructions for installing Apache, PHP, Git (for version control), and CouchDB on Windows, Linux and Mac OS X machines. But it is worth noting that the author restricts most of his discussions to the Mac OS X operating system (10.5 and later) and uses Mac OS command line statements “for simplicity and brevity.”

Windows and Linux users likely will have to do some command-line translations and work with files in different locations than described. Newbies with Windows or Linux machines should wait and gain more command-line experience first or find a mentor who knows both Mac OS X and Windows or Linux before tackling this book.

Maybe someone will write a similar CouchDB-PHP book for Windows and/or Linux users soon?

Si Dunn

PHP & MySQL: Novice to Ninja, 5th Ed. – A popular how-to guide updated – #bookreview #in #php #programming

PHP & MySQL: Novice to Ninja, 5th Edition
Kevin Yank
paperback, list price $39.95; Kindle edition, list price $29.95)

A key measure of a programming book’s usefulness and popularity is how many times it has been revised and reprinted.

Kevin Yank’s book first was published in 2001 under a different title. Eleven years later, his newly revised fifth edition is now in print and providing up-to-date hands-on guidance for those who want to use PHP and MySQL to create database-driven websites.  (By some estimates, at least 20 million websites worldwide now use PHP.)

Yank points out that “PHP is a server-side scripting language that lets you insert instructions into your web pages that your web server software (in most cases, Apache) will execute before it sends those pages to browsers that request them.”

Meanwhile, “[a] database server (in our case MySQL) is a program that can store large amounts of information in an organized format that’s easily accessible through programming languages like PHP. For example, you could tell PHP to look in the database for a list of jokes that you’d like to appear on your website.”

Yank’s fifth edition shows you how to use PHP to create a working content management system (CMS) that accesses – no surprise here – an online joke database that’s managed with MySQL. (Of course, if you think a simple joke database is lame, you can always modify a few tables and labels and create something more substantial, such as a database of vegetables you hate or celebrities or politicians you consider utterly irrelevant to your life.) 

Building a joke database (or whatever) is a pleasant way to learn the basics of PHP coding and database design and then quickly start improving your knowledge and skills as the CMS project is expanded and given more capabilities.

Yank’s book has 12 chapters and four appendices. The how-to chapters are split into short paragraphs, with numerous short code examples. A link is provided where the book’s code examples can be downloaded in a ZIP archive. And the book’s text is written in a smooth, approachable style.

PHP & MySQL: Novice to Ninja, 5th Edition is “aimed at intermediate and advanced web designers looking to make the leap into server-side programming,” Yank says. He expects readers to be familiar with “simple HTML” but “[n]o knowledge of Cascading Style Sheets (CSS) or JavaScript is assumed or required.”

He adds, however, “if you do know JavaScript, you’ll find it will make learning PHP a breeze, since these languages are quite similar.”

Si Dunn

MongoDB and PHP – Document-oriented data for web developers – #bookreview #in #programming

MongoDB and PHP
By Steve Francia
paperback, list price $19.99; Kindle edition, list price, $14.99)

You can’t blame Steve Francia for being vocal in his praise for MongoDB®. He’s the chief solutions architect at 10gen, Inc., which develops and supports this well-respected document-oriented database.

One consequence of the current, explosive growth of social media is that “all data and experience [needs] to be personalized – on a large scale,” he writes in his new book, MongoDB and PHP. Today, the data stores and caching techniques used over in the past three decades are losing their ability to keep pace. So: “It was out of this need that MongoDB was created. A database for today’s applications, a database for today’s challenges, a database for today’s scale.”

MongoDB, according to its 10gen, Inc., website, is “a scalable, high-performance, open-source noSQL database,” written in C++. Its features include: document-oriented storage; full index support; replication and high availability; auto-sharding (horizontal scaling with a partitioning architecture); querying; rapid in-place updates; map/reduce (for batch processing of data and aggregation); and GridFS (a specification for storing large files in MongoDb).

Francia explains that MongoDB is a document database. “At the highest level of organization, it is quite similar to a relational database, but as you get closer to the data itself, you will notice a significant change in the way the data is stored. Instead of databases, tables, columns, and rows, you have databases, collections, and documents.”

Meanwhile, in PHP (PHP: Hypertext Processor), “a document is equivalent to an array …,” for all intents and purposes.

PHP, which can be downloaded from this site, “is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML,” according to the PHP Group.

Francia notes in his book that “[i]n MongoDB, the primary object is called a document. A document doesn’t have a direct correlation in the relational world. Documents do not have a predefined schema like relational database tables. A document is partly a row, in that it’s where the data is located, but it’s also part columns, in that the schema is defined in each document (not table-wide)….The best way to think of a document is as a multidimensional array.”

Meanwhile, Francia adds: “Documents map extremely well to objects and other PHP data types like arrays and even multidimensional arrays.” So PHP users contemplating building PHP applications with MongoDB will find that “the PHP array has the closest correlation of any data type. It’s nearly a 1-to-1 correlation.”

His code examples, illustrations and succinct paragraphs show how MongoDB and PHP can work together closely and effectively when building database applications.

If you have been contemplating diving into PHP and/or MongoDB, this is a worthy book to add to your learning and reference collections.


Si Dunn is a novelist, screenwriter, freelance book reviewer, and former software technical writer and software/hardware QA test specialist. He also is a former newspaper and magazine photojournalist. His latest book is Dark Signals, a Vietnam War memoir available soon in paperback. He is the author of a detective novel, Erwin’s Law, a novella, Jump, and several other books and short stories.