2017 © Pedro PelĂĄez
 

library tex-tools

PHP library for (La)TeX abstraction

image

corny-phoenix/tex-tools

PHP library for (La)TeX abstraction

  • Monday, July 4, 2016
  • by CornyPhoenix
  • Repository
  • 2 Watchers
  • 3 Stars
  • 354 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 23 % Grown

The README.md

TeX Tools for PHP 0.3

Build Status Code Climate Test Coverage, (*1)

PHP library for (La)TeX abstraction, (*2)

Installation

Add following to your composer.json:, (*3)

"require": {
    "corny-phoenix/tex-tools": "dev-master"
}

Supported TeX Commands

The following TeX commands are supported:, (*4)

Command Required format Provided formats
TeX .tex .dvi, .log, .aux
PdfTeX .tex .pdf, .log, .aux
LaTeX .tex .dvi, .log, .aux
PdfLaTeX .tex .pdf, .log, .aux
XeLaTeX .tex .pdf, .log, .aux
LuaLaTeX .tex .pdf, .log, .aux
BibTeX .aux .bbl, .blg
BibTeX8 .aux .bbl, .blg
MakeIndex .idx .ind, .ilg
DviPs .dvi .ps

Usage

Create a basic PdfLaTeX job and run it:, (*5)

use CornyPhoenix\Tex\Repositories\TemporaryRepository;

$job = (new TemporaryRepository())->createJob( /* TeX source */ );
$job->runPdfLaTex();
$job->hasErrors(); // False if everything went fine

You can also chain LaTeX calls:, (*6)

use CornyPhoenix\Tex\Repositories\TemporaryRepository;
use CornyPhoenix\Tex\Exceptions\CompilationException;

$job = (new TemporaryRepository())->createJob( /* TeX source */ );
$job->runPdfLaTex()
    ->runBibTex()
    ->runMakeIndex()
    ->runPdfLaTex()
    ->runPdfLaTex();

There is a lovely interface for handling errors:, (*7)

use CornyPhoenix\Tex\Repositories\TemporaryRepository;
use CornyPhoenix\Tex\Exceptions\CompilationException;

$job = (new TemporaryRepository())->createJob( /* TeX source */ );
try {
    $job->runPdfLaTex()
        ->runBibTex()
        ->runMakeIndex()
        ->runPdfLaTex()
        ->runPdfLaTex();
} catch (CompilationException $e) {
    $format = 'Error in %s, line %d: %s';
    $log = $job->createLog();

    foreach ($log->getErrors() as $error) {
        echo sprintf(
            $format, 
            $error->getFilename(),
            $error->getLine(),
            $error->getMessage()
        );
        // handle error ...
    }
}

Also, there is a safe clean method which will clean up your working directory without deleting the input file or any files unknown to TeX:, (*8)

use CornyPhoenix\Tex\Repositories\TemporaryRepository;

$repo = new TemporaryRepository();
touch($repo->getDirectory() . '/file.unknown.to.tex');
$repo->clean();
assert(file_exists($repo->getDirectory() . '/file.unknown.to.tex')); // True

The Versions

04/07 2016

dev-develop

dev-develop https://github.com/CornyPhoenix/tex-tools

PHP library for (La)TeX abstraction

  Sources   Download

MIT

The Requires

 

The Development Requires

pdf latex bibtex tex xelatex lualatex post script

04/07 2016

dev-master

9999999-dev https://github.com/CornyPhoenix/tex-tools

PHP library for (La)TeX abstraction

  Sources   Download

MIT

The Requires

 

The Development Requires

pdf latex bibtex tex xelatex lualatex post script

04/07 2016

0.3

0.3.0.0 https://github.com/CornyPhoenix/tex-tools

PHP library for (La)TeX abstraction

  Sources   Download

MIT

The Requires

 

The Development Requires

pdf latex bibtex tex xelatex lualatex post script

26/04 2016

0.2

0.2.0.0 https://github.com/CornyPhoenix/tex-tools

PHP library for (La)TeX abstraction

  Sources   Download

MIT

The Requires

 

The Development Requires

pdf latex bibtex tex xelatex lualatex post script

10/01 2016

0.1

0.1.0.0 https://github.com/CornyPhoenix/tex-tools

PHP library for (La)TeX abstraction

  Sources   Download

MIT

The Requires

 

The Development Requires

pdf latex bibtex tex xelatex lualatex post script