Archive for July 2nd, 2007

DevShed: Handling Cookies and File Data with the Factory Pattern in PHP 5

Continuing on with their look at the Factory Pattern (part one), DevShed has part two posted - a look at applying what was learned previously into a simple cookie-handling and file manipulation script.

At this stage you should have a more accurate idea of how to include the factory pattern into your own PHP applications, at least at a very basic level. But don’t you worry because this scenario is going to change quickly, since in this second tutorial I’m going to teach you how to take advantage of the capacity offered by the pattern to create objects that are capable of saving data to different locations, including files and cookies.

The tutorial starts off by creating the classes needed to save strings and objects based off of the abstract DataSaverFactory class. On top of this, they build the classes to save the cookies and work with the files using the Factory objects.

Continue Reading · Add comment

JSLabs Blog: How to create Microsoft Office Documents with PHP

From the JSLabs blog today, there’s a quick illustration of how to dynamically create three different types of Microsoft Office files - a Word document, Powerpoint and an Excel file.

There are two main ways to build Excel, Word, and PowerPoint documents using PHP. The first is by using the COM library (only if you are using a Windows server) and the other is by using a more standardized approach such as HTML or CSV.

All three examples use the COM method and make basic structures to save out. They also include a screenshot (and description) showing where you can find the list of functions you can call to the COM object for each application.

Continue Reading · Add comment

PHP-GTK Community Site: Click Fast, Desktop Gadget & visualProxy

The PHP-GTK Community website as three new posts today all describing applications built with simplicity in mind and created using the PHP-GTK libraries:

  • the “Click Fast” button that makes use of the Gtk::timeout_add() and Gtk::timeout_remove() functions
  • a Desktop Widget that can be used for useful information you want to keep in view
  • visualProxy - an HTTP proxy server and transmit HTTP proxy requests from a WWW user agent to an other proxy or directly to a server. It displays requests graphically and update information on the fly on a detailed list with many fields columns.

Check out their apps and code snippets sections for more examples like these.

Continue Reading · Add comment

Sebastian Bergmann’s Blog: PHPUnit 3.1.0 (Release Announcement)

Sebastian Bergmann has posted the official release of one of the most popular unit testing software packages for PHP on the web - PHPUnit 3.1.0.

Included in the advancements he mentions are things like:

  • Improvements to Mock Objects include the ability to mock classes and methods that do not exist as well as mocking static methods. And mocked methods can raise exceptions now.
  • PHPUnit can now write test result and code coverage data to a test database. Several ideas for future features depend on this data.
  • New template methods, PHPUnit_Framework_TestCase::sharedAssertions(), PHPUnit_Framework_TestSuite::setUp(), PHPUnit_Framework_TestSuite::tearDown(), and PHPUnit_Extensions_SeleniumTestCase::defaultAssertions(), ease the development of test cases.

This latest version can be pulled from PHPUnit’s Trac repository or via the PEAR installer (recommended method).

Continue Reading · Add comment

Jonathan Street’s Blog: PHP5 Compete API Wrapper

Jonathan Street has officially released his version of a Complete API (for Complete.com) to grab traffic information for a particular site.

With the exception of a link from the homepage, which is apparently in the works, Compete has made good on the points I raised so it’s time for me to fulfil my part of the deal and release a PHP5 wrapper for the compete API.

The wrapper is simple at this point, only containing only a few methods to make the connection with Complete.com, generate the query and pull out one of three bits of information (including the traffic).

Continue Reading · Add comment