Scorpio Development Update November 2009

Posted by Dave Redfern (Writer), News on 04 Nov 2009 @ 04:17

Scorpio development update - updated libraries

It has been a while since the last Scorpio release and a news update is in order. Work is progressing on the next major version (currently 0.3) which will feature some major updates to several core components as well as new components. What sort of updates?

General changes

ereg() has been removed completely from all Scorpio libs. It is still present in some of the third party libraries, but Scorpio is well on the way to full PHP 5.3 E_STRICT standards.

There have been some files moved around and a little additional order brought to the utility classes.

A number of bugs have been worked out and the API docs improved and clarified. Additionally, methods that were previously missing docblocks have been updated.

mvcControllerBase

The mvc controller system has been reworked slightly and now all controllers require the constructor take an instance of mvcRequest. This removes one of the last uses of mvcRequest::getInstance() - which was the ultimate goal. Other changes include moving all the xajax controls out of base into a dedicated xajax controller. This is inline with plans to remove xajax from Scorpio in a future release.

Several of the base website controllers have been rebuilt and moved into the core library to make it easier to use them and there is now a dedicated mvcErrorController for handling errors generated inside the mvc system. This error system allows for error views to be fully templated via the template engine. Additional template engines are now supported to. Twig, Savant3 and PHPTal are now all supported in the mvcViewEngine and Smarty 3 can be used as a drop-in replacement with a minor change to systemSmartyBase to call parent::__construct() instead of parent::Smarty(). Smarty 3 will not be upgraded until it has reached a stable release.

mvcAutoload

The mvcAutoload system has been reworked a little to try and decouple it further from the distributor and the request, however this it is still tightly coupled and the logic may end up being moved into the distributor. At any rate, mvcAutoload now requires initialising before it can be used. This is setup automatically by the distributor.

mvcViewBase

HTTP headers can now be set for the views. Previously these had to be hard-coded, but now they can be added to an internal array and output with the render calls. Class constants have been pre-defined for several of the more common headers.

mvcDistributorBase

The primary distributor has been refactored a little and a dedicated mvcDistributor class created based on what was previously in websites/base/index.php. This is now the main, reference implementation.

An additional plugin event has been added for onShutdown() so plugin calls can be triggered as the distributor finishes the request.

Better Cygwin compatibility

Several updates have been made to the main system class so that it can correctly set the path when running under the Cygwin DLL on Windows. This fixes several issues were log files end up being placed in a cygwin/c/....../thing.log within the logs folder, while not a major issue it could be annoying when trying to tail logs.

Better exception/error Handler messages

The output generated for unhandled exceptions and user triggered errors has been improved to give clearer information and better traces. Part of these improvements are the truncation of the paths to be just the path within the framework base. The base path is then listed after the error. This makes the output considerably neater.

Traces are now better handled and are re-organised to place the function or class->method before the file and function traces are now in the reverse order, so originate from the function that called the triggered error (much like exceptions).

Reduced required libraries

Work has been done to reduce the number of required libraries in the main system.inc page and now far more of the framework can be autoloaded. The systemAutoload library can almost be used standalone.

Previously many includes were needed by the Scorpio bootstrap (system.inc -> system::init() call). This has now been reduced to just two files.

New Stuff

And now the new stuff! We've already touched on the mvcErrorController and the xajax controller but what other new components are there?

mvcViewHelper

The mvcViewBase now has a view helper system that is agnostic of the template engine. Currently no helpers are defined as there is one major caveat to using them. The caveat is: the view must be added to the template engine WITHOUT being wrapped in the output wrapper - unless you can define ahead of time the helpers that are needed for the view.

Why is this the case? Well the output wrapper blocks all access to methods that are not expressly defined to be executed. Those methods include get, is, has, count and allow but view helpers can be any method name and are called via the __call() magic method.

The other reason, is that Scorpio uses Smarty and has a collection of Smarty plugins already that are view helpers. As such it is included more for the PHP engine than anything else.

feedManager

