PHP common utilities [Part 1]

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
kgee's picture

I've taken on the task of automating some lengthy report generation processes here. The reports were to be e-mailed to the requestee in a spreadsheet format, and the heavy number-crunching was done from data retrieved from an mssql database. Along the way, the ubiquity of LDAP came in to play as well.

Since my position here is largely Drupal/Web based, I decided it was time to tackle some utility functions in a PHP setting that would minimize the effort needed to perform some of these higher-level tasks such as 'read/write to spreadsheet', 'query database', 'send email', or 'request LDAP auth'.

If I could bring these functions into PHP, it would open up a whole new avenue of scripted automation as well as have the added benefit of being adapted into any drupal work I do in the future. Scripts could be compiled and turned into drupal pages/plugins. Then, with the proper permission settings, I could release/remove access to various individuals and groups through the drupal administration interface. As you can see, this provides a pretty good set of tools to create a robust and secured intranet toolkit for an organization.

Anyway, I've managed to get most of these functions working. A large part of the process involved learning which PHP import libraries are well-supported, and which fall short of performing the tasks.

For example, there is no unified reader/writer for spreadsheet files, instead I had to install and configure two separate plugins.

On the database querying topic, I wanted to avoid being tied to one type of database. The adodb plugin helped with this, as now I can query a MySQL database just as easily as a postgres or msSQL database.

As I finish up these utilities, clean them up, test them, and deploy them, I would certainly be willing to assist others in the process of getting their own similar utility functions set up. I may possibly get into the line-by-line details of the code and the install procedure in another article.

Message me if you have questions, and happy hacking!

Thunder Bay

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week