Documentation

BladeCompiler extends Compiler
in package
implements CompilerInterface Uses CompilesAuthorizations, CompilesComments, CompilesComponents, CompilesConditionals, CompilesEchos, CompilesIncludes, CompilesInjections, CompilesJson, CompilesLayouts, CompilesLoops, CompilesRawPhp, CompilesStacks, CompilesTranslations

Interfaces, Classes and Traits

CompilerInterface

Table of Contents

$cachePath  : string
Get the cache path for the compiled views.
$compilers  : array<string|int, mixed>
All of the available compiler functions.
$conditions  : array<string|int, mixed>
All custom "condition" handlers.
$contentTags  : array<string|int, mixed>
Array of opening and closing tags for regular echos.
$customDirectives  : array<string|int, mixed>
All custom "directive" handlers.
$echoFormat  : string
The "regular" / legacy echo string format.
$escapedTags  : array<string|int, mixed>
Array of opening and closing tags for escaped echos.
$extensions  : array<string|int, mixed>
All of the registered extensions.
$files  : Filesystem
The Filesystem instance.
$firstCaseInSwitch  : bool
Identifier for the first case in switch statement.
$footer  : array<string|int, mixed>
Array of footer lines to be added to template.
$forElseCounter  : int
Counter to keep track of nested forelse statements.
$lastSection  : string
The name of the last section that was started.
$path  : string
The file currently being compiled.
$rawBlocks  : array<string|int, mixed>
Array to temporary store the raw blocks found in the template.
$rawTags  : array<string|int, mixed>
Array of opening and closing tags for raw echos.
$encodingOptions  : int
The default JSON encoding options.
__construct()  : void
Create a new compiler instance.
check()  : bool
Check the result of a condition.
compile()  : void
Compile the view at the given path.
compileEchoDefaults()  : string
Compile the default values for the echo statement.
compileString()  : string
Compile the given Blade template contents.
directive()  : void
Register a handler for custom directives.
doubleEncode()  : void
Set the echo format to double encode entities.
extend()  : void
Register a custom Blade compiler.
getCompiledPath()  : string
Get the path to the compiled version of a view.
getCustomDirectives()  : array<string|int, mixed>
Get the list of custom directives.
getExtensions()  : array<string|int, mixed>
Get the extensions used by the compiler.
getPath()  : string
Get the path currently being compiled.
if()  : void
Register an "if" statement directive.
isExpired()  : bool
Determine if the view at the given path is expired.
setEchoFormat()  : void
Set the echo format to be used by the compiler.
setPath()  : void
Set the path currently being compiled.
stripParentheses()  : string
Strip the parentheses from the given expression.
addFooters()  : string
Add the stored footers onto the given content.
callCustomDirective()  : string
Call the given directive with the given value.
compileAppend()  : string
Compile the append statements into valid PHP.
compileAuth()  : mixed
compileBreak()  : string
Compile the break statements into valid PHP.
compileCan()  : string
Compile the can statements into valid PHP.
compileCannot()  : string
Compile the cannot statements into valid PHP.
compileCase()  : string
Compile the case statements into valid PHP.
compileChoice()  : string
Compile the choice statements into valid PHP.
compileComments()  : string
Compile Blade comments into an empty string.
compileComponent()  : string
Compile the component statements into valid PHP.
compileContinue()  : string
Compile the continue statements into valid PHP.
compileDefault()  : string
Compile the default statements in switch case into valid PHP.
compileEach()  : string
Compile the each statements into valid PHP.
compileEchos()  : string
Compile Blade echos into valid PHP.
compileElse()  : string
Compile the else statements into valid PHP.
compileElsecan()  : string
Compile the else-can statements into valid PHP.
compileElsecannot()  : string
Compile the else-cannot statements into valid PHP.
compileElseif()  : string
Compile the else-if statements into valid PHP.
compileEmpty()  : string
Compile the for-else-empty and empty statements into valid PHP.
compileEndAuth()  : string
Compile the end-auth statements into valid PHP.
compileEndcan()  : string
Compile the end-can statements into valid PHP.
compileEndcannot()  : string
Compile the end-cannot statements into valid PHP.
compileEndComponent()  : string
Compile the end-component statements into valid PHP.
compileEndEmpty()  : string
Compile the end-empty statements into valid PHP.
compileEndfor()  : string
Compile the end-for statements into valid PHP.
compileEndforeach()  : string
Compile the end-for-each statements into valid PHP.
compileEndforelse()  : string
Compile the end-for-else statements into valid PHP.
compileEndGuest()  : string
Compile the end-guest statements into valid PHP.
compileEndif()  : string
Compile the end-if statements into valid PHP.
compileEndIsset()  : string
Compile the end-isset statements into valid PHP.
compileEndlang()  : string
Compile the end-lang statements into valid PHP.
compileEndprepend()  : string
Compile the end-prepend statements into valid PHP.
compileEndpush()  : string
Compile the end-push statements into valid PHP.
compileEndsection()  : string
Compile the end-section statements into valid PHP.
compileEndSlot()  : string
Compile the end-slot statements into valid PHP.
compileEndSwitch()  : string
Compile the end switch statements into valid PHP.
compileEndunless()  : string
Compile the end-unless statements into valid PHP.
compileEndwhile()  : string
Compile the end-while statements into valid PHP.
compileEscapedEchos()  : string
Compile the escaped echo statements.
compileExtends()  : string
Compile the extends statements into valid PHP.
compileExtensions()  : string
Execute the user defined extensions.
compileFor()  : string
Compile the for statements into valid PHP.
compileForeach()  : string
Compile the for-each statements into valid PHP.
compileForelse()  : string
Compile the for-else statements into valid PHP.
compileGuest()  : string
Compile the if-guest statements into valid PHP.
compileHasSection()  : string
Compile the has-section statements into valid PHP.
compileIf()  : string
Compile the if statements into valid PHP.
compileInclude()  : string
Compile the include statements into valid PHP.
compileIncludeFirst()  : string
Compile the include-first statements into valid PHP.
compileIncludeIf()  : string
Compile the include-if statements into valid PHP.
compileIncludeWhen()  : string
Compile the include-when statements into valid PHP.
compileInject()  : string
Compile the inject statements into valid PHP.
compileIsset()  : string
Compile the if-isset statements into valid PHP.
compileJson()  : string
Compile the JSON statement into valid PHP.
compileLang()  : string
Compile the lang statements into valid PHP.
compileOverwrite()  : string
Compile the overwrite statements into valid PHP.
compileParent()  : string
Replace the @parent directive to a placeholder.
compilePhp()  : string
Compile the raw PHP statements into valid PHP.
compilePrepend()  : string
Compile the prepend statements into valid PHP.
compilePush()  : string
Compile the push statements into valid PHP.
compileRawEchos()  : string
Compile the "raw" echo statements.
compileRegularEchos()  : string
Compile the "regular" echo statements.
compileSection()  : string
Compile the section statements into valid PHP.
compileShow()  : string
Compile the show statements into valid PHP.
compileSlot()  : string
Compile the slot statements into valid PHP.
compileStack()  : string
Compile the stack statements into the content.
compileStatement()  : string
Compile a single Blade @ statement.
compileStatements()  : string
Compile Blade statements that start with "@".
compileStop()  : string
Compile the stop statements into valid PHP.
compileSwitch()  : string
Compile the switch statements into valid PHP.
compileUnless()  : string
Compile the unless statements into valid PHP.
compileUnset()  : string
Compile the unset statements into valid PHP.
compileWhile()  : string
Compile the while statements into valid PHP.
compileYield()  : string
Compile the yield statements into valid PHP.
getEchoMethods()  : array<string|int, mixed>
Get the echo methods in the proper order for compilation.
getRawPlaceholder()  : string
Get a placeholder to temporary mark the position of raw blocks.
parseToken()  : string
Parse the tokens from the template.
restoreRawContent()  : string
Replace the raw placeholders with the original code stored in the raw blocks.
storePhpBlocks()  : string
Store the PHP blocks and replace them with a temporary placeholder.
storeRawBlock()  : string
Store a raw block and return a unique raw placeholder.
storeVerbatimBlocks()  : string
Store the verbatim blocks and replace them with a temporary placeholder.

