Archive for November, 2006

Chicago PHP User Group Upcoming Meeting - Nov 14

Moved from Wednesday to Tuesday this week, I’ll be talking about testing. I’ll talk a bit about Selenium, test-more and PHPUnit.

Info.com
150 N Michigan
Suite 2800
6:30p

If you are arriving past 7:00pm, shoot me an email (or comment here) and I’ll give your name to the guard and he’ll let you in .. otherwise, call Rich or I.

Comments

Book Review: PHP Hacks

Book Review: PHP Hacks by Jack D. Herrington, published by O’Reilly

I had borrowed a Perl Hacks book from and friend and really liked it, it was great! It had a lot of practical things as well as some fun things. I expected the same from PHP Hacks and I was not disappointed!

Here’s the table of contents:
http://www.oreilly.com/catalog/phphks/toc.html

O’Reilly also has some sample hacks:
http://www.oreilly.com/catalog/phphks/chapter/index.html

Here’s some that I found interesting:

The Practical Stuff
Breadcrumbs
Not familiar with the term? Check it out. I think this hack may get you started on a breadcrumb function/method. In the end they suggest a xml file to show which page urls were parents of which. The way I’ve done this before was I had a class for each major section, and sub section, and had a method ->addCrumb($label, $url) which I had in the constructor…and the subsections of course would call the parent contructor and it kept the breadcrumb hierarchy intact. But hey, that’s the fun of programming - different ways to do the same thing to meet different needs! Definitely a good hack to get the juices flowing!

Building Lightweight HTML Graphs
Don’t want to use flash to display a graph? use PHP to figure out the ratios and give you a width and use a table. I’ve done something similar by figuring out the width of a div, making the background a color… and I have used 1×1 pixel images that have been stretched to a certain width and height. It’s a very lightweight download for your user, that’s for sure! Later in the book, there’s a hack for creating a Dynamic HTML Graph that will change without reloading the page.

Put an Interactive Spreadsheet on your Page
This one is so cool — you need to read about it in the book yourself! Lets says, move over Google Spreadsheets! We can do it too!

Create Link Graphs
I call these Tag Clouds, not sure why they call them Link Graphs here in the book — probably, tag clouds has been copy written by some Web 2.0 smartass. Here I am, sue me! This is a unique and visual way to show the popularity of certain words in a group. Rather than a numbered list, this is visual. I had this discussion not too long ago with a group and sadly, most of them didn’t get it. I think if I actually used this sort of technique on a page, I’d include a “What’s this?” link or an alternative view.

Create Dynamic Database Objects
This was very interesting to me because I love Active Record in Rails. This relies on some of the magic of PHP5 to work, probably this is not going to be the best performance code but really — is anything easy the fastest?

Generating CRUD Database Code
Similar to previous, but a create-once and go method, this hack will read from a xml file and create CRUD objects for maintaining your database. These will probably be faster then the previous one -but you’d have to run this script or update manually when your schema updates. Some people hate code generation - some don’t. Pear’s DB_DataObject is a similar concept.

There are a few other nifty database hacks making this my favorite section of the book!

Turn any Object into an Array
Using foreach is my default iteration function and using the PHP 5 iteration interface on any object to give it that functionality is awesome. This is one of the most practical design patterns (other than the other favorite: singleton) that I talk about to people who ask me - what are design patterns and why should I care? Speaking of design patterns - tired of reading a design pattern book and trying to figure out the smalltalk or java code? the design pattern section of the book has diagrams and sample code that you can understand.

Fun Stuff

Build a DHTML Binary Clock
What is that you say? Take a look at ThinkGeek and learn how to make something similar in DHTML. Yes, this is not practical but its fun. Something fun is always a great way to get excited about programming and enjoy yourself.

Generate Your Unit Tests
I put this in the fun section because testing IS fun - I love it. One of the things people (normal people, not wacky test freaks like me) complain about testing is - no time! Here’s a hack that will let you put your test in a comment and running this script on it will pull out those comments and write your test for you. Nifty!

