PHP code example of kaiwa / clsi-client

1. Go to this page and download the library: Download kaiwa/clsi-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kaiwa / clsi-client example snippets




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



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