PHPBaseClasses is a multitier and fully Object Oriented set of base classes written for and in PHP. At this moment the storage tier is SQL-only; but it supports multiple databases : Any ODBC database, MS-SQL (SyBase), MySQL, PostgreSQL. PhpBaseClasses uses an abstraction-layer for all database operations so porting to a new database is trivial.

It looks like this ...

if ($action == "create") {
  $myN = new NewsItem();
  $myN->setPerson(new Person($nperson));
  $myNC = new NewsCat($ncid);

and ..

while (list($index, $newsitem) = each ($CurrentNewsCat->items)) {
  echo $newsitem->getSubject();

The API, how it looks like

PhpBaseClasses has for example the following classes in it's API tier:


PhpBaseClasses uses a XML-file for storing it's settings (like table -and column names, and like database connectivitiy-settings). It contains a extensible configuration-system. Adding a record in the XML-file will enable you to start using the record as a configuration setting without any further coding or hassle. getKey("node", "key") will do the trick in case you added those to the XML-tree.

PhpBaseClasses contains a complete API-reference written in XML. You can find the current version if this XML-file here

I also wrote a small XML-parser for this file in PHP which results in this HMTL-document. The parser is included in the module in CVS.

These classes have, of course, all typical functionality and methods. You don't have to know anything about databases in order to start using them as the storage-tier handles all that crab for you, the programmer. To give a quick explanantion; A NewsCats contains NewsCat's and a NewsCat contains NewsItems and a NewsItem contains NewsReplyItems and NewsReplyItems can again contain NewsReplyItems (until the 30-seconds execution time exceeded). The classes contain methods to add, remove, get and modify the entities that they contain.

Click here for the source of a sampleforum created by PhpBaseClasses.

Future ideas

Future ideas include anything that other developers want to get implemented in PhpBaseClasses, Of course stableizing the code and adding a GUI or Widget-set to PhpBaseClasses. Perhaps working together with webcomp for this last major feature. Once this is in, you could create visible web-components like labels, comboboxes, lists, textboxes, datetime-fields, grids and buttons just like with any other widget-GUI-toolkit. ($but = new Button("label")). Click here for a drawing by the maintainer of dotphp which shows how PhpBaseClasses, web components and dotPHP might become implemented.

The storage-tier

PhpBaseClasses has a abstraction layer for storage purposes. The classes described above don't use any database-related functionality directly, they use the storage-tier. This storage tier are a lot classes which are available for the API-tier and in the UserInterface if the programmer decides to incorrectly use the tiers (For example, for a quickhack. However, I do reccommend extending PhpBaseClasses and asking for a CVS-account of sending me a patch in stead of inventing such quickhacks). The storage-tier is not documented at this moment. The API-tier has programmer-documententation.

Transparant database-interface wraps multiple databases

Because I did some analysis before I started writing the storage-tier it is, imho, of a pretty good quality. It supports multiple databases and ODBC. It supports changing table -and column-names. You can set these in the BaseClass class of which each actual class inherits from (which is also why it's attributes are accessible in each existing PhpBaseClasses-class. Some of those attributes include a hash-table with the settings and table, column names). I am also thinking about table-creation functionality for the database-tier classes. So that this database-tier can create the SQL-environment by itselve (It does contain all information to recreate a table in SQL, so why not).

Incode documentation and API-reference

PhpBaseClasses uses XML in the code to store development-help and API-reference. I provide some tools in the manual directory to extract this XML out of the sources. I am planning to write a small module which will convert this XML to HTML or another markup-language. The aim is to document all methods, all properties, all classes, all TODO-stuff, all files and all functions. So if you contribute to the project; make sure that you include this XML-documentation. You can checkout the other classes to see how you should do this.

Files and releases

Because we are all big boys and girls who should by now know how to use CVS, I am only providing a pointer to the ViewCVS of SourceForge and a guide to get the sources of PhpBaseClasses by using CVS. If you want to use a GUI tool like gCVS or WinCVS then you are on your own for configuring these applications. The CVSROOT should be set as; you can login by leaving the password blank (an empty string).


I am maintaining a DIA UML scheme of the project which you can find here :*checkout*/phpbaseclasses/phpbaseclasses/manual/UML.dia?rev=HEAD
If clicking on the link shows you some XML-tags then save the contents to a file called UML.dia and open it using DIA.


You can mail them to me (check pointers to my website lower on this webpage. I am not including any E-mail adresses here for anti-spam reasons. Big boys and big girls can figure it out how to find my E-mail adres).

Author and maintainer

This is my website