Thoughts, rants and commentary from a husband, father of five and professional web geek

Newest title: Book reviewer

Posted on October 23rd, 2009 in PHP, Personal Messages, Web Development | No Comments »

A few days ago I received an email from Packt Publishing, “a UK based publishing firm specializing in focused IT books” asking if I would be willing to review a new book they are publishing entitled Zend Framework 1.8 Web Application Development. The book, written by Keith Pope, appears to cover the basics of using the Zend Framework to build web applications rapidly.

According the book description:

The Zend Framework has a flexible architecture that lets you build modern web applications and web services easily. The MVC components make the maintenance and testing of your applications easier. However, it is not only an MVC framework for developers. It also provides an easy-to-use high-quality component library that is designed to be used the way you want, picking up specific components without requiring the use of whole framework.

It’s easy to get started and produce a powerful and professional looking web site when you’ve got this book to hand. Taking you through a real-life application, it covers the major Zend Framework components, as well as throwing light on the best practices and design issues faced when building complex MVC applications.

This book takes you through detailed examples as well as covering the foundations you will need to get the most out of the Zend Framework. From humble beginnings you will progress through the book and slowly build upon what you have learned previously. By the end, you should have a good understanding of the Zend Framework, its components, and the issues involved in implementing a Zend Framework based application.

I am actually looking forward to reading what Keith has put together. With some of the more recent improvements to the Zend Framework I have been really considering putting the framework to use in a project. Hopefully having examples to follow will point me in the proper direction.

Regardless, I am looking forward to reading what Keith has to say about developing with the Zend Framework. And if nothing else, at least I get a free chapter of a new PHP book out of the deal. ;)

Back to top

Getting books details by ISBN in PHP

Posted on April 4th, 2009 in Geek Stuff, PHP, Programming, Web Development | 4 Comments »

Sometimes I love being a geek. Today, as I set out to inventory my collection of almost 500 books or so, I wanted to find a fast way to get the information on the book I wanted based on the books ISBN. This was because I was already getting tired of typing five books into the inventory (yes, I am that lazy) and I really did not want to keep typing out the authors name, the title and the subtitle for each book.

So I went to ISBNdb.com and entered an ISBN thinking I would be able to just copy and paste the book information from the output. That turned out to be overwhelmingly difficult since their output of the search is really convoluted. I knew what I wanted to get and they didn’t offer that.

But they did offer an API and, after reading their docs, I realized that I could write a script that would take an ISBN and return to me the information I was looking for in a way that I could just copy and paste it. Remarkably, it was faster and easier than I thought it would be. I actually developed this little snippet, freely available for you here, in about 5 minutes. Hope it helps you in some way, if you are looking for such a thing.

NOTE: Before using this code make sure to sign up for your own API key. In order to do that you will need to register for an account with ISBNdb.com and then create a key. But as soon as you do you will have immediate access to their API. The API is simple, responding to the request with a simple XML output. Anyhow, without further ado, here is the little script I put together to fetch me the data I was looking for the way I wanted it.

<?php
/**
 * Set this value to your own API key
 */
$apikey = '12345678';
 
/**
 * Initialize this var for use when forms are not posted
 */
$isbn = null;
 
/**
 * Initialize the result set var
 */
$rs = null;
 
/**
 * See if the form is posted
 */
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  /**
   * Get the ISBN from the form
   * 
   * No, there is no validation on this. This 
   * was for me and I knew I would not be at
   * all trying to trick my own script. USE 
   * THIS AS IS AT YOUR OWN PERIL.
   */
  $isbn = $_POST['isbn'];
 
  /**
   * Get the result as a SimpleXML object
   */
  $rs = simplexml_load_file("http://isbndb.com/api/books.xml?access_key=$apikey&index1=isbn&value1=$isbn");
}
?>
<html>
<head><title>ISBN Check</title></head>
<body>
<form method="post" action="<?php echo basename(__FILE__) ?>">
  <p>
    Enter an ISBN:<br />
    <input type="text" size="40" name="isbn" id="isbn" value="<?php echo $isbn ?>" />
  </p>
  <p>
    <input type="submit" name="submit" value="Search ISBN" />
  </p>