Properties

$cachePath

Get the cache path for the compiled views.

protected string $cachePath

$compilers

All of the available compiler functions.

protected array<string|int, mixed> $compilers = ['Comments', 'Extensions', 'Statements', 'Echos']

$conditions

All custom "condition" handlers.

protected array<string|int, mixed> $conditions = []

$contentTags

Array of opening and closing tags for regular echos.

protected array<string|int, mixed> $contentTags = ['{{', '}}']

$customDirectives

All custom "directive" handlers.

protected array<string|int, mixed> $customDirectives = []

$echoFormat

The "regular" / legacy echo string format.

protected string $echoFormat = 'e(%s)'

$escapedTags

Array of opening and closing tags for escaped echos.

protected array<string|int, mixed> $escapedTags = ['{{{', '}}}']

$extensions

All of the registered extensions.

protected array<string|int, mixed> $extensions = []

$firstCaseInSwitch

Identifier for the first case in switch statement.

protected bool $firstCaseInSwitch = true

Array of footer lines to be added to template.

protected array<string|int, mixed> $footer = []

$forElseCounter

Counter to keep track of nested forelse statements.

protected int $forElseCounter = 0

$lastSection

The name of the last section that was started.

protected string $lastSection

$path

The file currently being compiled.

protected string $path

$rawBlocks

