Exploit biodiversity data with PHP and Drupal thanks to the PHP GBIF library
The Musa in situ project, led jointly by CIRAD and Bioversity, collects data on Musaceae1 around the world, in the wild or in the closest to natural growing conditions. The main purpose is to obtain an as precise as possible picture of the natural geographical diversity of Musaceae. Although it initially relied on an iNaturalist project, it now integrates other sources of data, particularly GBIF (Global Biodiversity Information Facility), which facilitates open access to biodiversity data worldwide. In particular, GBIF provides a REST interface to these data.
GBIF also provides an access through a web interface which internally consumes this REST service. However, for the Musa in situ project, it was best to request these data directly from our site—ideally with a view, so that we could select which data should be imported into the local database, and so that we were able to ensure coherence with what had already been imported, or what we refrain from importing.
As it happens, a reference implementation is available for the R language, namely rgbif. This client is an abstraction allowing to interrogate the GBIF database without the need to delve into web services requests. It was ported (more or less comprehensively) to Python (pygbif) and Ruby (gbifrb). From now on, we can also count on PHP GBIF, developed as part of this project. Our hope is that this free2 project may be useful to other individuals and entities who wish to interact with this central repository of biodiversity worldwide.
Installing is as simple as a
composer require restelae/php-gbif. This library requires PHP version 7.2 or later. All the necessary usage information can be found on its homepage as well as the documentation automatically generated with Doxygen.
We also wrote a module for Drupal3 which relies on this library and allows to display occurrences from GBIF with Views, only in site building, with web service calls, without interrogating the local database! Coupled with the Views Bulk Operations module, you may use it to process GBIF occurrences on your website, e.g. to import them locally with the Migrate module.
Currently, this project only supports occurrences (search and retrieval) and species. We are looking for sponsors and contributors to implements the whole API, and thus greatly facilitate access to GBIF data to all projects written in PHP. Do not hesitate to contact us in case you are interested!