Joomla Platform
We can think of the Joomla CMS as a platform for building applications. We can also view the Joomla CMS as an application that sits on top of something even more fundamental, something that forms the foundation on which everything in Joomla is built. That something is the Joomla Platform. It has been previously called “the Joomla Framework”, “the Joomla libraries”, and probably many other things. What we are talking about though is what can be found inside the “libraries” folder of the Joomla distribution.
Prior to version 1.5 of Joomla, the foundational classes and functions that made Joomla run were all jumbled up in a handful of files within the “includes” folder. For Joomla 1.5, it was decided that we needed a cleaner, more maintainable way of keeping foundational code organized. We wanted things to look and feel familiar to someone coming from a professional development background where frameworks are relied upon to provide foundational logic. For example, we wanted Joomla development to be more comfortable for people coming from a Java or .NET background. Because of this we set out to build what is now known as the Joomla Platform.
When you first look in the “libraries” folder you see four folders and one PHP file (along with the obligatory HTML file). Within the "loader.php" file there is a very important class and two very important functions. The class is called "JLoader" and this is the class that handles including platform libraries so that you can use them in your projects. We will go over this further in a later chapter. The two functions are "jexit()" and "jimport()".
The jexit() function is a wrapper around the PHP "exit" function (actually a language construct). It exists to make unit testing easier and you should always use it in your scripts instead of using exit() directly. The "jimport()" function is a shorthand way of calling "JLoader::import()" and is intended to provide a similar syntax to the "import" statement in Java or the "using" statement in C#. The general idea is that you give the "jimport()" method a dot-separated path to the library you want to use and then the platform makes sure it is available to you when you use it.
The four main folders are “joomla”, “phpmailer”, “phputf8”, and “simplepie”. The three that are not “joomla” are third party library packages that the Joomla CMS uses to provide various functionality.
- "phpmailer" is a package for handling complex email sending written in PHP.
- "phputf8" is a package for making PHP more UTF8 friendly and is used to augment the native PHP functionality for dealing with UTF8 strings.
- "simplepie" is a package to handle parsing XML feeds such as ATOM and RSS. The “joomla” folder contains all of the libraries that comprise the Joomla Platform.
- "config.php" is a default configuration file that includes the basic configuration options that are likely used by the Joomla Platform regardless of the application.
- "factory.php" contains a static class called JFactory and provides an easy way to get various system objects from a common interface.
- "import.php" is the include file to bootstrap the platform. This file is the first thing included when you intend to use the Joomla Platform in any software project. The Joomla CMS bootstraps the platform for you in the beginning of the request cycle so it isn’t something you will have to worry with unless you are writing a separate application altogether.
- "methods.php" contains some static helper classes for interacting with URLs and translating text.
- "version.php" contains a static class which holds various version information about the distribution.
There are five PHP files directly in the “libraries/joomla” folder.
The folders found inside of “libraries/joomla” are known as library packages and are grouped logically around the type of functionality they provide.
Library Package |
Description |
access |
Functionality for the access control, or permissions, system. |
application |
Functionality for extensions as well as the main application class. |
base |
Very low level classes that are generally very abstract and implement some sort of design pattern or data structure. |
cache |
Classes that handle data caching of various types and storage mechanisms. |
client |
Client classes to connect to various servers such as FTP or LDAP. |
database |
Classes used for connecting to and interacting with databases. |
document |
Classes for building and manipulating the document that is eventually sent to the browser. |
environment |
Classes for interacting with the request (GET, POST, COOKIE values) and the response headers. |
error |
Classes that help with error handling. |
event |
Classes that constitute our event system so that we can listen to and fire events. |
filesystem |
Classes used for interacting with the file system. |
filter |
Classes for sanitizing and filtering input and output values. |
form |
Classes to help with building, manipulating, and processing web forms. |
html |
Helper methods for quickly generating HTML markup and easily loading CSS or Javascript. |
installer |
Classes for installing and upgrading application extensions. |
language |
Classes for translating strings into different languages. |
|
Helper methods to send email. |
plugin |
Classes related to the plugin system. |
registry |
Classes for working with complex data objects. It allows you to import and export to various formats including INI, JSON, and XML. |
session |
Classes for creating, manipulating, and storing the session. |
updater |
Classes for supporting auto-updating extensions. |
user |
Classes for manipulating or interacting with users. |
utilities |
Helper classes that don’t otherwise fit into a separate package. |
Figure 14: Joomla Platform Packages