Array to temporary store the raw blocks found in the template.

protected array<string|int, mixed> $rawBlocks = []

$rawTags

Array of opening and closing tags for raw echos.

protected array<string|int, mixed> $rawTags = ['{!!', '!!}']

$encodingOptions

The default JSON encoding options.

private int $encodingOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT

Methods

__construct()

Create a new compiler instance.

public __construct(Filesystem $files, string $cachePath) : void
Parameters
$files : Filesystem
$cachePath : string
Tags
throws
InvalidArgumentException
Return values
void

check()

Check the result of a condition.

public check(string $name, array<string|int, mixed> ...$parameters) : bool
Parameters
$name : string
$parameters : array<string|int, mixed>
Return values
bool

compile()

Compile the view at the given path.

public compile([string $path = null ]) : void
Parameters
$path : string = null
Return values
void

compileEchoDefaults()

Compile the default values for the echo statement.

public compileEchoDefaults(string $value) : string
Parameters
$value : string
Return values
string

compileString()

Compile the given Blade template contents.

public compileString(string $value) : string
Parameters
$value : string
Return values
string

directive()

Register a handler for custom directives.

public directive(string $name, callable $handler) : void
Parameters
$name : string
$handler : callable
Return values
void

doubleEncode()

Set the echo format to double encode entities.

public doubleEncode() : void
Return values
void

extend()

Register a custom Blade compiler.

public extend(callable $compiler) : void
Parameters
$compiler : callable
Return values
void

getCompiledPath()

Get the path to the compiled version of a view.

public getCompiledPath(string $path) : string
Parameters
$path : string
Return values
string

getCustomDirectives()

Get the list of custom directives.

public getCustomDirectives() : array<string|int, mixed>
Return values
array<string|int, mixed>

getExtensions()

Get the extensions used by the compiler.

public getExtensions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPath()

Get the path currently being compiled.

public getPath() : string
Return values
string

if()

Register an "if" statement directive.

