Mammut Framework

Developer handbook :: Framework :: Basics

System requirements

Minimum requirements are PHP >= 5.1 with the SPL and the Perl RegEx (pcre) extensions, which should be installed by default.

Using Mammut

To use the framework, you just need to add a few lines of code at the beginning of your work:

// extend include path to libary base path
set_include_path(get_include_path().PATH_SEPARATOR.'.\lib');
 
// load the framework
define('USE_MAMMUT',true);
require('Mammut/lib.mammut.php');
 
// EXAMPLE: load a classes and a libary
import('Mammut.DB.MFDB');
importlib('Mammut.array');

OOP in Mammut

Object orientation is one of the newest, and also, most incomplete features of php. The lack of namespaces and only rudimeary method overloading signatures reduces the oop usability a lot. PHP >= 5.3 will fix some of the missings, but you have to "be good" if you want to write clean and reusable code.

While 5.3 is not commonly avaible, we need to have some workarounds for the lack of namespaces. To prevent class name crashes, there is a simple Rule: Mammut Framework classes starts with MF in their name, Mammut CMS starts with MM. All subfolders will be added with cameltyping, the Image package classes of the framework will start with MFImage... , for example. You should use your own two to three caracter prefix for your classes.

To load a class, the import($classpath) function is provided. It checks it the class is loaded already, and loads it if not.

import('Mammut.DB.MFDB')

This will import the MFDB class of the DB framework package.

Loading additional libaries is handled in the same way, with the importlib($ident) function:

importlib('Mammut.array');

This will load the array libary of the framework.