class LatexCompiler

Properties

$fileName
$template
$pdfUrl
protected $data
protected $pdfName
protected $runs
protected $view
protected $tempPath
protected $buildDir
protected $buildPath
protected $pdfPath

Methods

__construct()

No description

$this
compile(string $fileName)

Define the name of the file to be compiled without file suffix

$this
with($data)

Set data to be passed to the view

$this
runs(int $runs)

Override default runs

$this
in(string $view)

Define view

true
deletePdf()

Delete PDF file

string
storagePath(string $storagePath)

Set Storage Path

$this
run()

Compiles the PDF and store the path to the file

string
fillTemplate()

Fills in the template

writeToFile()

Writes filled in template to file

compileTex()

Sends to terminal to compile in tex

handlePDF()

Check for existing PDF and move from temp

tearDownTemp()

Deletes build directory

makeTempDir()

Makes build directory

Details

at line 33
__construct()

at line 50
$this compile(string $fileName)

Define the name of the file to be compiled without file suffix

Parameters

string $fileName

Return Value

$this

at line 65
$this with($data)

Set data to be passed to the view

Parameters

$data

Return Value

$this

at line 79
$this runs(int $runs)

Override default runs

Parameters

int $runs

Return Value

$this

at line 93
$this in(string $view)

Define view

Parameters

string $view

Return Value

$this

at line 106
true deletePdf()

Delete PDF file

Return Value

true

at line 120
string storagePath(string $storagePath)

Set Storage Path

Parameters

string $storagePath overrides default storage path

Return Value

string

at line 133
$this run()

Compiles the PDF and store the path to the file

Return Value

$this

Exceptions

Exception

at line 152
string fillTemplate()

Fills in the template

Return Value

string Compiled template

Exceptions

Throwable

at line 163
protected writeToFile()

Writes filled in template to file

at line 178
protected compileTex()

Sends to terminal to compile in tex

Sets the absolute file position on the disk and attempts to run pdf latex after cding into the directory. If the exit code is anything other than 0, it logs the error in the latex.log, tears down the temp directory, and throws a new exception which can be caught if desired.

Exceptions

Exception indicates failure to finish compiling in the shell.

at line 202
protected handlePDF()

Check for existing PDF and move from temp

Checks the PDF path to see if there is already a PDF with the same name. If there is, it deletes the PDF in the path and then moves the new PDF there. If not, then it moves the PDF.

at line 211
protected tearDownTemp()

Deletes build directory

at line 219
protected makeTempDir()

Makes build directory