Book review: PHP Team Development

October 15, 2009

A representative of Packt Publishing contacted me to do a review of their book PHP Team Development by Samisa Abeysinghe. Over the years, PHP has evolved into a programming language that can be used for much more than just simple web applications. And organising development processes and software architectures are becoming ever more important. So books that go beyond pure PHP programming are of interest to me. So I agreed to do a review.

The author uses the first chapter to tell us that software is complex. He then introduces different aspects of the software development process that can be used to deal with this complexity. These aspects are elaborated upon in the remaining chapters. He discusses topics that are popular at the moment, like design patterns, frameworks, agile development, collaboration and continuous integration.

Especially the MVC design pattern plays an important role in the book. The author tries to explain how MVC can help to divide responsibilities in teams. A whole chapter is dedicated the pattern and another chapter on MVC frameworks in PHP. Unfortunately, this is also where the weakness of this book shows. The author maps the View to the Presentation Layer, the Controller to the Business Logic Layer and the Model to the Data Layer of an application. This explanation of the MVC pattern is quite common, but also inaccurate, because the Model should also contain (if not most) business logic. Often referred to as "Skinny Controller, Fat Model".

Moreover, the author insist on using a MVC framework as a basis to split responsibilities in teams:

"So as long as all of M, V, and C, work on their own, it is only a matter of putting them together and they should work seamlessly."

The use of MVC frameworks is in a lot of cases a good thing to do. But he also discards Drupal as just a CMS and not a framework. And therefore it cannot be used for building enterprise-level applications as a team. A lot of developers would beg to differ. I am quite sure that Drupal, and other CMS type systems e.g. Typo3 or eZ Publish, have been used more often in building complex applications, than "leading" (according to the author) frameworks like Limb, phpDrone, PHP Work or ZNF.

Apart from the list of PHP frameworks there wasn't really a lot PHP specific information in the book. Tools like PHPDocumentor, PHPUnit, XDebug, PHP_CodeSniffer or Phing aren't even mentioned.

Throughout the book I had the feeling that the author based his views more on hearsay, than on proper research. Topics like object-oriented programming, agile development, extreme programming, SCRUM, continuous integration don't go very deep. And he hardly refers to the people, books or articles behind the different theories and methodologies. I can understand that the author doesn't want to get theoretical. But his advice is also too general. Practical examples are rare.

Also missing is how different types of organisations can influence a development team. Not every team works on a single product inside a firm. Some teams consist of a mix of internal and external employees. Team members might even be working on different continents. Or how do I organise a completely virtual team, which is typical for open source projects. Hey, some of us even work on multiple projects at the same time.

"PHP Team Development" presents a quick 'n dirty guide on team development. For beginning programmers it might be useful. But more experienced programmers don't have to feel guilty for not reading the book.

Why does the Meaningo search engine not let you to find anything?

October 14, 2009

After a mention of the Meaningo search engine on The Next Web, I went to the site to have a try. Turns out they don't want you to find anything, because there is no search form.

Screenshot of the Meaningo home page

And even if you are able to find a form, it is apparently a good idea to hide the submit button:

<input id="applicationFormSubmit" name="applicationFormSubmit" type="submit" style="display:none;" />

All this needs to have a nice table layout, of course.

I guess startups still don't care about accessibility.

Well, if you turn on javascript everything works. Progressive enhancement anyone?

Creating your own SSL certificates

October 7, 2009

If you need a SSL certificate, it is quite easy to create them with OpenSSL. Of course, every browser will issue a warning for self-signed certificates.

Create a private key (4096-bit):

openssl genrsa -des3 -out privkey.pem 4096

Create a certificate request:

openssl req -new -key privkey.pem -out cert.csr

Create a self-signed certificate (valid for 10 years):

openssl req -new -x509 -key privkey.pem -out cacert.pem -days 3652

Decrypt a private key (to be able to (re)start the webserver without requiring a certificate password):

openssl rsa -in privkey.pem -out privkey.pem

Using deprecated code in PHP5.3

August 12, 2009

When PHP5.3 was released I tested several open source projects on their compatibility with this new version. To my surprise a lot of them are not.

To clean up PHP some directives, functions or features that are going to be removed in PHP6. This will get rid of some potentially insecure or redundant features. Examples are the register_globals directive and the ereg regular expression functions. I haven't used these for at least the last 2 years, because I know that they are going to be removed in the future.

To detect the use of these deprecated features the new error level E_DEPRECATED has been introduced in PHP5.3. This enables developers to detect incompatibilies with the future release and learn how to improve their code. Because one can set the error reporting level, the deprecated messages can be switched off. This way developers are not required to immediately adapt their code, if they want to use PHP5.3.

Or so I thought. In php.ini you can disable DEPRECATED messages by setting which error levels should be reported:

error_reporting = E_ALL & ~E_DEPRECATED

Turns out that a lot of programmers are setting the error reporting inside their scripts/libraries, e.g. error_reporting(E_ALL). Probably they wanted to avoid STRICT messages. This takes precendence over the setting in php.ini. Meaning you will still get DEPRECATED messages. Thank you very much.

So now I have to decide what to do:

  • Remove the hard coded error_reporting() functions;
  • Rewrite the use of deprecated directives, functions and features;
  • Stick with PHP5.2

Linux distributions are still shipping PHP5.2 in the near future. So I probably will go with that temporary solution for now.

[Update] It is also a good idea to activate the "allow_call_time_pass_reference" PHP directive. In Apache you can add the following code to your VirtualHost or .htaccess to make PHP5.3 backward compatible.

php_flag allow_call_time_pass_reference On
php_value error_reporting "E_ALL & ~E_NOTICE & ~E_DEPRECATED"

PS. In PHP6 E_STRICT will be included in E_ALL. So you have been warned!

Getting video in Skype to work with openSUSE 11.1+

July 19, 2009

Although I prefer to use free and open source software, but sometimes you cannot get around proprietary software. One example is Skype. Lots of people are using it and luckily Skype took the effort to create a Linux version. Being at version 2.0, Linux support seems not to be a priority, when the version for Windows is at 4.1. But at least you are not forced to run it under Wine.

Unfortunately, upgrading from openSUSE 11.0 to 11.1, my Logitech webcam stopped working with Skype. It worked without any problems in 11.0. After some searching, I found that Skype is using the video4linux (v4l) library.

[Update] This also applies to openSUSE 11.2 + 11.3.

Recommended steps were:

  1. Install v4l with: sudo zypper install libv4l
  2. Start Skype with: LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype

To me starting Skype from the command line seemed a bit to cumbersome. So I looked for a more user-friendly and system-wide solution. I did not like to change the menu entry, because it is part of the (un)install procedure. Knowing that you can set environment variables in user profiles, I started to look in /etc/profile.d and quickly found the answer.

Create the script:

/etc/profile.d/skype.sh

Put in the following rule:

export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so

Logout of your openSUSE account and login again and you can use Skype as before.