When Microsoft started throwing more of its weight behind open source support on Windows, one of the biggest moves the company made was to bolster development of PHP. Love it or hate it, PHP has become a lingua franca of Web applications; tons of them are written in it, from quick-and-dirty one-page apps to entire websites.
For most sites, PHP is run in conjunction with a database, typically something like MySQL. Microsoft’s most recent set of support tools for PHP, however, are designed to allow tighter integration with SQL Server. In this case, it’s a toolset—written by Microsoft and Persistent Systems -- that lets PHP programmers make use of SQL Server Reporting Services (SSRS) (SSRS). This comes not long after Microsoft announced the 2.0 revision for its SQL Server Driver for PHP, so PHP with SQL Server is clearly the newest addition in an ongoing series of improvements from Microsoft.
The software development kit (SDK) provides a library that allows PHP programs to make use of SQL Server Reporting Services. It works with many versions of SQL Server, including the free-to-use Express edition with Advanced Services.
You can create SSRS reports via Business Intelligence Development Studio -- which also comes with the aforementioned edition of SQL Server -- and obtain the data from a local or linked server. The latter is useful if you have a full repository of data on another SQL Server instance somewhere in your network, and rather than copying data out piecemeal you’d prefer to talk directly to that server and make use of the data in its original place.
The library also allows PHP programs to access four common functions in Reporting Services:
- querying for a list of available reports
- querying each report’s parameter list and valid values
- obtaining a list of report formats provided by the server
- executing a report (of course!)
Code samples included with the library show you how to make use of the functions. This example shows how the report returned by the library can be easily slipstreamed into an existing webpage.
Apart from the library itself and the examples associated with it, there’s also a module for SugarCRM that allows SSRS reporting to be integrated with SugarCRM Community Edition’s reporting functions. This example module contains details about how to set up SugarCRM to work with SSRS. Note that the database for SugarCRM itself will be MySQL instead of SQL Server. Fortunately, if you don’t have MySQL set up you can add it using Microsoft’s Web Platform Installer app, a virtual appliance like JumpBox, or a standalone edition such as XAMPP.
The SQL Server Reporting Services SDK is licensed under the open source BSD license and comes with source code, so it can be freely reused or re-implemented in many different contexts.
ABOUT THE AUTHOR
Serdar Yegulalp has been writing about computers and information technology for more than 15 years for a variety of publications, including InformationWeek and Windows Magazine.