public if(string $name, callable $callback) : void
Parameters
$name : string
$callback : callable
Return values
void

isExpired()

Determine if the view at the given path is expired.

public isExpired(string $path) : bool
Parameters
$path : string
Return values
bool

setEchoFormat()

Set the echo format to be used by the compiler.

public setEchoFormat(string $format) : void
Parameters
$format : string
Return values
void

setPath()

Set the path currently being compiled.

public setPath(string $path) : void
Parameters
$path : string
Return values
void

stripParentheses()

Strip the parentheses from the given expression.

public stripParentheses(string $expression) : string
Parameters
$expression : string
Return values
string

addFooters()

Add the stored footers onto the given content.

protected addFooters(string $result) : string
Parameters
$result : string
Return values
string

callCustomDirective()

Call the given directive with the given value.

protected callCustomDirective(string $name, string|null $value) : string
Parameters
$name : string
$value : string|null
Return values
string

compileAppend()

Compile the append statements into valid PHP.

protected compileAppend() : string
Return values
string

compileAuth()

protected compileAuth([mixed $guard = null ]) : mixed
Parameters
$guard : mixed = null
Return values
mixed

compileBreak()

Compile the break statements into valid PHP.

protected compileBreak(string $expression) : string
Parameters
$expression : string
Return values
string

compileCan()

Compile the can statements into valid PHP.

protected compileCan(string $expression) : string
Parameters
$expression : string
Return values
string

compileCannot()

Compile the cannot statements into valid PHP.

protected compileCannot(string $expression) : string
Parameters
$expression : string
Return values
string

compileCase()

Compile the case statements into valid PHP.

protected compileCase(string $expression) : string
Parameters
$expression : string
Return values
string

compileChoice()

Compile the choice statements into valid PHP.

protected compileChoice(string $expression) : string
Parameters
$expression : string
Return values
string

compileComments()

Compile Blade comments into an empty string.

protected compileComments(string $value) : string
Parameters
$value : string
Return values
string

compileComponent()

Compile the component statements into valid PHP.

protected compileComponent(string $expression) : string
Parameters
$expression : string
Return values
string

compileContinue()

Compile the continue statements into valid PHP.

protected compileContinue(string $expression) : string
Parameters
$expression : string
Return values
string

compileDefault()

Compile the default statements in switch case into valid PHP.

protected compileDefault() : string
Return values
string

compileEach()

Compile the each statements into valid PHP.

protected compileEach(string $expression) : string
Parameters
$expression : string
Return values
string

compileEchos()

Compile Blade echos into valid PHP.

protected compileEchos(string $value) : string
Parameters
$value : string
Return values
string

compileElse()

Compile the else statements into valid PHP.

protected compileElse() : string
Return values
string

compileElsecan()

Compile the else-can statements into valid PHP.

protected compileElsecan(string $expression) : string
Parameters
$expression : string
Return values
string

compileElsecannot()

Compile the else-cannot statements into valid PHP.

protected compileElsecannot(string $expression) : string
Parameters
$expression : string
Return values
string

compileElseif()

Compile the else-if statements into valid PHP.

protected compileElseif(string $expression) : string
Parameters
$expression : string
Return values
string

compileEmpty()

Compile the for-else-empty and empty statements into valid PHP.

protected compileEmpty(string $expression) : string
Parameters
$expression : string
Return values
string

compileEndAuth()

Compile the end-auth statements into valid PHP.

protected compileEndAuth() : string
Return values
string

compileEndcan()

Compile the end-can statements into valid PHP.

protected compileEndcan() : string
Return values
string

compileEndcannot()

Compile the end-cannot statements into valid PHP.

protected compileEndcannot() : string
Return values
string

compileEndComponent()

Compile the end-component statements into valid PHP.

protected compileEndComponent() : string
Return values
string

compileEndEmpty()

Compile the end-empty statements into valid PHP.

protected compileEndEmpty() : string
Return values
string

