blend4php  v0.1
A PHP API for interacting with Galaxy
 All Classes Functions Variables Pages
blend4php Documentation


The blend4php package is a PHP wrapper for the Galaxy API ( It follows the lead of BioBlend ( which provides a Python package for interacting with Galaxy and CloudMan–hence the use of 'blend' in the name of this package. blend4php currently offers a partial implementation of the Galaxy API and includes support for datasets, data types, folder contents, folders, genomes, group roles, groups, group users, histories, history contents, jobs, libraries, library contents, requests, roles, search, tools, toolshed repositories, users, visualizations and workflows.

The motivation for development of this library is for integration with Tripal (, an open-source toolkit for creation of online genomic, genetic and biological databases. Integration of Tripal and Galaxy will allow the community research databases to provide next-generation analytical tools to their users using Galaxy. However, this library was created independently of Tripal to support integration of any PHP application with Galaxy.


To use blend4php, first include the file in your program. For example:

require_once('[blend4php installation dir]/')

Where [blend4php installation dir] is where the blend4php package is installed.

To Connect to a galaxy instance:

$galaxy = new GalaxyInstance($hostname, $port, $use_https);

The variables $hostname and $port should be the hostname (or IP address) and port number of the remote Galaxy server. If the server requires HTTPs then $use_https should be TRUE.

To authenticate and retrieve the user's API key for future requests:

$success = $galaxy->authenticate($username, $password, $error)
if (!$success) {
// Handle a failed authentication.

Where $username is the name of the user on the remote Galaxy server and $password is the user's password. The $error variable will contain any error message if authentication fails. The function will return false if authentication fails.

If the API key for the user is already known, the authentication step can be skiped and the API key directly set:


Where the $api_key variable contains the API key of the user on the remote Galaxy server.

To interact with Galaxy regarding jobs, workflows, users, etc. Please review the Classes pages for each respective class.

Error Handling

All functions in the blend4php library return FALSE on failure. If failure occurs then the most recent error can be retrieved using the following:

$error = $galaxy->getError();
$emessage = $error['message']
$etype = $error['type']

Alternatively, the message and type can be retrieved independently:

$emessage = $galaxy->getErrorMessage();
$etype = $galaxy->getErrorType();


This work is supported by the US National Science Foundation (NSF) award #1443040, titled “CIF21 DIBBS: Tripal Gateway, a Platform for Next-Generation Data Analysis and Sharing.”


blend4php is available under version 2 of the GNU General Public License