academicpuma / citeproc-php
This is an effort to implement a full-featured standalone CSL processor in PHP. The code based on the implementation of Ron Jerome.
Installs: 371 957
Dependents: 2
Suggesters: 1
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- academicpuma/locales: >=1.0
- academicpuma/styles: >=1.0
Requires (Dev)
- phpunit/phpunit: 3.7.*
- phpunit/phpunit-skeleton-generator: 2.0.*
This package is auto-updated.
Last update: 2022-02-01 12:43:18 UTC
README
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
- lib-php-kar (GitHub)
- BibSonomy restclient-php (BitBucket)