compileEndfor()

Compile the end-for statements into valid PHP.

protected compileEndfor() : string
Return values
string

compileEndforeach()

Compile the end-for-each statements into valid PHP.

protected compileEndforeach() : string
Return values
string

compileEndforelse()

Compile the end-for-else statements into valid PHP.

protected compileEndforelse() : string
Return values
string

compileEndGuest()

Compile the end-guest statements into valid PHP.

protected compileEndGuest() : string
Return values
string

compileEndif()

Compile the end-if statements into valid PHP.

protected compileEndif() : string
Return values
string

compileEndIsset()

Compile the end-isset statements into valid PHP.

protected compileEndIsset() : string
Return values
string

compileEndlang()

Compile the end-lang statements into valid PHP.

protected compileEndlang() : string
Return values
string

compileEndprepend()

Compile the end-prepend statements into valid PHP.

protected compileEndprepend() : string
Return values
string

compileEndpush()

Compile the end-push statements into valid PHP.

protected compileEndpush() : string
Return values
string

compileEndsection()

Compile the end-section statements into valid PHP.

protected compileEndsection() : string
Return values
string

compileEndSlot()

Compile the end-slot statements into valid PHP.

protected compileEndSlot() : string
Return values
string

compileEndSwitch()

Compile the end switch statements into valid PHP.

protected compileEndSwitch() : string
Return values
string

compileEndunless()

Compile the end-unless statements into valid PHP.

protected compileEndunless() : string
Return values
string

compileEndwhile()

Compile the end-while statements into valid PHP.

protected compileEndwhile() : string
Return values
string

compileEscapedEchos()

Compile the escaped echo statements.

protected compileEscapedEchos(string $value) : string
Parameters
$value : string
Return values
string

compileExtends()

Compile the extends statements into valid PHP.

protected compileExtends(string $expression) : string
Parameters
$expression : string
Return values
string

compileExtensions()

Execute the user defined extensions.

protected compileExtensions(string $value) : string
Parameters
$value : string
Return values
string

compileFor()

Compile the for statements into valid PHP.

protected compileFor(string $expression) : string
Parameters
$expression : string
Return values
string

compileForeach()

Compile the for-each statements into valid PHP.

protected compileForeach(string $expression) : string
Parameters
$expression : string
Return values
string

compileForelse()

Compile the for-else statements into valid PHP.

protected compileForelse(string $expression) : string
Parameters
$expression : string
Return values
string

compileGuest()

Compile the if-guest statements into valid PHP.

protected compileGuest([string|null $guard = null ]) : string
Parameters
$guard : string|null = null
Return values
string

compileHasSection()

Compile the has-section statements into valid PHP.

protected compileHasSection(string $expression) : string
Parameters
$expression : string
Return values
string

compileIf()

Compile the if statements into valid PHP.

protected compileIf(string $expression) : string
Parameters
$expression : string
Return values
string

compileInclude()

Compile the include statements into valid PHP.

protected compileInclude(string $expression) : string
Parameters
$expression : string
Return values
string

compileIncludeFirst()

Compile the include-first statements into valid PHP.

protected compileIncludeFirst(string $expression) : string
Parameters
$expression : string
Return values
string

compileIncludeIf()

Compile the include-if statements into valid PHP.

protected compileIncludeIf(string $expression) : string
Parameters
$expression : string
Return values
string

compileIncludeWhen()

Compile the include-when statements into valid PHP.

protected compileIncludeWhen(string $expression) : string
Parameters
$expression : string
Return values
string

compileInject()

Compile the inject statements into valid PHP.

protected compileInject(string $expression) : string
Parameters
$expression : string
Return values
string

compileIsset()

Compile the if-isset statements into valid PHP.

protected compileIsset(string $expression) : string
Parameters
$expression : string
Return values
string

compileJson()

Compile the JSON statement into valid PHP.

