The developer console

Oxygen comes with a limited but helpful set of tools to assist in the development process. These tools can be found in the development console, which is nothing but a standard Action. So, the console can be accessed from the standard URL with the query string paramenter action=Oxygen.

The first screen in the developer console is an information page with all the setup parameters of Oxygen. Then, there are 3 tabs with reports. On the othe side of the bar, there is a button to reset the cache, a button to access the documentation and a button to return to the application.

The 3 reporting tabs are browsers for reports generated by Oxygen and kept as files in the log folder. There are links to view or to delete reports. Each of the reports have a header that contains a copy of the info page at the moment the report was generated.

Error reports

Error reports are generated automatically by Oxygen whenever an exception (other than ApplicationException or SecurityException) is caught by the exception handler. If the application runs on a production environment, a copy of the report is also sent to each of the developers. The type of the environment is only determined by the URL of the application; if it runs under 'localhost', then it is DEVELOPMENT. In any other case, it is considered PRODUCTION. The error reports are accumulated here even in a development environment. This is just to keep track of possible open bugs.

Debugger reports

Debugger reports is a sophisticated way to generate logs from the code to assist in debugging. They serve as a replacement to the error_log function of PHP. The debugger come with some functions that make the creation of logs easier.

To write something to the debugger, use the function Debug::Write(). Every entry in the debugger will automatically take two attributes: the time passed from the beginning of the script's execution and the time from the previous debugger entry.

Debug::Write('Beginning processing...'); ... Debug::Write('Processing finished.');

There are also some others similar functions. Debug::Tick() will write nothing but a bullet to the log, which is sometimes useful in order to start timing up to the next entry. In addition, Debug::Dump will dump the value of a variable, along with its type (similar to var_dump, but with less noise).

Debug::Tick(); ... Debug::Dump( $v ); // this will dump the variable, and it will show the time since the last entry (the tick). ...

The debugger report will not be created unless the debugger is enabled. To enable the debugger, add the query string parameter debug to the address and the debugger report will show up and a copy will be saved in to the log folder. There is also the option to keep the debugger running in every consequent request by pinning the parameter. To do so, use debug=pin. This is very useful in order to debug actions that are not called directly from the address bar, such as AJAX requests, or other blind actions such as file servers. The report will be generated and save in the log folder even it it is not possible to show up immediately.

While the debugger is a nice ad-hoc solution, it should not be considered as a replacement for a full blown IDE with a PHP debugger. Being professional means that one should having all the tools ready to be used and select the best tool for each case.

Profiler

Oxygen uses XHProf to profile instantly the function times. If the xhprof plugin is installed, the profiler can be called the same way as the debugger by adding the query string parameter profile or profile=pin. The process is similar, the profiler report will be shown immediatelly if possible and a copy will be saved in the log folder.

The profiler is configured to work in instrumentation mode (which means tracking the entrance and the exit to each function, in constast to sampling mode) and it ignores the calls to internal functions (their time is added to the caller function). It shows the total number of calls to each function and the total time spent in the function inclusively and exclusively. The later is probably to most important hint for the point in the application that need optimising.

Always remember that premature optimisation is the mother of all evil.