Supercharge Your OXID Development Environment

OXID eShop offers developers a full-featured, OOP-compliant API that can be used to easily add new features and enhancements to the base product. And regardless of whether you’re a developer new to the OXID framework or an old hand with many years of OXID experience under your belt, chances are you’re always on the lookout for tools and techniques that will help you get the most out of your OXID development environment.

Below are some tips, compiled both from my own experience and from the experiences of other developers on the oxid-dev mailing list, that you can use to make your OXID development environment a faster, smarter and – dare I say it? – more fun place to be.

Cut installation time with a pre-built VMWare image

OXID eShop requires a fully-configured Apache/PHP/mySQL environment, with all necessary extensions and modules installed. Most PHP developers will already have this basic set-up but for those who don’t, recompiling PHP and Apache to include the necessary modules is a time-consuming process. For such situations, OXID offers a ready-to-run VMWare image that contains a working edition of OXID eShop CE. This image can be used to quickly bootstrap a working OXID eShop development environment and it’s also certified by OXID, which means that you’ll be beginning your development on the right footing.

In case you’re wondering, the image contains a basic Debian installation, together with installed versions of Apache 2.x, PHP 5.x with all required modules, MySQL 5.x, SSL, Postfix and FTP (and, of course, OXID eShop itself). To install it, download the free VMWare player (registration required) and then follow these instructions to get it up and running.

Use debug mode

OXID eShop comes with a built-in “debug mode” that allows developers to inspect template variables, backtrace SQL queries, see SMTP debug messages and analyze script execution times. This debug mode is controlled via the $iDebug property in the main OXID eShop configuration file. Here’s an extract from the file, which illustrates the different modes available:


    //  enable debug mode for template development or bugfixing
    // -1 = Logger Messages internal use only
    //  0 = off
    //  1 = smarty
    //  2 = SQL
    //  3 = SQL + smarty
    //  4 = SQL + smarty + shoptemplate data
    //  5 = Delivery Cost calculation info
    //  6 = SMTP Debug Messages
    //  7 = oxDbDebug SQL parser
    $this->iDebug = 0;


Here’s an example of the debugger displaying Smarty template variables for a particular page ($iDebug = 1):

Dev Image 1

And here’s an example of the debugger displaying ADOdb performance statistics ($iDebug = 2):

Dev Image 2

Watch SQL queries in real time

The OXID eShop database currently has 59 tables, each dealing with a different aspect of the product. Understanding the specific function of each of these tables, and how they contribute to the whole, is no easy task, but it is nevertheless an essential one for developers who are building modules that will “plug in” to the existing OXID eShop infrastructure.

An easy way to gain this understanding is to request a specific eShop URL and then watch the SQL queries being performed internally by the application to satisfy this request. The OXID eShop debug mode, discussed above, makes it easy to display a backtrace of the SQL queries used to generate a particular page. Here’s an example ($iDebug = 7):

Dev Image 3

In case this isn’t enough data, or if you’re already using debug mode to watch something else, an alternative tool is the MySQL general query log, which logs all queries sent to the database server in real time.

If you’re using MySQL 5.1.2 or better, use the following command to activate the MySQL query log:

mysql> SET GLOBAL general_log = 'ON'; 

For older versions of MySQL, activate the query log by adding the special –log or –general_log parameter to the MySQL server command line:

shell> /usr/local/bin/mysqld --general_log 

By default, the MySQL general query log is stored as a file named hostname.log in the server’s data directory. Once active, you can watch this file change in real time as the server executes SQL queries sent by OXID eShop, using either the tail command (UNIX) or the Tail for Win32 application (Windows). Here’s a screenshot that demonstrates it in action.

Dev Image 4

If you’re creating a module that reads or writes data to the OXID database, this “real time query inspection” also lets you quickly identify errors in your SQL queries. You could also activate the MySQL slow query log and use it to identify queries that need optimization for better performance.

Update your IDE

While you can write PHP code in any text editor, a number of OXID developers point to Eclipse as their IDE of choice. Eclipse, coupled with the PDT plugin, significantly increases the speed of PHP development, by providing code completion, syntax highlighting, a debugging engine and a file publishing engine.

A good suggested Eclipse configuration is:

  • PHP Development Tools (PDT) v2.1: An Eclipse plugin for PHP development, with support for syntax highlighting, code completion, project management and XDebug code profiling and debugging.
  • AnyEdit plugin v2.2: An Eclipse plugin for code cleanup, including automatically removing whitespace, converting tabs and handling HTML entities.
  • SubClipse SVN v1.6.x: An Eclipse plugin that facilitates interaction with a Subversion (SVN) version control system

Alternatives to Eclipse include Aptana, Zend Studio, phpDesigner and the small-footprint Crimson Editor.

Add Mozilla debugging tools

In addition to the application’s own debug mode, OXID developers make use of a number of Mozilla Firefox extensions to debug the application on the client and ensure it performs well in all Web browsers. Typical tools used include:

  • Firebug: A browser extension that allows inspection and debugging of CSS, HTML and JavaScript errors on the client
  • YSlow: A Firebug plug-in that analyzes the performance of output pages and automatically offers suggestions for making them lighter and faster.
  • XDebug Helper: A Firebug plug-in that integrates with PHP’s XDebug extension for code profiling and debugging.
  • FireShot: A browser extension for taking full-size screenshots and adding annotations, ideal for making notes on prototype interfaces or reporting GUI bugs
  • HTML Validator: A browser extension based on Tidy that validates a Web page’s HTML markup against the W3C specification and returns information on errors found..
  • Selenium IDE: A browser extension that provides an integrated environment for Selenium-based testing.

Here’s an example of Firebug in action:

Dev Image 5

Keep a copy of the OXID manual at hand

The OXID eShop API is built in conformance with OOP principles, and takes full advantage of the object features in PHP 5.x. The large object collection offers tremendous flexibility, allowing developers to override almost any aspect of the product’s default behaviour. At the same time, it requires a developer to invest time and effort in understanding the inheritance chain and the core object architecture.

This task is made easier by the existence of extensive Doxygen-generated API documentation, which provides developers with a ready reference of the OXID class hierarchy, complete with inheritance and collaboration diagrams, an exhaustive list of classes and class members, and complete signatures for every method in the API. This online reference is possibly the best resource available to help you in your OXID development, and a close study of it is essential before you can begin writing custom modules for OXID.

A good tip is to keep PDF copies of the key parts of this manual, such as the class hierarchy and the oxArticle object skeleton, on your desktop so you can quickly refer to them as needed.

Here’s an example of the graphical class hierarchy generated by Doxygen:

Dev Image 6

Many thanks to Marco Steinhaeuser, Michael Fritsch, Alfonsas Cirtautas and Christopher Simon for their contributions to this article.

Have more tips to share? Comment on this page, or send them to the oxid-dev mailing list.



Start the discussion at OXID forums