Library Organisation in Seagull


The library classes used in the Seagull framework basically fall into the following groups:

  • Controllers - workflow
  • Core - general
  • Tasks - mostly used to do setup tasks
  • Filters - modify the request and response objects as they pass through the filter chain
  • PEAR libs - general

Developing with Seagull involves building modules that include one or more manager classes to implement business logic. Building managers is eased by using the module creator wizard and above-listed library resources. For a typical project you will probably only ever use the Controllers, Core and PEAR libs.

The following sections explain the library groupings and describe the basically functionality of each class. This will be of more interest to advanced devs, beginners need not worry as default task and filters are all you'll need for basic web apps.

Controller Classes

The controller classes manage application workflow, several examples are provided but it's very easy to write your own.

Class name Availability Methods Description
SGL_FrontController default * run The FrontController is used to organise workflow for particular application types. You will probably use similar controllers for each application you build, although workflow can be easily customised. See the unit test controller versus the Seagull one for ideas on how to customise.
SGL_Manager default * validate
* process
* display
* maintainState
The Manager class is an app controller, it sets out generic validate/process/display workflow.
SGL_Wizard default * validate
* process
* display
* maintainState
The Wizard class is a specialisation of the Manager class, use it to create wizard workflows in your applications.

Core Classes

The core classes are what you use in your managers to manipulate system, application and user resources. Availability refers to whether you need to include the class or not, anything labelled as 'default' is available within the application scope, like default classes in, eg, java.lang. 'Requirable' libs need to be included.

Class name Availability Methods Description
SGL default Provides a set of static utility methods used by most modules
SGL_Request default Wraps all $_GET $_POST $_FILES arrays into a Request object, provides a number of filtering methods
SGL_Output default The SGL_Ouput class is known as a TemplateHelper in other contexts, it wraps methods used by the template engine to transform the data into, eg, html.
SGL_Config default Config file parsing and handling, acts as a registry for config data
SGL_Registry default Generic data storage object, referred to as $input. Holds references to Url, Request and Config singletons
SGL_DB default Mostly used as a DB resource singleton, also provides dsn building method
SGL_ServiceLocator default Facilitates switching resources at runtime, eg, so a test database resource can be swapped in for the dev one
SGL_Url default Provides URI related functionality, derived from Net_URL and uses a parser strategy
SGL_HTTP default Provides HTTP functionality including redirects
SGL_Session default Handles session management, most methods are static
SGL_String default Various string helper methods
SGL_Array default Provides array manipulation methods
SGL_Date default Provides various date formatting methods
SGL_Inflector default Performs transformations on resource names, ie, URIs, classes, methods, variables
SGL_Delegator default PHP 4/5 compatible class for aggregating objects
SGL_Util default Various utility methods
SGL_Category requirable Wrapper to SGL_NestedSet, used to manipulate Categories
SGL_Emailer requirable Utility class that wraps PEAR::Mail, provides convenience methods for sending HTML emails
SGL_TaskRunner requirable Used for building and running a task list
SGL_NestedSet requirable A lightweight wrapper to PEAR DB_NestedSet that bypasses DB_NestedSet for most methods
SGL_Download requirable Wrapper around PEAR HTTP/Download class to workaround some limits of that class
SGL_Item requirable Acts as a wrapped for content objects
SGL_Sql requirable Provides SQL schema and data parsing/executing methods
SGL_Install requirable Provides various static methods required for install routine


All filters are optional, configurable, and can be ordered according to need.

The process tasks below implement the Intercepting Filter pattern, each filter must extend SGL_DecorateProcess and acts as a filter pass on the Request object.

Class name Availability Group Description
SGL_Process_Init default pre-process
SGL_Process_AuthenticateRequest default pre-process
SGL_Process_BuildHeaders default pre-process
SGL_Process_CreateSession default pre-process
SGL_Process_DetectBlackListing default pre-process
SGL_Process_DetectDebug default pre-process
SGL_Process_DiscoverClientOs default pre-process
SGL_Process_ResolveManager default pre-process
SGL_Process_SetupLangSupport default pre-process
SGL_Process_SetupLocale default pre-process
SGL_Process_SetupPerms default pre-process
SGL_MainProcess default main process
SGL_PostProcess default post-process
SGL_Process_SetupNavigation default post-process
SGL_Process_SetupBlocks default post-process
SGL_Process_SetupWysiwyg default post-process
SGL_Process_GetPerformanceInfo default post-process

The install tasks below are simple units of work that can optionally take an argument, ie $data. Each must extend SGL_Task or a specialisation of it.


Class name Availability Group Description
SGL_EnvSummaryTask default install
SGL_Task_GetFilesystemInfo default install
SGL_Task_GetLoadedModules default install
SGL_Task_GetPearInfo default install
SGL_Task_GetPhpEnv default install
SGL_Task_GetPhpIniValues default install
SGL_Task_SetupPaths default install
SGL_Task_SetupConstants default install
SGL_Task_SetBaseUrl default install
SGL_Task_CreateConfig default install
SGL_UpdateHtmlTask default install
SGL_Task_CreateTables default install
SGL_Task_LoadDefaultData default install
SGL_Task_CreateConstraints default install
SGL_Task_VerifyDbSetup default install
SGL_Task_CreateFileSystem default install
SGL_Task_CreateDataObjectEntities default install
SGL_Task_SyncSequences default install
SGL_Task_CreateAdminUser default install
SGL_Task_InstallerCleanup default install

Interfaces and Abstract Classes

  • SGL_Manager
  • SGL_Observer
  • SGL_Observable
  • SGL_View
  • SGL_Task
  • SGL_OutputRendererStrategy
  • SGL_ProcessRequest
  • SGL_DecorateProcess