Scorpio now has an RSS feed reader. It supports RSS1/2 and Atom 1.0. It's a light weight implementation and other types may be added but so far there seems to be little utility as other formats are seldom used.

feedManager supports caching of content and returns the feed in an easily foreachable set.

Report System

A report system has been added that provides a generic framework for creating reports; as in literal reports with numbers and things that can then be turned into Excel spreadsheets or PDF files.

The reports extend the reportBase and implement a few methods that generate a reportData object which can be cached. The reportData object is then used by the writers when reports are downloaded. Any backend can be used that you would need as sourcing the data is upto the individual report. As an example: data could be pulled from SOAP, XML, RSS, SQL, PHP, other processes - anything PHP can access in fact.

How reports are managed is up to the developer to implement. A queuing system is strongly encouraged.

Report data can be converted into several formats including XLS, CSV, PDF, HTML (ready for display) and XML. Additional formats can be added by implementing the appropriate interface (e.g. JSON).

Validation Framework

Perhaps a component that should have been added earlier; a validation framework has been added. This allows an associative array of values to be validated against a variety of validators. The data can come from any source as the validator does not use any of the super global variables.

There are several validators bundled with Scorpio covering numbers, floats, strings, dates and times, email addresses, URIs and IP addresses. Additional validators can be added by implementing the interface.

The validation layer is translation ready and the utilityValidator keys the errors to the specific array keys so you can match messages to form values or screen output.

Simple Permissions Framework

The baseAdminSite user framework has been refactored into a generic permissions system. This is activity and role based where a role has certain permissions with the default being no-access at all. Permissions can be assigned to the role, but the individual user can have these augmented with individual level permissions that can explicitly allow or deny an activity.

Inheritance is deliberately avoided in this system, in favour of a simpler, cleaner (albeit slightly higher maintenance) system. When coupled with an auto-generation system that automatically builds and assigns activities, the short-comings can be largely factored out (e.g. the implementation in baseAdminSite).

Stuff that has been removed and wrap up

The last part of this update is an overview of things that have been removed or deprecated. Some of these have been previously discussed so should not come as a surprise.

baseAdminSite

The baseAdminSite and related files have now been removed. While it was useful, it was heavily dependent on MySQL. The remaining components are now the dbUpdateLog and WURFL layer which are still included.

The removal of the baseAdminSite has seen the removal of the systemUser and related classes and most other data access objects that require MySQL.

The baseAdminSite is being turned into a component that can be added to Scorpio as a separate download and is being re-themed and re-structured in the process.

xajax uncompressed javascript files

The uncompressed xajax javascript library files have been removed. There was not much point in having them lying around. The language files remain.

Spellify

As almost every browser now comes with a built-in spellchecker, spellify has been removed.

Prototype, Scriptaculous

As spellify has been removed, Prototype JS and Scriptaculous have also been removed. In fact based on the lack of progress with both libraries and that tying into a single JS framework serves no purpose, all other files were removed as well.

TinyMCE

As with Prototype etc, TinyMCE has been removed. This has helped heavily reduce the size of the 0.3 distribution.

Other items removed

The last items removed include the SQL data files and test cases for the other items already mentioned as well as the favicon and the baseAdminSite theme.

Deprecated methods

Because several DAOs were removed, several methods have had to be deprecated or now return a different instance. These include:

mvcSiteConfig->getSystemSite() - systemSite no longer exists
systemConfig->getFolderPlugins() - previously marked deprecated, now removed
mvcDistributorBase->getPluginFile() - now handled via the systemAutoload

Wrapping Up

There is still work to be done before 0.3 is ready for release - namely testing and test cases, but it is already shaping up to be a much more rounded version. Setting up will be easier and not so many libraries are required by default - in fact systemAutoload requires only systemException and its exception library to run.

Time frame for release? Because of the changes to the MVC layer and the new validators, the current plan is for a December or January release. As always, the latest work can always be obtained from SVN.

Additional articles looking at the validators and the feed reader will come in time.

< Return to article