Finally, after 7 months of slow, but steady development, I’m happy to announce phpSmug 2.0 is now available for download.

It’s been a long time coming as there has only been one bug reported in the last release, and it wasn’t a major issue, and I’ve been working on consolidating the code to make it more uniform and a lot easier to manage and maintain.

What’s New?

First things first, I have to issue a warning:


phpSmug 2.0 is NOT a drop in replacement for phpSmug 1.0.x of 1.1.x.

Please ensure you read this post, which is also documented in the README and the documentation, for details on how phpSmug 2.x now functions.

Right, now we’ve got that out of the way, lets get to the nitty gritty.

For those who’ve used phpSmug before, things have changed with phpSmug 2.0 and hopefully it’s for the good and won’t be too much trouble to adapt your applications for.

If you’ve not used phpSmug before, you can skip the rest of this post as it won’t mean much to you.

  • Method Arguments The general functionality is the same, however the method of passing arguments to methods has changed. Now when you pass arguments to a method, you need to pass them either as a series of strings, for example:

    $f->images_getInfo("ImageID=<value>", "ImageKey=<value>");

    … or as an array …

    $f->images_getInfo(array("ImageID" => "<value>", "ImageKey" => "<value>"));

    This is a deliberate design decision to keep things consistent and is actually due to work I’ve done to ease the development and maintenance of phpSmug.

    You’ll see phpSmug 2.0 is considerably smaller than previous versions. This is because phpSmug now uses PHP 5’s __call() method to dynamically create the API calls for methods that are not explicitly declared.

    As a result of this, phpSmug 2.0 and later will definitely NOT work with PHP4. It also has the added bonus in that you no longer need to have empty arguments in your method calls: you only need to pass what’s required or what you need.

  • SmugMug API Endpoint Compatibility phpSmug 2.0 defaults to using the only stable endpoint provided by SmugMug: the 1.2.0 endpoint. However, it is fully functional with the later endpoint revisions, unless otherwise documented on the Issues page. To use a later version of the endpoint, just set the version when instantiating the instance using APIver.

  • All smugmug.login.* Methods Handled by a Single login() Method To simplfy things even further, I’ve consolidated all the smugmug.login.* API methods into a single login() method. phpSmug will determine which API method you wish to use from the arguments passed when calling the method. If not arguments are passed, phpSmug will login anonymously.

  • phpSmug now throws exceptions on error In order to take full advantage of PHP5 functionality and make phpSmug behave more like a proper PHP class, I’ve removed the “die_on_error” functionality and instead turned to using exceptions. It’s up to you as the application developer to catch the exceptions and turn it into something useful for your users. All the examples supplied with phpSmug now catch the exceptions. The only exception to this is caching. If there is a problem creating the cache, phpSmug will just error and continue without using any caching. I didn’t think it worth stopping the world due to a caching issue.

So, go on, get downloading and if you encounter any problems, please leave a comment on this post.