academicpuma / citeproc-php
1.0.0
2015-09-15 09:01 UTC
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
描述
这是一个在PHP中实现独立CSL处理器的尝试。该程序可用于使用CSL样式表渲染参考文献列表。此存储库是rjerome的实现的分支(显然不再维护)。
一些优势
- 使用Composer
- 每个类都位于单独的文件中
- 使用命名空间
- 使用Composer的自动加载器
- 使用PHPUnit进行测试
使用Composer安装citeproc-php
使用Composer将citeproc-php添加到您的应用程序
$ composer require academicpuma/citeproc-php
如何使用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));
?>
设置工作区
$ cd /path/to/your/php/workspace
$ hg clone https://seboettg@bitbucket.org/seboettg/citeproc-php
$ composer install
您可以将Apache配置为在网页上查看测试结果。因此,您可以使用自定义虚拟主机配置Apache。
<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>
将'/path/to/your/php/workspace/'替换为您的路径,将'citeproc.local'替换为您喜欢的域名。
如果您想使用自己的主机地址,别忘了将其追加到/etc/hosts
127.0.0.1 citeproc.local localhost
重启Apache
$ sudo apachectl restart
或
$ sudo /etc/init.d/apache2 restart
打开浏览器并输入您选择的主机地址,一旦Apache完成。
使用citeproc-php的已知软件包
- lib-php-kar(GitHub)
- BibSonomy restclient-php(BitBucket)