Archive for the 'PHP' Category

 

PHPUnderControl Install Guide

Jun 22, 2008 in CI, PHP

Lately I’ve been doing some work with PHPUnderControl. It’s based on the Cruise Control Continuous Integration framework, which in turn, is based on Ant. It combines PHPUnit, PHPDocumentor & CodeSniffer to build & test software projects. It works pretty well, though there were a few mysteries along the way to getting an install up and running. I’m in the middle of preparing a comprehensive how-to, but meanwhile, here are a few notes I made about the installation & configuration process.

* There’s no easy way to start and stop Cruise Control. You’ll need to add an init script for starting/stopping/restarting. I’ll post mine here eventually.

* Disc Space: Builds can potentially use up a ton of the stuff. Make sure you have plenty of room, and/or, an easy way to shutdown the CC process if you find yourself running out of disc space.

* Configuration changes require a restart/reload to take affect. This should be second-nature if you’re used to configuring apache etc. Having said this, it caught me out a couple of times.

* You can configure builds to be triggered only where code changes have been merged to your svn sources. This saves heaps of unnecessary disc writing etc.

* Be careful using relative file paths. I’m still looking into how Ant handles file paths, but it definitely seems to be inconsistent. I’m using absolute paths in my build.xml & config.xml config files.

* If commands in your build process are failing, check the contents of /path/to/cruisecontrol/cruisecontrol.log - This will detail the exact commands being run by cruisecontrol.

* To test your build.xml configuration for a specific project run /path/to/cruisecontrol/apacheAnt-Version/bin/ant from within the project directory. Do this before restarting the cruisecontrol process to avoid builds failing because config errors.

Sebastian Bergmann Visits Melbourne!

May 31, 2008 in PHP

Arjen Lentz, though Open Query, is hosting a training seminar with Sebastian Bergmann:

