Installing external libraries

Plpugins may also require external libraries that they are dependent upon to be downloaded. This requires several things: a specific declaration in the plugin.xml file, and the existence of a /lib directory that is write accessible in the SPIP root directory, into which the library will be automatically (or manually) loaded.

<necessite id="lib:nom" src="address of the zip file" />
  • nom specifies the name of the zip’s uncompressed folder
  • src is the address of the library archive in zip format


A plugin called "loupe photo"" uses a javascript library that it installs as a library (therefore outside of the plugin itself) in this manner:

<necessite id="lib:tjpzoom" src="" />

In the plugin, the names of the files that the plugin uses are listed like this:

$tjp = find_in_path('lib/tjpzoom/tjpzoom.js');

The "Open ID" plugin also uses a library that is external to the plugin. It loads it in the following manner:

<necessite id="lib:php-openid-2.1.2" src="" />

And then uses that library as below:

// options
if (!defined('_DIR_LIB')) define('_DIR_LIB', _DIR_RACINE . 'lib/');
define('_DIR_OPENID_LIB', _DIR_LIB . 'php-openid-2.1.2/');

// usage (somewhat more complicated!)
function init_auth_openid() {
	// ...
	$cwd = getcwd();
	require_once "Auth/OpenID/Consumer.php";
	require_once "Auth/OpenID/FileStore.php";
	require_once "Auth/OpenID/SReg.php";
	// ...

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français, Nederlands