I am trying to display a bibliography in PHP and allowing the use of CSL to format it, but am coming up short of good examples of how to implement it. Basically, I am looking for a library or script which can take a bibliography, in the form of Bibtex or JSON or similar, and output it as HTML through PHP.
Formatting with CSL, through for example citeproc-php, would accomodate a vast variety of output styles. Does anyone know of any examples of this, or up-to-date libraries for doing so?
The author of citeproc-php answered an issue on GitHub with some details:
<?php
include 'vendor/autoload.php';
use \AcademicPuma\CiteProc\CiteProc;
$bibliographyStyleName = 'apa';
$lang = "en-US";
$csl = CiteProc::loadStyleSheet($bibliographyStyleName);
$citeProc = new CiteProc($csl, $lang);
$file = file_get_contents("citations.json");
$data = json_decode($file);
echo "<ul>";
foreach ($data as $item) {
echo "<li>".$citeProc->render($item)."</li>";
}
echo "</ul>";
?>
And this works as expected with a sample citations.json from citeproc-js.