Blog

About

Flourish is a PHP unframework, a general-purpose, object-oriented library focused on security, documentation, ease-of-use and portability.

Testing Across 12 OSes, 10 Versions of PHP and 6 Databases

Part of the goal of Flourish is to provide a solid library of code to build web apps and websites on top of. Since PHP runs on such a variety of operating systems and many users do not control the server they are installed on, operating system and PHP version compatibility is important. Thanks to recent donations by iMarc and Luke Foreman, the testing setup has been expanded to include OS X 10.6 and Windows Server 2008.

With these changes, over 60,000 tests are run with every SVN commit, on a total of 10 different versions of PHP, running on 12 different server environments. All database-related tests are run on the six supported databases, and most are run using each of the 14 supported database extensions against eight different database versions. In situations where Flourish provides a pure-PHP fallback implementation of a non-standard PHP extension, the tests are run both with the non-standard extension loaded and not. Read more


Offline Documentation

After a handful of requests, I finally took some time this weekend to create some offline documentation for Flourish. Starting with r879, every SVN commit and every time a class documentation page is updated, a single HTML page is created that contains all of the class documentation, API reference, and relevant general documentation.

Offline Documentation Preview

The file uses the data URI scheme to allow for a single file containing all HTML, images, CSS and javascript. As long as you aren't using Internet Explorer, you'll even see the Flourish favicon.

Unfortunately, IE6 and IE7 don't support the data URI scheme and thus may not show all images. You probably won't want to use IE anyway, since it can't handle the 4mb of HTML without slowing to a crawl. Chrome, Firefox, Opera and Safari all seem to perform just great. Read more


Do You Use ODBC?

Recently I've been running into more issues with ODBC not properly handling UTF-8 and blob data across the various databases that Flourish supports. I'm very strongly considering dropping ODBC support due to the fact that:

  • None of the ODBC database drivers pass the tests on any OS but Windows
  • There is no way to tell DB2 to use the UTF-8 encoding with ODBC
  • Oracle via ODBC fails with UTF-8 so some characters must be escaped using CHR()
  • CURRENT_TIMESTAMP isn't implemented for Oracle when using ODBC
  • The pdo_odbc driver in PHP 5.3 returns seemingly random data from an MSSQL blob column

Does anyone currently use an ODBC connection with fDatabase?

Update

7/31/10 - As of revision 879, ODBC support is no longer provided in any of Flourish's database classes. ODBC support was removed since it was holding back perfect UTF-8 support, caused stability issues on some servers and did not appear to be used by anyone.


DB2 Support Added

Last night I completed the final additions to the core database layer of Flourish by adding support for IBM's DB2. Along with support in all of the core database classes, such as fDatabase and fResult, DB2 support was added to fSchema and fSQLTranslation, which means that DB2 is fully supported by the ORM. The Flourish SQL page has been updated to show the non-translated compatibility of DB2 to the other supported databases.

Currently only the ibm_db2 extension is supported for DB2 access due to issues with the others. The pdo_ibm extension currently has serious issues that cause PHP to segfault when trying to access CLOB or BLOB data. The odbc and pdo_odbc drivers are not currently supported because I have not found a way to get proper UTF-8 support on Windows machines. If you have any experience with DB2 on Windows, please check out my post on the IBM developerWorks forum. Read more


Testing Enhancements

With the addition of comprehensive prepared statement support, I felt it time to invest in an enhanced testing architecture to help ensure that Flourish is as portable as possible. The work described below was possible due to the generous support received through the Server Fund last fall.

The hardware purchased with the server fund included an Intel Core i7 860 processor and 8GB of ram. This hardware is used to run 11 different virtual machines:

Testing OutputTest History Graphs
  • A Debian database server running MySQL 5.0, PostgreSQL 8.3 and Oracle 10g XE
  • A Windows XP machine used for running tests and running SQL Server 2005 and SQL Server 2008
  • Machines for running tests, including the following operating systems:

Read more


Prepared Statement Support Added

Since back in December there has been kind of a lull in activity on Flourish due to some major work adding prepared statement support to fDatabase and re-architecting the tests. The result of this work was a new class added to Flourish, fStatement, that works in combination with fDatabase to provide prepared statement support across all database extensions. You can read more about it in the fDatabase section about Prepared Statements.

A good amount of time was spent adapting the various PHP extension APIs to work with the existing fDatabase::query() style of using data-type-specific placeholders. As you can see below, using prepared statements with Flourish will feel very natural if you have used the other query methods.

