This is an outdated version of the Manual. Visit the NEW Manual


Replica is the build script for RedBeanPHP. The all-in-one package on the homepage has been built using Replica.

Using Replica you can build your own all-in-one PHP file. Replica reads the replica.xml file which contains a list of files to be added to the rb-file. The R-facade class is dynamically generated by Replica.

This is what a line in the replica.xml file looks like:

<item type="php">RedBean/Logger.php</item>

This line will instruct Replica to add the PHP file RedBean/Logger.php to the package.

To run replica type:

php replica.php

Replica will tell you which files are included in the build:

Adding: RedBean/license.txt

Afterwards, you will find the all-in-one file in your directory:


Flavours (version 3.3+)

It's possible to not generate just one but several all-in-one packages, all containing different collections of php files. These additional versions are called flavours. To add a php file to a 'flavour' called 'oci' we can use:

<item type="php" flavour="oci">RedBean/QueryWriter/Oracle.php</item>

This line will add the Oracle driver to the rboci.php file. This file has the same contents as rb.php but with the addition of the Oracle.php file.

Replica will report about flavour specific items:

Adding: RedBean/QueryWriter/Oracle.php to flavour: oci

And after running Replica you will see two builds in your directory:


Replica and Plugins (version 3.3+)

Plugins can add static methods to the R facade class. To do so, a plugin has to add a comment containing the @plugin section. What comes after the word @plugin will be inserted into the R-facade class.

For instance, consider the imaginary plugin 'CSVImport'. If we add the line:

// @plugin public static function CSV($file){ ... }

And we include an entry to the XML configuration:

<item type="php" >RedBean/Plugins/CSVImport.php</item>

then we can now use the method:


Which allows us to dynamically add methods to the R-facade class.


RedBeanPHP Easy ORM for PHP © 2019 Gabor de Mooij and the RedBeanPHP community - Licensed New BSD/GPLv2