2017 © Pedro Peláez
 

library clsi-client

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

image

kaiwa/clsi-client

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

  • Monday, April 4, 2016
  • by packagist
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

CLSI Client Library

For sending LaTeX files to a compile server using the "Common LaTeX Service Interface"-API., (*1)

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., (*2)

For a CLSI server implementation see https://github.com/sharelatex/clsi-sharelatex, (*3)

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., (*4)

You will need to require the suggested guzzlehttp/guzzle composer package., (*5)

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., (*6)

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');

The Versions

04/04 2016

dev-master

9999999-dev

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

  Sources   Download

The Requires

 

by kaiwa

07/08 2015

v1.0.0

1.0.0.0

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

  Sources   Download

The Requires

 

by kaiwa