</form>
<?php
/**
 * Only output more stuff if there is a result
 */
if ($rs) : ?>
<hr />
Results for ISBN: <?php echo $isbn ?>:
<?php 
/**
 * Results for a book are in $rs->BookList->BookData
 * 
 * You can see this using var_dump($rs);
 */ 
$book = $rs->BookList->BookData;
?>
<p>
  <strong><?php echo $book->Title; ?></strong><br />
  <?php echo !empty($book->TitleLong) ? $book->TitleLong . '<br />' : null; ?>
  <?php echo $book->AuthorsText; ?><br />
  <?php echo $book->PublisherText; ?><br />
  <?php echo $isbn; ?>
</p>
<?php endif; ?>
</body>
</html>

Typical output might look like (from one of the books I was checking on):


Results for ISBN: 0316116955:

The day the universe changed
James Burke
Boston : Little, Brown, c1985.
0316116955


I hope you enjoy this, if you happen to be looking for an ISBN search tool that you can run on your own. ;)

Back to top

Microsoft Expression Web Super Preview

Posted on March 19th, 2009 in Microsoft, Web Browsers, Web Development | No Comments »

I just read an article on ZDNet that mentioned a recent “showing off” of Expression Web SuperPreview by Microsoft. SuperPreview allows web developers to view and debug web output and rendering as it would appear in Internet Explorer 6, 7 and 8. And I can’t help but wonder… why would we need a tool to check rendering if Microsoft actually handled rendering properly to begin with?

I am glad they have introduced this tool. Before this you had to install an application that would literally install multiple versions of IE on your machine. Then you would need to load your page in a new instance of whatever version you wanted to test. That really sucked. So having the option to inspect your rendering in one app across multiple versions of IE is definitely a boon. But still, why should you have to do that?

And speaking of browsers, a friend of mine the a few weeks back brought up a point that I still enjoy… why are we still coding for browser based output anyway? The web as we know it is totally breaking out of the browser. Why are there still cross-browser compatibility issues and rendering problems?

While I applaud Microsoft on their efforts to help developers code for their broken, crappy, waste-of-software browser, I think I am leaning more towards my friend’s way of thinking. Maybe it is time to start thinking outside the browser box?

Regardless, if you are a developer developing on Windows and you need a tool that will help you see how things are going to work for you in IE 6, 7 and 8, this might be the tool for you.

Back to top

Fun with PHP

Posted on July 24th, 2008 in PHP, Web Development | 4 Comments »

Every now and again someone writes a line or two of code that really makes me smile. Such is the case with this outcome determinating and decision making class below. This code is being reproduced, with or without consent, from the PHP Developers Network’s own scottayy.

<?php
/**
 * Coin flipper class helps determine outcome of situations in which an outcome
 * cannot be decided by sheer manpower alone.
 * 
 * @author Scott Martin <scottayy@devnetwork.net>
 * @license None, don't even try to use this or your hair will turn yellow
 */
class coin {
	/**
	 * The outcome determinators
	 * 
	 * Each invocation of this object will require a determinator upon which the
	 * object relies to build a determined outcome. These are those determinators.
	 * 
	 * @access private
	 * @var array
	 */
	private static $_sides = array('heads', 'tails');
 
	/**
	 * The determinating method
	 * 
	 * This method, when called, invokes a determination sequence and returns a
	 * determined value for use in decision making.
	 * 
	 * @access public
	 * @return string Randomly selected determinator
	 */
	public static function flip() {
		// Quick, randomize me some determinators
		shuffle(self::$_sides);
 
		// Quick, offer it back before it gets angry
		return self::$_sides[mt_rand(0, 1)];
	}
}
 
