\Pluf

The main class of the framework.

From where all start.

The __autoload function is automatically set.

Summary

Methods
Properties
Constants
start()
loadConfig()
loadRelations()
f()
pf()
factory()
loadFunction()
fileExists()
db()
getCurrentRequest()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

start()

start(  $config) 

Start the framework

Parameters

$config

loadConfig()

loadConfig(  $config_file) 

Load the given configuration file.

The configuration is saved in the $GLOBALS['_PX_config'] array. The relations between the models are loaded in $GLOBALS[ModelUtils::MODEL_KEY].

Parameters

$config_file

loadRelations()

loadRelations(  $usecache = true) 

Get the model relations and signals.

If not in debug mode, it will automatically cache the information. This allows one include file when many applications and thus many includes are needed.

Signals and relations are cached in the same file as the way to go for signals is to put them in the relations.php file.

Parameters

$usecache

f()

f(  $cfg,   $default = '') : mixed

Gets system configuration

Parameters

$cfg
$default

Returns

mixed —

Configuration variable or default value if not defined.

pf()

pf(  $pfx,   $strip = false) : array

Access an array of configuration variables having a given prefix.

Parameters

$pfx
$strip

Returns

array —

Configuration variables.

factory()

factory(  $model,   $params = null) 

Returns a given object.

Loads automatically the corresponding class file if needed. If impossible to get the class $model, exception is thrown.

Parameters

$model
$params

loadFunction()

loadFunction(  $function) 

Load a function depending on its name.

The implementation file of the function MyApp_Youpla_Boum_Stuff() is MyApp/Youpla/Boum.php That way it is possible to group all the related function in one file.

Throw an exception if not possible to load the function.

Parameters

$function

fileExists()

fileExists(string  $file) : mixed

Hack for [[php file_exists()]] that checks the include_path.

Use this to see if a file exists anywhere in the include_path.

$file = 'path/to/file.php'; if (Pluf::fileExists('path/to/file.php')) { include $file; }

Parameters

string $file

Check for this file in the include_path.

Returns

mixed —

Full path to the file if the file exists and is readable in the include_path, false if not.

db()

db(  $extra = null) : resource

Helper to load the default database connection.

This method is just dispatching to the function define in the configuration by the 'db_get_connection' key or use the default 'Pluf_DB_getConnection'. If you want to use your own function, take a look at the Pluf_DB_getConnection function to use the same approach for your method.

The extra parameters can be used to selectively connect to a given database. When the ORM is getting a connection, it is passing the current model as parameter. That way you could get different databases for different models.

Parameters

$extra

Returns

resource —

DB connection.

getCurrentRequest()

getCurrentRequest() : \Pluf_HTTP_Request|NULL

Get Curretn request

Returns

\Pluf_HTTP_Request|NULL