I’m proud to announce that after significant wrangling (just suggesting did the trick, actually ;-), I’ve found Sebastian Bergmann willing to visit Australia, and teach a 3-day workshop “Quality Assurance in PHP Projects” (http://openquery.com.au/training/php_project_qa).
It’s scheduled 4-6 August in Melbourne.

The three-day workshop will introduce the attendees to writing unit tests for the backend and system tests for the frontend of a web application as well as managing the quality from development to deployment and maintainance using tools such as PHPUnit, Selenium RC, phpUnderControl, PHP_CodeSniffer, and PHP_Depend.

Sebastian (http://sebastian-bergmann.de/) is the author of PHPUnit (http://www.phpunit.de), and long-time contributor to PHP itself.

Pricing is AUD 1695 + GST.
Since this is a workshop, the number of seats will be limited to 10-12.
Registrations before June 15th receive $50 off.

Around the course dates Sebastian will also be available for consulting and/or in-house training in the Australia and New Zealand region, simply contact Open Query to discuss.

PHP Melbourne - May Meeting

May 02, 2008 in PHP, PHPMelb, Random

www.PHPMelb.org

Thursday May 8th, 7pm
580 St Kilda Road Melbourne  
 
CodeSniffer. You need it. You want it. Be there. - Avi Miller - 7:00 - 7:45 pm
 
PHP_CodeSniffer is a PHP5 script that tokenises and “sniffs” PHP and JavsScript code to detect violations of a defined set of coding standards. It is an essential development tool that ensures that your code remains clean and consistent. It can even help prevent some common semantic errors made by developers.
This talk will show you how to use PHP_CodeSniffer to ensure your PHP and JavaScript adheres to your chosen coding standard. We will also look at how to create a new “sniff” that will check a particular coding standard requirement.
Avi is the MySource Matrix Product Evangelist for Squiz. As Product Evangelist, he is contractually obliged to deeply love MySource Matrix, a state greatly enhanced by strict adherence to coding standards (great plug!). Additional daily duties include pre-sales consulting, business analysis, information architecture, hand-holding, nappy changing and other professional tasks.
 
 
MySQL Stored Procedures -  Ben Balbo - 8:00 - 8:45 pm
 
A recent addition in MySQL 5, stored procedures allow us to automate or program our way out of many tasks directly on the server rather than having to write external scripts to do complex manipulation of data. Stored procedures can also be used to simplify data validation or enforce access control. In this talk, Ben will use a few simple stored procedures and views to demonstrate their power and usefulness, not to mention the benefits that can be reaped when the database needs refactoring.
 
Socialising & Networking 9:00pm onward

Pizza, softdrink, tea, coffee and comfy swivel chairs will be provided
with compliments of our major sponsor, Hitwise.

PHP Melbourne - December Meeting

Dec 03, 2007 in PHP, PHPMelb

When

Date: Thursday 13th December 2007
Time: 7.00pm

Where

Hitwise Melbourne
Level 6, 580 St Kilda Rd
Melbourne

With things starting to wind down for holidays, we’re holding a social event this December. Ben Balbo & Ben Cornwell will be presenting a recap of highlights from the 2007 Open Source Developers’ Conference, Ben Balbo will be presenting a lightning talk, we’ll be screening Antitrust (a film by Peter Howitt) with a generous supply of popcorn & coke, then heading to the pub to toast the end of another busy year.

OSDC Recap + Patents Rock! - A Lightning Talk ™ by Ben Balbo - 7:00 - 7:15 pm

Come along to hear the highlights from OSDC 2007, and why Ben Balbo likes patents - in 5 minutes or less!

Antitrust - A film by PeterHowitt - 7:15 - 9:00 pm

This movie is the fictional story of computer programming genius Milo Hoffman after graduating from Stanford and getting out into the competitive world of computer software. In his contemplation of where to begin his career, he is contacted by Gary Winston whose character is loosely based on Bill Gates. Winston is the CEO of a company called NURV, and they are on the brink of completing the global communication’s system, Synapse. They need Hoffman to help them meet their launch date, so after much thought and with the full support of his girlfriend Alice, he accepts the job. Tragedy soon after strikes and Milo becomes suspicious of the company he has been wrapped up in. He learns that trusting anyone could be a mistake, and that nothing is as it seems. [www.imdb.com]

Socialising & Networking - 9:00 pm onward

Pizza, softdrink, tea, coffee and comfy swivel chairs will be provided
with compliments of our major sponsor, Hitwise.

PHP 6 Installation Guide for Ubuntu 7.10 (Gutsy Gibbon)

Nov 18, 2007 in PHP, Random

It’s no longer news that next release of PHP is on it’s way. If you’re like me, you’re probably pretty keen to start experimenting with the new features, enhanced OO, and rejoice at the demise of ‘register_globals’. The only problem is: PHP 6 doesn’t have packaged releases just yet. In other words, if you want to start working with PHP 6, you need to compile it from source. To most Linux nuts, compiling source code is an everyday task. However if you’re not familiar with rolling your own binaries, the process can seem daunting, and with that in mind I decided to write a guide to compiling PHP 6.

Environment

I wrote this guide specifically for Ubuntu 7.10, and while most steps will work successfully for most flavors of Debian Linux, bear in mind that some commands and file system locations may need to change depending on the system you’re running. You’ll need administrative privileges to execute many of the steps described in this guide, so if your account isn’t already on the sudoers manifest, you might want to correct that first. I recommend using a virtual machine as a sandbox for experimental environments. This way, should anything go toes-up along the way, you won’t have damaged your regular working environment (VMWare server is free and does the job nicely).

Some Prerequsites

Before we can get started compiling PHP, there a few tools needed during the installation process that we’ll need to install first:
* libtool - GNU shared library manager
* bison - grammar parser
* flex - another source code parser
* re2c - lexical scanner
* g++ - GNU compiler collection (the c compiler)
* libxml2-dev - XMl libraries (a non-bundled dependency of PHP)
* autoconf - configures source code for compiling
* automake - used to build compiler instructions (’make’ files)

To install these packages, fire up a terminal window and enter:

sudo apt-get install libtool bison flex re2c g++ libxml2-dev autoconf automake

Once that’s done, you’ll have all the tools you need to compile ICU (International Components for Unicode) & then PHP 6.

Compiling and Installing ICU

One of the major features coming in PHP 6 is support for Unicode, and the ICU library is what provides unicode capability to PHP. To compile & install ICU, run the following commands in your terminal session:

mkdir ./icu_source
cd icu_source
wget ftp://ftp.software.ibm.com/software/globalization/icu/3.6/icu4c-3_6-src.tgz
tar -xf ./icu4c-3_6-src.tgz
cd icu/source
sudo mkdir /usr/local/icu
sudo ./configure --prefix=/usr/local/icu
sudo make
sudo make install

Install Apache

This step is optional, but if you’re like 99% of PHP developers (myself included), chances are you’ll want to use your PHP 6 install with Apache. Note that you need the non-threaded version of apache - because while PHP is not thread-safe, many of the PHP extension libraries are not. To install non-threaded Apache, run the following command:

sudo apt-get install apache2-mpm-prefork

Getting PHP 6 Source Code

The best place to get PHP 6 source code is from http://snaps.php.net/. The version I’m using in this guide was built on 17th of November 2007. Before carrying out these steps, you might want to check if a new version is available and use that instead. Here’s how to download & unpack the PHP 6 source code:

cd
mkdir ./php_source
cd ./php_source
wget http://snaps.php.net/php6.0-200711170930.tar.bz2
tar -xf ./php6.0-200711170930.tar.bz2
cd ./php6.0-200711170930

PHP 6 Configuration

You need to configure your PHP build so the compiler knows which libraries and extensions you want supported. This is done using a configure script, like this (no need to use new lines, I’ve just done that to make the command easier to read):

sudo ./configure --prefix=/usr/local/php6
--enable-bcmath
--enable-calendar
--enable-dba
--enable-exif
--enable-ftp
--enable-gd-native-ttf
--enable-soap
--enable-sqlite-utf8
--enable-wddx
--with-apxs2=/usr/bin/apxs2
--with-gettext
--with-iconv
--with-openssl
--with-pcre-regex
--with-pdo-sqlite
--with-sqlite
--with-zlib
--enable-zip

You don’t need to compile PHP 6 with support for *all* these libraries & extensions, however this is the default set of configuration options being used by the QA team doing the testing on PHP 6, hence this is also the configuration I’m recommending.

Heads-Up Apache Users!

Due to a quirk of apxs2 (the tool that builds and links the PHP executable module for apache), you’ll need to hack a commented-out dummy LoadModule directive into your httpd.conf. You can get more info on why this is necessary from (http://www.trachtenberg.com/blog/2004/08/25/apxs2-causes-php-install-to-barf-under-suse-91-and-apache-2/). It’s a shame apxs2 doesn’t have a nicer solution, but at least there’s a simple work-around. Open up you httpd.conf file in your favourite text editor (here, I’m using vim):

sudo vim /etc/apache2/httpd.conf

Add the following line, save and close the file:

#AddModule foo_module /usr/lib/apache2/modules/foo.so

The Crunch

Once the configure script has finished running (and you’ve put the dummy entry into httpd.conf), it’s time to compile the binaries (this process should look familiar from compiling & installing ICU). Just run the following commands.

sudo make
sudo make install

Note that the steps above can take a while to run - usually about 10 to 15 minutes, depending on the specs of your computer.

PHP 6 is Now Yours!

If you’d like to run a quick check to test everything has gone according to plan, do this:

/usr/local/php6/bin/php --version

You should see something like the following:

PHP 6.0.0-dev (cli) (built: Nov 17 2007 22:57:15)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2007 Zend Technologies

Hooking Up With Apache

Lastly, if you want to use PHP 6 with Apache, you’ll need to configure the web server to use your swanky new PHP 6 binaries. First, add the configuration directives (again, I’m using vim here, but feel free to use whatever text editor you’re comfortable with):

sudo vim /etc/apache2/mods-available/php6.conf

Now add the following configuration section to the php6.conf file, save then close:

<IfModule mod_php6.c>
  AddType application/x-httpd-php .php
  AddType application/x-httpd-php-source .phps
</IfModule>

Now you need to tell Apache where to find the PHP 6 module:

sudo vim /etc/apache2/mods-available/php6.load

Add the following line, then save and close the file.

LoadModule php6_module /usr/lib/apache2/modules/libphp6.so

At this point, it would probably be a good idea to remove the ‘hacked in’ LoadModule directive from /etc/apache2/htttpd.conf (See the section above called ‘Heads-up Apache Users’). It shouldn’t break anything if you don’t though. Apxs2 will have also added an additional LoadModule for php6 below the dummy entry - it’s safe to remove this as well, because we’ve just added the same thing to in the php6.load file.

Once you’ve finished editing the apache config files, enable the new module by running

sudo a2enmod php6

Finally, restart Apache so the configuration changes take affect:

sudo /etc/init.d/apache2 restart

If you knock together a quick script calling phpinfo(), you should now be seeing “PHP6.0.0-dev”!

Enjoy!

By the way: If you’re interested in hearing exactly what’s coming in PHP and you’re in Brisbane next week, come along to the Open Source Developers’ Conference, where I’ll be giving a presentation: “PHP 6 - What’s In, What’s Out and Why”

Importing RSS Feeds into OSX Mail

Nov 16, 2007 in OSX, PHP

I have about 150 feeds that I had previously been reading with Thunderbird. Since getting my hands on a MacBook Pro, I’ve switched to using Mail.app as my mail client (it’s nice!). The Problem is that Mail.app doesn’t provide an easy way of importing OPML (the format in which Thunderbird will export your RSS feeds).

Rather than skim through the exported OPML file & copy-paste each individual feed address into Mail.app, I (hastily) knocked together a php script - it doesn’t import directly into Mail.app, but rather puts your feed addresses into a simple text file that you can then copy-paste in one go (Mail.app -> File -> Add RSS Feeds ) .


#!/usr/bin/php
<?php

$file = "./MyThunderbirdFeeds.opml";
$doc = simplexml_load_file( $file );

$outfile = "./output.text";
$handle = fopen( $outfile, 'w' );

foreach( $doc->body->outline as $section )
{
	foreach( $section->outline as $feed )
	{
		fwrite( $handle, $feed["xmlUrl"].”\\r\\n” );
	}
}

fclose( $handle );

?>

Hopefully it might help someone out.

A few things to note:

  • You need to give the script execute permissions before it’ll run (
    chmod 755 ./extractScript.php

    )

  • You need to run the script in the same directory as the OPML export file
  • The script expects an export file called ‘MyThunderbirdFeeds.opml’ (but you can change that by altering the value given to $file)
  • Your feeds get dumped into a file called ‘output.text’ (again, change that if you want by putting a different file name into the $outfile variable)

PHP Melbourne September Meeting

Sep 03, 2007 in PHP, PHPMelb

Testing with Selenium Core - Jason King - 7:15-8:00 pm

Selenium is a javascript based website testing package that allows you
to create tests to determine if your website is functioning properly.

The use of selenium core, and the firefox addon for selenium will be
demonstrated so you will be able to write and run your own tests.

I will also be going through how to get the results of selenium tests,
and store them in a database for future analysis.

XUL is Cool! - Christian Hope - 8:15-9:00 pm

Mozilla’s XUL is a user interface markup language used in cross platform applications such as Firefox. XUL is based around a similar technology stack to your every web development, which should make it relatively easy for web developers to pick up.

Christian will be covering the basics of XUL development including how to create Firefox extensions.

When/Where

Date: Thursday 13th September 2007
Time: 7.00pm

Address

Hitwise Melbourne
Level 6, 580 St Kilda Rd
Melbourne

PHP Melbourne August Meeting

Jul 24, 2007 in PHP, PHPMelb, Presentations

A return to ‘normal’ after July’s Microsoft theme ;)
When/Where

Date: Thursday 9th August 2007
Time: 7.00pm

Address

Hitwise Melbourne
Level 6, 580 St Kilda Rd
Melbourne

Website Usability Testing - Sandrine Balbo - 7:15-8:00 pm

In this presentation on Web Site Usability Testing, Sandrine will cover:

* Why test? Setting testing objectives
* Setting testing objectives
* Choosing appropriate testing methods (expert reviews, surveys,
observations, etc)
* Determining when to test
* Determining the number of users to test (if any)
* Attaining both internal and external feedback
* Considering the cost vs benefit of testing

Unit Testing with PHPUnit - Ben Cornwell - 8:15-9:00 pm

Unit testing is a programming technique that aids in the development of robust, reliable code and gives developers piece of mind in knowing that their code functions as expected. Based on JUnit, PHPUnit is the defacto standard unit testing framework for PHP: it is easy to install, straight-forward to work with, and actively maintained.

This presentation will cover:

* Introducing PHPUnit

* Installing PHPUnit

* Writing PHPUnit test cases

* Running your tests

* Using test suites to ‘group’ your tests, and

* Using mock objects

Socialising & Networking - 9:00pm onward

After the meeting we’ll be moving downstairs to the Cartel Bar, for an informal chat over a few cold ones.

Pizza, softdrink, tea, coffee and comfy swivel chairs will be provided
with compliments of our major sponsor, Hitwise.

Follow up on my Silverlight presentation last week

Jul 19, 2007 in PHP, PHPMelb, Presentations, Silverlight

In case you’re keen hack around with code used in my PHPMelb presentation last week, you can get the source here.

Perhaps you didn’t come to the meeting, but just want to see how lame my graphic design skills are… ;)
I’m planning to get it running somewhere public on my server eventually, but need to dist-upgrade first to get some updated PHP packages.

In other news, I’ve got three talk proposals under consideration for OSDC 2007 being held in Brisbane this November. More on that soon, assuming at least one of them is accepted.

PHP Melbourne July Meeting

Jul 08, 2007 in .NET, PHP, PHPMelb, Silverlight

This thusrday (12th July 2007), I’ll be presenting some of the discoveries I’ve made in the last few weeks playing around with Silverlight & PHP at the Melbourne PHP User Group. Dave Glover, the local Microsoft Developer Evangelist, will be coming along to talk about Expression Studio and Visual Studio Orcas.
From phpmelb.org:
When/Where

Date: Thursday 12th July 2007
Time: 7.00pm

Address

Hitwise Melbourne
Level 6, 580 St Kilda Rd
Melbourne
Expression Studio Round Up - Dave Glover - 7:15 - 8:00pm

Coinciding with the official release of Silverlight, Microsoft have recently launched a bunch of brand new tools for web development work called Expression Studio, with the express purpose of enabling collaboration between developers and designers in creating standards based websites. Featured in this suite of applications is Expression Web, a web authoring tool with comprehensive support for CSS and… PHP!

Dave Glover will be coming along to give us the low-down.

Doing Silverlight with PHP - Ben Cornwell - 8:15 - 9:00pm

Silverlight is Microsoft’s offering in the world of rich-client platforms like Flex and Open Laszlo. Based on XAML, Silverlight provides a framework for creating user interfaces for the web that are standards compliant, great looking and encompass complex animation, audio and video.

Ben’s presentation will provide an introduction to Silverlight and a live demonstration of how to create Silverlight interfaces with PHP and AJAX.


Socialising & Networking - 9:00pm onward

After the meeting we’ll be moving downstairs to the Cartel Bar, for an informal chat over a few cold ones.

Pizza, softdrink, tea, coffee and comfy swivel chairs will be provided
with compliments of our major sponsor, Hitwise.