/**
 * We should always test our determinating decision establisher
 *
 * 2,4,6,8 You know you want to determinate
 */
echo coin::flip();
?>

For those that just have to have an object to instantiate (and you know who you are), there is this lightly modified version for your obsessive/compulsive selves:

<?php
/**
 * Coin flipper class helps determine outcome of situations in which an outcome
 * cannot be decided by shear manpower alone.
 * 
 * @author Scott Martin <scottayy@devnetwork.net>
 * @license None, don't even try to use this or your hair will turn yellow
 */
class coin {
	/**
	 * The outcome determinators
	 * 
	 * Each invocation of this object will require a determinator upon which the
	 * object relies to build a determined outcome. These are those determinators.
	 * 
	 * @access private
	 * @var array
	 */
	private $_sides = array('heads', 'tails');
 
	/**
	 * The determinating method
	 * 
	 * This method, when called, invokes a determination sequence and returns a
	 * determined value for use in decision making.
	 * 
	 * @access public
	 * @return string Randomly selected determinator
	 */
	public function flip() {
		// Quick, randomize me some determinators
		shuffle($this->_sides);
 
		// Quick, offer it back before it gets angry
		return $this->_sides[mt_rand(0, 1)];
	}
}
 
/**
 * We should always test our determinating decision establisher
 */
$coin = new coin;
 
/**
 * 2,4,6,8 You know you want to determinate
 */
echo $coin->flip();
?>

See, just looking at that code makes you want to smile doesn’t it? Geeks are great.

Back to top

How would improve the look of this site?

Posted on June 21st, 2008 in Personal Messages | 2 Comments »

I have made a good many changes to this theme in the few days that it has been alive. Since its launch a few day ago I have asked for critiques and constructive criticism from the PHP Developers Network. However, I think it might be better to ask your opinion as well seeing you might not visit the PHPDN community (tsk, tsk).

So I ask you, dear reader, if you were going to improve upon the way this theme appears, what would you do? What changes would you make if you were the designer?

I appreciate any responses you provide. I am looking forward to making this theme a usable, intuitive, clean interface and could use any and all feedback presented.

Thanks.

Back to top

A bit of irony in the PHP world

Posted on May 19th, 2008 in Geek Stuff, PHP, Web Development | No Comments »

According to an article today by TechCrunch, Zend Technologies, The PHP company, is cutting 25% of their PHP developer staff, perhaps with an eye towards selling the company.

Israeli startup Zend Technologies has fired 25 percent of its R&D team (at least ten people), as well as others across the company, in an attempt to become cash flow positive, says a source close to the company. A spokesperson from the company’s PR firm says: “Yes, I can confirm that Zend made the layoffs, but we cannot comment on the numbers or reasons for the action.”

Read the complete TechCrunch article here.

As I read the brief article I began to think that this is not really anything that should be too newsworthy. Many companies in the USA, and around the world in general, are feeling the pinch of a down economy. Companies have to do what they can to reduce cost while maintaining competitive prices for goods and services. What Zend is doing is not really that out of the ordinary.

And I am not sure that Zend, as a company, is really worth a huge amount of money like the Sun Microsystems acquisition of MySQL was. It might be tasty to some of the players in the industry right now like Oracle, IBM or even a Sun. But really, other than the Zend engine and the Zend IDE what exactly does Zend have to offer?

Whatever happens to Zend from all of this one thing is very important to remember. Many a PHP developer now has the opportunity to seek gainful employment from other companies that are seeking, heavily, PHP talent. Many Silicon Valley companies, including many companies in the social networking space, are looking for top tier PHP talent right now. Companies like Ning, Digg, Facebook, Technorati, Yahoo and Google are constantly hiring PHP developers.

Times are good for being a PHP developer. Maybe not so much if you worked for Zend. Nonetheless, now is a great time to know a great deal about PHP.

Back to top