class LatexCompiler (View source)

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

__construct()

$this compile(string $fileName)

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

Parameters

string $fileName

Return Value

$this

$this with($data)

Set data to be passed to the view

Parameters

$data

Return Value

$this

$this runs(int $runs)

Override default runs

Parameters

int $runs

Return Value

$this

$this in(string $view)

Define view

Parameters

string $view

Return Value

$this

true deletePdf()

Delete PDF file

Return Value

true

string storagePath(string $storagePath)

Set Storage Path

Parameters

string $storagePath overrides default storage path

Return Value

string

$this run()

Compiles the PDF and store the path to the file

Return Value

$this

Exceptions

Exception

string fillTemplate()

Fills in the template

Return Value

string Compiled template

Exceptions

Throwable

protected writeToFile()

Writes filled in template to file

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.

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.

protected tearDownTemp()

Deletes build directory

protected makeTempDir()

Makes build directory