kaiwa/clsi-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kaiwa/clsi-client

最新稳定版本:v1.0.0

Composer 安装命令:

composer require kaiwa/clsi-client

包简介

Client library for making requests to a CLSI (Common LaTeX Service Interface) server

README 文档

README

For sending LaTeX files to a compile server using the "Common LaTeX Service Interface"-API.

This library creates psr7-compatible http requests, so you can use any psr7-compatible http client for sending the created requests. You may take a look here for finding an http client.

For a CLSI server implementation see https://github.com/sharelatex/clsi-sharelatex

Usage

Guzzle client example

For the guzzle http client there is the GuzzleCompileRequestSender class included. It takes care of transforming the CompileRequest into an http request and also transforming the http response back into a CompileResponse.

You will need to require the suggested guzzlehttp/guzzle composer package.

require __DIR__.'/vendor/autoload.php';

use Kaiwa\Clsi as Clsi;

$compileRequest = new Clsi\Request\CompileRequest(
    'http://myclsiserver.com:3013',
    'myprojectId',
    new Clsi\Request\Resource\TextFileResource(__DIR__.'/test.tex')
);

// Optional: Add more resources
// $compileRequest->addResources(
//      new Clsi\Request\Resource\UrlResource('logo.png', 'http://myserver.com/logo.png')
// );

$sender = new Clsi\Bridge\Guzzle\GuzzleCompileRequestSender();
$compileResponse = $sender->send($compileRequest);

$compiledPdfUrl = $compileResponse->getOutputFile('pdf');

Any other psr7-compatible http client example

If you want to use any other psr7-compatible http client (or a particular Guzzle instance) you have to transform the CompileRequest into an http request and the http response into a CompileResponse manually.

require __DIR__.'/vendor/autoload.php';

use Kaiwa\Clsi as Clsi;

$compileRequest = new Clsi\Request\CompileRequest(
    'http://myclsiserver.com:3013',
    'myprojectId',
    new Clsi\Request\Resource\TextFileResource(__DIR__.'/test.tex')
);

// Optional: Add more resources
// $compileRequest->addResources(
//      new Clsi\Request\Resource\UrlResource('logo.png', 'http://myserver.com/logo.png')
// );

$compileRequestFactory  = new Clsi\Psr\PsrCompileRequestFactory();
$compileResponseFactory = new Clsi\Psr\PsrCompileResponseFactory();

// initiate your http client
$httpClient = new HttpClient();

// Transform the CompileRequest into an http request
$httpRequest = $compileRequestFactory->makePsrRequest($compileRequest);

// Send the http request with your client and get the response
$httpResponse    = $httpClient->send($httpRequest);

// Transform the http response into a CompileResponse
$compileResponse = $compileResponseFactory->makeCompileResponse($httpResponse);

// Work with the CompileResponse
$compiledPdfUrl = $compileResponse->getOutputFile('pdf');

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-08-06