Archive for the ‘pear’ Category

Book review; “UML 2.0 in Action: A project-based tutorial”

Monday, May 26th, 2008

A while ago I received, from packt, a copy of “UML 2.0 in Action: A project-based tutorial” by Patrick Grassle, Philippe Baumann, Henriette Baumann. This book certainly lives up to it’s byline of being “a detailed and practical walk-through showing how to apply UML to real world development projects”.

UML is a standardized visual specification language for object modeling and is short for “Unified Modeling Language” that includes a graphical notation used to create an abstract model of a system, referred to as a UML model. There are many software tools available which can be used for code generation and reverse engineering, such as the new PEAR package PHP_UML which generates a UML representation of existing PHP source code.

This book assumes no prior knowledge of UML and this works very well. It is by no means comprehensive but that it’s what the authors set out to write – this book is focused on being a practical tutorial for learning the essentials of modelling business systems, IT systems and systems integration – no more, no less. It does this admirably and I’ll recommend this book as a reference and introduction for developers performing system analysis and design activities.

Validation in Depth – a retort to using just regular expressions

Monday, May 26th, 2008

I’ve noticed that Richard Heyes, who professes himself to be a php guru, deleted my comment on his “Some common regular expressions” posting which simply pointed out his expressions didn’t quite do the job and suggested a few PEAR packages that should be used instead of the expressions that he proffered for the following:

  • Email addresses
  • Usernames
  • Telephone numbers
  • Postal codes
  • IP addresses
  • An SQL date
  • A domain
  • A UK sort code

Why he deleted it is anybody’s guess – he deleted a few others too.

Anyway, for the record I thought I’d reproduce my comment from memory (I didn’t think to make a backup copy for obvious reasons but hey nobody expects the Spanish Inquisition).

The problem with just relying on a regular expression for validating data is there is no “defense in depth” to that solution. Sure the expression might catch the main bulk of data entered but there’s always going to be data that get’s through.