protected compileJson(string $expression) : string
Parameters
$expression : string
Return values
string

compileLang()

Compile the lang statements into valid PHP.

protected compileLang(string $expression) : string
Parameters
$expression : string
Return values
string

compileOverwrite()

Compile the overwrite statements into valid PHP.

protected compileOverwrite() : string
Return values
string

compileParent()

Replace the @parent directive to a placeholder.

protected compileParent() : string
Return values
string

compilePhp()

Compile the raw PHP statements into valid PHP.

protected compilePhp(string $expression) : string
Parameters
$expression : string
Return values
string

compilePrepend()

Compile the prepend statements into valid PHP.

protected compilePrepend(string $expression) : string
Parameters
$expression : string
Return values
string

compilePush()

Compile the push statements into valid PHP.

protected compilePush(string $expression) : string
Parameters
$expression : string
Return values
string

compileRawEchos()

Compile the "raw" echo statements.

protected compileRawEchos(string $value) : string
Parameters
$value : string
Return values
string

compileRegularEchos()

Compile the "regular" echo statements.

protected compileRegularEchos(string $value) : string
Parameters
$value : string
Return values
string

compileSection()

Compile the section statements into valid PHP.

protected compileSection(string $expression) : string
Parameters
$expression : string
Return values
string

compileShow()

Compile the show statements into valid PHP.

protected compileShow() : string
Return values
string

compileSlot()

Compile the slot statements into valid PHP.

protected compileSlot(string $expression) : string
Parameters
$expression : string
Return values
string

compileStack()

Compile the stack statements into the content.

protected compileStack(string $expression) : string
Parameters
$expression : string
Return values
string

compileStatement()

Compile a single Blade @ statement.

protected compileStatement(array<string|int, mixed> $match) : string
Parameters
$match : array<string|int, mixed>
Return values
string

compileStatements()

Compile Blade statements that start with "@".

protected compileStatements(string $value) : string
Parameters
$value : string
Return values
string

compileStop()

Compile the stop statements into valid PHP.

protected compileStop() : string
Return values
string

compileSwitch()

Compile the switch statements into valid PHP.

protected compileSwitch(string $expression) : string
Parameters
$expression : string
Return values
string

compileUnless()

Compile the unless statements into valid PHP.

protected compileUnless(string $expression) : string
Parameters
$expression : string
Return values
string

compileUnset()

Compile the unset statements into valid PHP.

protected compileUnset(string $expression) : string
Parameters
$expression : string
Return values
string

compileWhile()

Compile the while statements into valid PHP.

protected compileWhile(string $expression) : string
Parameters
$expression : string
Return values
string

compileYield()

Compile the yield statements into valid PHP.

protected compileYield(string $expression) : string
Parameters
$expression : string
Return values
string

getEchoMethods()

Get the echo methods in the proper order for compilation.

protected getEchoMethods() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRawPlaceholder()

Get a placeholder to temporary mark the position of raw blocks.

protected getRawPlaceholder(int|string $replace) : string
Parameters
$replace : int|string
Return values
string

parseToken()

Parse the tokens from the template.

protected parseToken(array<string|int, mixed> $token) : string
Parameters
$token : array<string|int, mixed>
Return values
string

restoreRawContent()

Replace the raw placeholders with the original code stored in the raw blocks.

protected restoreRawContent(string $result) : string
Parameters
$result : string
Return values
string

storePhpBlocks()

Store the PHP blocks and replace them with a temporary placeholder.

protected storePhpBlocks(string $value) : string
Parameters
$value : string
Return values
string

storeRawBlock()

Store a raw block and return a unique raw placeholder.

protected storeRawBlock(string $value) : string
Parameters
$value : string
Return values
string

storeVerbatimBlocks()

Store the verbatim blocks and replace them with a temporary placeholder.

protected storeVerbatimBlocks(string $value) : string
Parameters
$value : string
Return values
string

Search results