academicpuma/citeproc-php

This package is abandoned and no longer maintained. The author suggests using the seboettg/citeproc-php package instead.

This is an effort to implement a full-featured standalone CSL processor in PHP. The code based on the implementation of Ron Jerome.

1.0.0 2015-09-15 09:01 UTC

This package is auto-updated.

Last update: 2022-02-01 12:43:18 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Build Status

Description

This is an effort to implement a standalone CSL processor in PHP. This program can be used to render bibliographies using CSL Stylesheets. This repository is a fork of the implementation of rjerome (apparently no longer maintained).

Some advantages:

  • uses Composer
  • each class is located in a separate file
  • uses namespaces
  • uses the autoloader of Composer
  • uses PHPUnit for testing

Installing citeproc-php using Composer

Use Composer to add citeproc-php to your app:

$ composer require academicpuma/citeproc-php

How to use citeproc-php

<?php
include 'vendor/autoload.php';
use \AcademicPuma\CiteProc\CiteProc;

$bibliographyStyleName = 'apa';
$lang = "en-US";

$csl = CiteProc::loadStyleSheet($bibliographyStyleName); // xml code of your csl stylesheet

$citeProc = new CiteProc($csl, $lang);

// $data is a JSON encoded string
echo $citeProc->render(json_decode($data));
?>

Setup a workspace

$ cd /path/to/your/php/workspace
$ hg clone https://seboettg@bitbucket.org/seboettg/citeproc-php
$ composer install

You can setup your apache to see the test results on a webpage. Therefor you can configure your apache with an custom virtual host:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName citeproc.local
        DocumentRoot /path/to/your/php/workspace/citeproc-php/tests
        ErrorLog "/var/log/apache2/citeproc.error.log"
        CustomLog "/var/log/apache2/citeproc.access.log" common

        <Directory /path/to/your/php/workspace/citeproc-php/tests>
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

Replace '/path/to/your/php/workspace/' with your path and replace 'citeproc.local' with your favourite host name.

If you want to use your own host address don't forget to append them to /etc/hosts:

127.0.0.1       citeproc.local localhost

Restart your apache

$ sudo apachectl restart

or

$ sudo /etc/init.d/apache2 restart

Open your browser and enter your chosen host address, as soon as apache has finished.

Known packages using citeproc-php