// Prepare a statement
$statement = $db->prepare("SELECT * FROM users WHERE user_id = %i");
 
// Execute it any number of times
$user_1 = $db->query($statement, 1);
$user_2 = $db->query($statement, 2);
//

The fDatabase::prepare() method will create an fStatement object out of database-specific SQL string, while fDatabase::translatedPrepare() will translate the SQL throught fSQLTranslation before creating the object. The object can then be passed in place of a SQL string to fDatabase::query() or fDatabase::unbufferedQuery(). Read more


Contributing

Recently there has been some increased interest in contributing to Flourish. If you are interested in helping out with the project, I’m sure that everyone who uses it would be very grateful. The way that things of have been going recently, I’m going to start focusing more on approaching a stable release. Over the past year the beta has helped to improve the available functionality, increase its robustness and work out quite a number of bugs.

As the code moves to a stable release, I foresee more of a focus on improving documentation and writing tests. There are also currently a number of tickets for enhancements, plus there are some items on the original roadmap still to tackle.

So, if you do have interest in contributing to the project, please consider how you may be able to help out with:

Read more


New Oracle Support and More Tests

After some prodding from a few interested parties, I took it upon myself to add Oracle support to Flourish. There now exists full support for Oracle in the fDatabase, fResult, fUnbufferedResult, fSchema and fSQLTranslation classes. I've targeted Oracle 10g since I have free access to that via Oracle Database 10g Express Edition, however I believe almost all of the functionality should work on older versions.

In addition to adding support for Oracle, I took the past couple of months to add over 1800 new tests that exercise all 16 supported database extensions and cover most of the functionality of the fDatabase, fResult, fUnbufferedResult, fSchema and fSQLTranslation classes.

Like other supported databases, the Oracle support in fDatabase will work with any of the available database extensions for Oracle. This includes OCI8, PDO_OCI, ODBC and PDO_ODBC. From my testing, the ODBC extensions only work on Windows because some of the ALTER SESSION commands executed by fDatabase are not supported by the UnixODBC driver. If you have any details on a better way to configure ODBC on Linux/BSD, please let me know. Read more


Discussions and Comments

Just a few days ago I posted links to Flourish on both Hacker News and the PHP Reddit. There has been some great conversation about Flourish on those sites and on a thread over on the CodeIgnitor forums.

If you run across any other conversations, I'd love to hear about them. And as always, please feel free to comment on this post or start a thread with any suggestions or questions you may have.


Flourish Demo Site

If you've never worked with Flourish before, getting started building a site may seem a little daunting. Included below is the description and source code for a production site written with Flourish and SQLite.

The northshorewebgeeks.com site provides a simple list of upcoming and past meetups for the North Shore Web Geeks meetup. Rather than hand-editing the HTML and RSS feeds, Flourish was set up to provide a simple CMS to easily update the information.

Routing

The site is fairly simple, so I set up Apache with mod_rewrite to create some nice, clean URLs:

/                     # -> index.php  : Home/main page
/rss                  # -> index.php  : RSS feed
/manage               # -> manage.php : Lists all meetups
/manage/add           # -> manage.php : Allows adding a meetup
/manage/{date}/edit   # -> manage.php : Allows editing a meetup
/manage/{date}/delete # -> manage.php : Allows deleting a meetup

Read more


SQLite 3.2.8 Binary

If you are working with a server running PHP 5.1.x (such as a VPS with CentOS 4) you may have run into an issue with using SQLite as a database. The version of the sqlite3 command line program is 3.3.6, however the version of the SQLite library used for the PDO SQLite driver is 3.2.8. To complicate matters further, between versions 3.2.8 and 3.3.0 the database file format was changed in a way that databases created by 3.3.0 and newer are not readable by 3.2.8 and before.

In practical terms, this means you can't use the sqlite3 binary provided by the OS to create a database to use with PHP.

Unfortunately the SQLite website has removed all source and binary files for everything before 3.6.x. While I was unable to find a 3.2.8 binary for linux, I was able to find a copy of the source tarball from an old Ubuntu repository, and I have mirrored it here along with a statically linked binary that I compiled.

Downloads

Read more


Announcing the Flourish Beta

After about a year and a half of development and approximately 150k lines of code changes, Flourish is now officially in beta.

Flourish is a general PHP library that is focused on being robust, yet easy to use, secure, portable and well documented. It is specifically not referred to as a framework because it is quite different from most of the PHP MVC frameworks currently available.

Project Overview

Here is a brief overview of the library:

Read more