Posts Tagged ‘php’

Alex’s PHP micro-optimization tips

Tuesday, March 10th, 2009

Just a quick link to Alex Netkachov’s PHP micro-optimization tips; via planet.php.net. Note these are mico-optimization tips – they won’t dramatically speed up an ineffectual algorithm.

Book Review: Learning Facebook Application Development

Friday, August 29th, 2008

It’s been a while since I posted a review about a packt published book.
I was sent a copy of “Learning Facebook Application Development” by Hasin Hayder and Dr Mark Alexander Bain a while ago. The by-line description of the book is “A step-by-step tutorial for creating custom facebook applications using the Facebook platform and PHP”. It is precisely that.

Here’s my review of it:

The book was published prior to Facebook’s facelift but this doesn’t really impact on the usefulness of the book.
An overview of FBML, FQL, FBJS (a restricted subset of JavaScript and enforced for security reasons) are given along with information on how to use the test consoles, publish to news feeds, some multimedia aspects of what can be done in Facebook applications and more.

Happily the book focuses on using PHP5 for developing Facebook Applications – while there are classes available for developing FB apps with PHP4 there really is no point in doing so; especially now that official support for PHP4 was withdrawn last month.
MySQL appears to be the database system of choice for the examples and Linux/Unix oriented solutions for scheduling tasks to occur regularly are given – some Windows screenshots feature in chapter one with regard to setting up the client libraries for local development but other than that everything else is unix-centric.

I found “Facebook Application Development” more useful than facebook’s own documentation with regard to the main aspects of developing a Facebook application – it is written well and easier to follow than the online documentation and while it is true to say that the Facebook Platform is evolving I am of the opinion that Heyder and Bain’s work will still be applicable for a long time.

Is PHP vulnerable software?

Tuesday, August 26th, 2008

Thanks to Ivo Jansch, I spotted Matt Assay mentioning in his article on cnet that PHP headlines in IBM’s list of most vulnerable software and I have to say this is complete balderdash on the part of IBM.

He quotes from the report:

Another commonality between these three vendors is that they are all written in PHP. If we look back over last year’s disclosures and apply the new CPE methodology to them, we would uncover another newcomer to the top five list, PHP itself, which would rank number four in the 2007 top five vendor list.

What are featuring in IBM’s top ten of vulnerable that makes the report insinuate that the PHP language is a security risk are Jooma, WordPress and Drupal. How PHP would feature in a list of “vendors” is beside the point – if a construction company were to build a house where the windows don’t close fully, the security alarm doesn’t work and where bare wires are exposed you don’t “blame” the windows, alarm system and cabling. The responsibility rests with the construction company and/or the individual contractors hired by that company. Similarly, we can’t “blame” PHP for bad software architecture and security risks present in Joomla, WordPress or Drupal – the onus is on the software developers and architects to design secure [web] applications.

They should, at the least, ensure input data is of the expected type, of certain values; handle uploaded files in a secure and cautious manner that they don’t overwrite files crucial to the health/security of the system running the application or the application itself; use an audit trail for checking against attacks, ensure security in depth against SQL injections, Cross Site Vulnerabilities, Command Injection and … I could go on but won’t – search for php security best practices, get the Zend PHP 5 Certification Study Guide, check out the library resource at the PHP Security Consortium.

Now where’s ruby, cobol, C, and z80A assembly language on that list? And why is Linux mentioned there as a vendor?

Book Review: Learning jQuery

Saturday, July 5th, 2008

Packt sent me a copy of “Learning jQuery” by Jonathan Chaffer and Karl Swedberg. jQuery is a javascript library that I have been using on and off and was delighted to be given a chance to review this book and have a chance to read through and learn about jQuery in a less urgent manner than I had initially.

With a tag-line of “Better Interaction Design and Web Development with Simple JavaScript Techniques” and some 376 pages long (split into 10 chapters, along with three appendices) the book excels at fulfilling that promise.

From the chapter on Getting Started through selectors (css, dom, xpath), Chaffer and Swedberg examine and show how to use jQuery for animations, ajax and manipulating tables to the all important client-side form validation with disarmingly concise eloquence and skill. They also detail how to use and develop jQuery Plug-ins.

Any of the required server-side code examples, for the AJAX chapter, are in PHP but that doesn’t make the book any less relevant or more specialised towards PHP – it should be trivial to rework them for any language.

The authors use an example based approach and this works very well as they continue to progressively enhance each example with additional features and functionality – you can really see their shopping cart and image carousel examples really build up into very well formed examples of what can be done with jQuery.

If you haven’t already been turned on to jQuery by it’s excellent on-line documentation and fluent API (method chaining), this is the book that will do it.

There is one caveat though: “Learning jQuery” was written for jQuery v1.1 and published in June 2007; version 1.2 of jQuery was released four months later with some substantial changes to the API.
This doesn’t matter all that much to be honest; obviously this book doesn’t cover what’s available in v1.2 but until there’s a second edition of this book (and wouldn’t that be great?) you won’t find a better book on the subject.

Book review: PHP Objects, Patterns and Practice (second edition)

Tuesday, June 3rd, 2008

Apress sent me a copy of “PHP Objects, Patterns and Practice (second edition)” by Matt Zandstra to review.

As hinted in the title, this near 500 page tome is split into three parts: objects, patterns and [best] practice.
The section on objects covers the basics and then the advanced features of object oriented facilities in PHP and tools such as namespaces, autoloading and the reflection classes along with design basics, class scope, encapsulation, polymorphism and some UML.
The patterns section is obviously inspired by “The Gang of Four” (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) and covers what design patterns are, enterprise patterns, database patterns and also the basic patterns such as the factory, fascade, decorator and composite patterns along with a few more. This section is far from comprehensive, but is a good start. (If Patterns do interest you, and they should, have a look at patternsforphp.com)
The last section, focuses on PEAR (including writing your own packages and setting up your own PEAR channel), phpDocumentor, unit testing with phpUnit, version control with CVS (which struck me as a bit odd – I had expected subversion to be covered either instead of or along with CVS) and setting up automated builds with phing.

While being an easy read, this is a well written, serious book and is aimed squarely at enterprise-level developers and software engineers who make their living through the development and architecture of solutions developed in PHP.
Any PHP developer wishing to improve his skills should get a copy.