For example a simple regular expression for validating phone numbers won’t catch area codes or country that don’t actually exist and another that’s used for validating entered dates might not catch leap-year based exceptions.

  • Email addresses – use the PEAR Validate package for email address validation
  • Usernames
  • Telephone numbers – use Validate_UK; this package will also validate UK specific details such as:
    • SSN (National Insurance/IN)
    • Postal Code
    • Sort Code
    • Bank AC
    • Car registration numbers
    • Passports
    • Driver license
  • Postal codes – use Validate_UK or counterpart as appropriate.
  • IP addresses – use the Net_Check PHP5 port of Net_CheckIP or the original Net_CheckIP for php4 if you really have to.
  • An SQL date – what Richard provided validates the form of a date in yyyy-mm-dd format but not that the entered value is a date; one could enter 2008-13-42. Again, I’d suggest using the Validate package.
  • A domain – You could, in theory use the Validate package’s uri method, prefixing the domain with ‘http://’.
  • A UK sort code – Validate_UK.
  • If you follow these suggestions it should make your input validation more robust than simply relying on regular expressions and nothing more.

    The Date_Holidays package, a pack of splitters and a pear tree.

    Friday, May 9th, 2008

    Some of you may know that I am a lead developer of the pear Date_Holidays package.

    Date_Holidays helps you calculate the dates and titles of holidays and other special celebrations. This is all driver-based so it is easy to add new drivers that calculate a country’s holidays.
    Until recently all of these drivers for individual countries were grouped together into one package.

    We decided that this one package should be split into subpackages: one subpackage per region/country. Some advantages of this approach are that each driver / filter / subpackage gets it’s own stability and version number – we wouldn’t have to keep increasing the version number of Date_Holidays each time a new driver is added or when an existing driver gets a significant number of fixes.

    Therefore we now have subpackages such as Date_Holidays_Austria, Date_Holidays_Brazil etc etc.

    If you want to use the new set of [sub]packages, the simplest thing to do is uninstall the package that you have installed:

    $ sudo pear uninstall Date_Holidays

    and then install the new package, with a group directive which will install all subpackages:

    $ sudo pear install Date_Holidays#all

    There’s a new planet – planet.php.ie

    Wednesday, April 16th, 2008

    After a bit of discussion on the php.ie mailing list, Kae Verens and David Coallier set up http://planet.php.ie to bundle together blog postings from people within the Irish PHP community – a big thank you is deserved for them.

    If you want your blog added to this ‘planet’ please contact either Kae or myself.

    On other news, I’m going to start documenting PEAR_Size real soon.

    What I’ve done recently

    Friday, April 11th, 2008

    Travis asked What did you do today? recently – and what he did all sums up to an amazing level of work.

    I felt a need to answer this question myself. This is what I’ve been keeping myself busy with recently:

  • Released version 0.18.0 of Date_Holidays – this includes drivers for Iceland, Romania and the Ukraine along with some bug fixes.
  • Released version 1.0.1 of Validate_IE, focused solely on adding validation for the 089/Tesco mobile phone network.
  • Released version version 0.1.2 of PEAR_Size. This includes integration with the PEAR command.
  • Wrote a review of CodeIgniter for Rapid PHP Application Development.
  • Kick-started a discussion on aggregating blogs of people in the Irish PHP Users Group.
  • I’m trying to decide what to do with the codebase for the website of the Irish Linux Users Group – at the moment it’s all rather cobbled together and isn’t providing as much functionality to the community as it could. I’ll most likely migrate it over to using a more general purpose framework plus ILUG/User Group specific components.
  • Book Review: CodeIgniter for Rapid PHP Application Development

    Thursday, April 10th, 2008

    A while ago packt sent me another book to review – this time it was “Code Igniter for Rapid PHP Application Development” by David Upton.

    Similar in size to the PEAR Installer Manifesto, this book weighs in at 240 pages, is aimed at developers new to CodeIgniter, and is split into 15 chapters:

    1. Introduction to CodeIgniter
    2. Two Minute’s Work: Setting up a CodeIgniter Site
    3. Navigating your site
    4. Using CI to Simplify Databases
    5. Simplifying HTML Pages and Forms
    6. Simplifying Sessions and Security
    7. CodeIgniter and Objects
    8. Using CI to Test Code
    9. Using CI to Communicate
    10. How CI Helps to Provide Dynamic Information
    11. Using CI to Handle Files and Images
    12. Production Versions, Updates, and Big Decisions
    13. Instant CRUD – or putting it all together
    14. The Verdict On CI
    15. Resources and Extensions

    Chapter one is a bare-bones introduction to what CodeIgniter is and why it was initially developed.
    Chapter two details how to set up an initial site with CodeIgniter.
    Chapter three introduces the reader to the concept of the MVC pattern, what it is about and how CodeIgniter implements it.
    Chapter four details the ActiveRecord class for interacting with databases.
    Chapter five shows the reader how to specify a View, how to nest them for better reuse and demonstrates CodeIgniter’s Validation class.
    Chapter six is about session management and securing applications.
    Chapter seven, if the reader requires a refresher, explains Object Oriented Programming and through some examples shows that CodeIgniter does not take advantage of PHP5′s enhancements in that regard. It also looks at the object model in CodeIgniter.
    Chapter eight details how to perform unit tests, benchmarking, profiling and how to use mock database objects for test purposes.
    Chapter nine is about various machine-to-machine communications: FTP, mail and using xml-rpc for providing webservices.
    Chapter ten focuses on internationalization, caching and string manipulation.
    Chapter eleven is about file uploads, downloads, compression and image manipulation.
    Chapter twelve discusses various topics relevant to migrating your code from your development servers to production.
    Chapter thirteen details CRUD operations in CodeIgniter.
    Chapter fourteen takes an objective look at what the book has covered as regards CodeIgniter’s abilities and what the author chose to not cover – one admitted omission is a lack of focus on AJAX.
    Chapter fifteen, the last one, provides a list of resources and extensions that the dear reader will want to investigate. These include, but are not limited to, graphing and AJAX classes, methods of authentication and CRUD libraries.

    The book is written well and the inevitable – yet thankfully small – number of spelling and grammar mistakes in the books don’t detract from the book as much as in the SOA one. I got the impression while reading chapter eleven that the author is not particularly knowledgeable about file permissions on linux/unix and specifies the most permissive options for those platforms which is a bit worrying.
    I was amused to find the book “PHP Programming with PEAR” gets a mention in the “Resources and Extensions” chapter, more so because CodeIgniter seems to be a framework that has a chronic case of “Not-Invented-Here” syndrome and attacks the PEAR framework on the main page of it’s website and userguide.

    All in all, I found the book to be a straight-forward, educational read and that it works very well alongside the CodeIgniter online documentation.
    Well worth the read if you are new to CodeIgniter.
    Addendum: Kae asked if reading this book might make me inclined to use CodeIgniter; while I found it very interesting I was also shocked that there is no inclination of embracing and utilising PHP5 enhancements and the chronic NIH present in the framework makes me feel very reluctant to use CodeIgniter. There is a spin-off or fork of CodeIgniter called Kohana that takes advantage of PHP5. It may well be worth investigating.

    Book Review: The PEAR Installer Manifesto

    Tuesday, March 11th, 2008

    Book Review: The PEAR Installer Manifesto by Gregory BeaverPackt Publishing.

    When I was asked by a Packt representative if I would review the book “SOA Approach to Integration” by Poornachandra Sarang, Frank Jennings, Matjaz Juric and Ramesh Loganathan I was told I could pick a book of my choice as a “thank-you” for writing that review.

    I jumped at the chance to obtain a copy of “The PEAR Installer Manifesto” – and have now been asked to write a review of it, so here goes:

    The book is approximately 270 pages long, split into six chapters, and is aimed at PHP developers who “want to understand how the PEAR Installer works and what it can do for them” and also for those “seeking a better way to deploy their applications and manage updates”.

    The six chapters are:

    1. What is it and how do I get it?
    2. Managing PHP Software Management with the PEAR Installer
    3. Leveraging Full Application Support with the PEAR installer
    4. Clever Website Coordination using the pear Installer
    5. Releasing to the world: PEAR Channels
    6. Embedding the PEAR Installer: Designing a Custom Plugin System

    Chapter one explains what PEAR is, how to install the PEAR installer and how to deploy PEAR packages remotely onto a server over FTP – proving that no matter what way you access your production servers you can, and should, be using the PEAR installer.

    Chapter two covers versioning, package.xml and roles; teaching how to turn software written in PHP into discrete distributable packages.

    Chapter three focuses more on version two of package.xml (chapter two briefly covered both versions 1 and 2 of the package definition file) and explains how to bundle a package with its dependancies.

    Chapter four is about source code control and performing roll-backs on pear packages – essential tasks when it comes to managing a complex website.

    Chapter five details how to set up a channel server, outlines various ways to distribute packages and applications using channel servers and discusses related security issues.

    Chapter six closes the book with an explanation of why you might want to embed the PEAR installed, a discussion of several methods of handling plug-in systems and designing a custom PEAR channel-based plugin system.

    As a PEAR developer who’s going through the process of getting a new package proposed and accepted I found the discussion of package.xml enlightening – much more so than the current online documentation.

    As a developer who has occasionally needed to rollback changes pushed to a production server… well, if chapters two and three weren’t eye-opening enough; chapter four definitely was as it details how to employ the PEAR installer to update and rollback live code so you can quickly revert back to a known working version of the site.

    Though they are relatively few the book is not without its flaws: there is a small number of spelling mistakes present and considering the book was published in 2006 I don’t think it unrealistic to expect these to be corrected in an on-line errata. Other than that I found “The PEAR Installer Manifesto” to be a nicely focused, well written book grounded with good case studies and real world examples.

    Authored by the authority on the PEAR installer the book couldn’t get much better. Highly recommended.

    Our php.ie stand at the Irish Web Technologies Conference 2008

    Friday, February 29th, 2008

    I noticed just now that Kae blogged about our participation at the Irish Web Technologies Conference.

    As Kae mentioned, this was the first time that we represented the Irish PHP Users Group at any such conference and we learnt a lot – from the mundane to the slightly more insightful.

    • Bring at least two [long] extension leads along rather than assume there will be power sockets nearby!
    • Have Group business cards to give out – a few times we had to resort to writing the website address and contact/mailing list details of the Group onto scraps of paper; obviously not the best impression to give.
    • Building on this, it wouldn’t be a bad idea to prepare some form of flyer that could be used to raise awareness of what the Group, and PHP in general, is about – a more substantial take away reminder as it were.
    • And on top of this we need to raise awareness of the Group: I got speaking with David Ennis from TechWest in Galway and discovered that until today he had no idea that there was a national users group for php developers. We need to work on making ourselves known. David had some good ideas about this including having regional talks every 3 months or so. We reminded each other that the PHPLondon Conference was on today and for us to hold something similar there’s a lot of baby steps that we’d need to do before we can consider holding something similar.

    It was a good day and I’m sure the next time we participate in a conference we’ll come better prepared.

    Book Review: SOA Approach to Integration

    Wednesday, February 6th, 2008

    Book Review: SOA Approach to Integration by Poornachandra Sarang, Frank Jennings, Matjaz Juric, Ramesh Loganathan – (Packt Publishing)

    I was recently asked by a representative of Packt Publishing to review this book on Service Oriented Architecture and I looked forward to reading the review copy they sent me.

    While I waited for the book to arrive I searched the packt website for the errata for it – and found none. I thought “Either the book is perfect or they haven’t gotten around to publishing a list of corrections yet”. Quite an omen.

    The blurb on the back of the book says that it is intended for “architects and senior developers who are responsible for setting up SOA for integration for applications within the enterprise and applications across the enterprise”.

    The 360 or so pages are split into six chapters:

    1. Integration Architecture, Principles and Patterns
    2. Service- and Process-Oriented Architectures for Integration
    3. Best Practices for Using XML for Integration
    4. SOA and Web Services Approach for Integration
    5. BPEL and the Process-Oriented Approach to Integration
    6. Service- and Process-Oriented Approach to Integration Using Web Services

    Chapter one focuses on integration technologies, approaches and patterns – pretty much laying the groundwork as you would expect an introductory chapter to do.
    The second chapter attempts to drill down deep into what SOA is about.
    Chapter three details the Best Practices that should be followed when using XML for Integration and seems completely out of place considering the intended audience that this book is written for – it is far to low-level for a book aimed at software architects.
    Chapter four focuses on web services and does a very good job of it, advising for example to stick with approved Standards rather than using proprietary extensions of say SOAP and WSDL. Amusingly though, while advising that web services should remain independent of programming languages and application platforms the book soley gives examples in Java and .net.
    Chapter five details BPEL (Business Process Execution Language) and the Process-Oriented Approach to Integration in a rather comprehensive manner.
    Chapter six, discusses the Enterprise Service Bus (ESB) in depth. Just as with chapter 4 I was amused with this one. There is a subsection to it about how ESB helps avoid vendor lock-ins yet there is no discussion of open source offerings that are available for EBS, BPEL etc etc.

    “SOA Approach to Integration” focuses in detail on the WS-* standards and references SOAP very often. There is an anomaly in that there is no mention of REST and while the authors, with their collective experience in Java and .NET, focus on detailing use and interoperability between those platforms I would have expected at least some Open Source technologies and programming languages to be referred to – the ESBs Apache Service Mix, Mule for example; along with perl, PHP and python as some of the programming languages that can be used.
    If PHP was to be mentioned I would expect the “WSO2 Web Services Framework for PHP” to be listed as well as, perhaps, the SOAP and UDDI packages from PEAR.

    I found myself reading some sections of the book repeatedly – not because the technical content was too complex to understand; but due to it being too verbose, due to bad grammar, spelling mistakes and poor punctuation. I also felt that the diagrams and figures in the book should have been identified better, both in the text and individually. A glossary and a more complete index would have been nice too.

    On the whole, although I did enjoy reading portions of the book, it seems to be a lacklustre introduction for software architects and senior developers that are new to Service Oriented Architecture but that’s pretty much all that it is.

    More for Date_Holidays

    Tuesday, January 22nd, 2008

    It seems that my recent post about Date_Holidays has evolved into a request-fest for Drivers and Filters to calculate when the national and public holidays for various countries.

    On the list to be developed so far are:
    * Iceland
    * Romania
    * The Ukraine

    Email me or leave a comment below if you are interested in this ;-)

    New release of Date_Holidays PEAR package.

    Saturday, January 5th, 2008

    Date_Holidays 0.17.2 was released today; with two new drivers and some bug fixes!

    Date_Holidays is a PEAR package for PHP that is used for determining whether a specific date is a [public] holiday in some specified country, listing all such holidays and for these reasons is a useful component for scheduling applications.

    This is driver based, one per country.
    Currently there are drivers for: Austria, Denmark, England & Wales, Germany, Ireland, The Netherlands (new) , Norway (new), Slovenia, Sweden and the USA.

    There are also drivers for Christian and Jewish holidays along with special ‘UN’ celebrated days such as “World Health Day”.

    It’s very easy to write new drivers for Date_Holidays, heck I wrote the Ireland driver ;-) So if you’ve noticed there is no driver for where you are I’d recommend that you do so.

    Determining specific install of PEAR packages.

    Monday, October 15th, 2007

    Adam Harvey posted about listing which PEAR packages are installed. This inspired me to spend a few minutes coding a solution to check for a specific installed version of a package.
    This is useful for where you provide a system that uses certain packages and you decide to not bundle those packages with the system you developed [so you don't have to manually apply upgrades for security fixes etc] and rely on PEAR itself to install and upgrade those packages as need be.

    Sixth Meeting in Dublin of the Irish PHP Users Group

    Thursday, July 26th, 2007

    There were five attendants at this Wednesday’s meeting:

    1. Fergal Byrne <editor@adnet.ie>
    2. Justin Kelly <jk@tedcreativegroup.com>
    3. Ken Guest <kguest@php.net>
    4. Michael Słaby <michal.slaby@epsi.pl>
    5. Stephen Curran <stephen.curran@gmail.com>

    Symeon Charalabides sent his apologies, as did Barry O’Donovan – both unable to
    attend.

    We had a very interesting discussion about the different forms of testing:
    Test Driven Development, phpunit, simpletest and the management/recording of
    manual testing. CruiseControl and xinc were mentioned in passing.

    This segued into chatting about maintaining existing code; the use of
    php_beautifier and vim’s indent function for making code more readable and
    phpdoc for generating documentation.
    PHPCS was also mentioned and how it can be hooked into CVS or Subversion to
    ensure only code adhering to the coding standards can be committed – much the
    same as Fergal’s suggestion of hooking phpunit up so only fully tested code
    can get into the repositary.

    All in all it was a successful meeting; we even came away with a nice quote
    from Justin: “Perl is nice if you want to be Harry Potter” (!)

    links:

    1. xinc – http://sourceforge.net/projects/xinc
    2. cruisecontrol – http://cruisecontrol.sourceforge.net/
    3. phpunit – http://phpunit.de
    4. simpletest – http://www.lastcraft.com/simple_test.php
    5. phpcs – http://pear.php.net/package/PHP_CodeSniffer
    6. php_beautifier – http://pear.php.net/package/PHP_Beautifier