Build GUI Interfaces with GTK
I’ve always wanted to try something with GTK, but never have. This hack shows you how to build a regex expression tool to test and play around with regex. I’ve had programs like this and they are darn handy when you want to do a quick check. So, after you’ve had your fun building this — its practical as well.

Send RSS feeds to your IM Application using Jabber
Depending on your use, this may in fact be practical but I think its rather fun. I have not figured out a use for this myself but the book uses it to send weather forecasts to your IM client. Neat-o

What I didn’t like about this book
not too much in the way of checking input variables. I know, probably they “leave that as exercise to the reader” but noobs and experts alike need to get this ingrained into the head by default. So I suggest also picking up Essential PHP Security

What I like
ER diagrams and control flow - Nice!
Handy size

I’ve only touched on a few of the great hacks and there are many more I also like, but didn’t really want to give away the entire book! I suggest you pick it up and keep it handy. Next time you are bored — flip though and find something interesting!

Comments

Zend Conference, part 2

Its been over a week, seems like I just got back!

Since then, I’ve done alot of thinking about the PHP Community. Last fall I was ready to throw in the towel on PHP and started studying Perl and Ruby. I’ve learned alot and its made me think about problems in terms of algorithms not “which php function do I use to do this” … and being at the Zend Conference has renewed some PHP hope — with the PHP Unit testing, Selenium integration, XDebug and the focus on design patterns and appropriate use of OOP, I think I’ll put my energies into PHP for awhile.

The official start date of the conference was Monday and started with a presentation by Zend about the state of PHP. It was this that made me think, hey … PHP is making good progress. Zend announced quite a few things. Here’s what stood out to me

ZendBox - PHP5 Dedicated server hosting, with the latest Zend software. One of the problems right now is finding hosts that will have the latest PHP software. Its probably been one of the drawbacks to getting into PHP5.

Microsoft - They announced a partership with Microsoft to improve the performance of PHP on IIS. At first I was like ahhhhhhhh… then I was like, ohhh, if PHP performs well on windows it will take more marketshare from ASP.

IBM - They announced another partnership with IBM who is now shipping Zend products on their new ‘System i’ line of servers.

Here’s an interview with Andi about these new partnerships.

Another thing I noticed, and in contrast with YAPC (Yet Another Perl Conference) there is not the bitterness and jealously over Rails success in PHP as is in Perl. There was a few comments about Rails at the PHP conference, but if anything, PHP has been inspired by Rails. Anyways, interesting contrast. The PHP community doesn’t see Rails as much of a threat.

Comments

Zend Conference Report

I’m here at the PHP Zend Conference in San Jose, CA … what a beautiful city! I’ve never actually seen mountians! I don’t think I’ve ever been west of Iowa actually.

I got here saturday and had a lonely lunch by myself in the hotel restaurant, never before had I sat at a resturant and ate by myself! My coworker arrived later that evening and he talked me into trying Sushi. It was ok.. but… given a choice…I’d go for steak anyday. Not a big seafood fan.
Sunday - my coworker and I got adventurous and managed to get downtown and find directions to a mall. It was pretty much your average mall.. I bough a fleece shirt that came in handy on the ride back to the hotel.

Monday - Zend tutorials! I attended

Improving Performance of PHP Applications - Ilia Alshanetsky
It was very good, he’s a good speaker and I learned alot of things. About half of it was more hardware, apache fine tuning … and the other half, specifically PHP. For example, the @ error suppressor operator is actually quite slow. What it does is take the value of error_reporting and store in a variable, set the level to none, do your command, then set the reporting back to what it was. There were many other such things that I didn’t know before.

Essential PHP Security - Chris Shiflett
I thought I knew security stuff, since I’m an avid reader of Chris’s blog. But when I took the PHP Zend Certification practice tests at PHP Arch, I failed the security section!! So I knew I had to go to this one, I learned a few things I didn’t know or really understand before. I will be happy to say, that after this session when I took the practice test again - I passed  the security session!! Hope you are proud of me Chris!

more later ……..

Comments