php-cooper-laravel

Tags
in package

FinalYes

The tags every load of the application's configuration has, each named exactly as the PHP it stands for, so a `config/*.php` value reads the same in CASC:

Tag Gives
!base_path("x"), !app_path, !config_path, !database_path, !lang_path, !public_path, !resource_path, !storage_path the helper's path, on the machine loading the document; "" for the directory itself
!php_const("PDO::MYSQL_ATTR_SSL_CA") a class constant's, an enum case's or a global constant's value
!php("""...""") the value of the PHP expression, evaluated at load with $app in scope

!php is a LiteralTag: its argument must be a string literal written in the document -- "...", '...' or """...""" with nothing interpolated -- or the load is refused, naming the key and the file. No value from the environment, a resolver, a variable or another tag can ever become code. Its code is one expression (return is implied); more than one statement needs an immediately invoked closure, (function () { ...; return $x; })(). An exception it throws, a parse error included, fails the load naming the key and the file.

The path helpers and !php_const take any string, from anywhere: a path or a constant's name is data, not code.

Table of Contents

Constants

PATH_HELPERS  : mixed = ['base_path', 'app_path', 'config_path', 'datab...
The path helpers, each a tag of the same name.

Methods

for()  : array<string, callable(mixed): mixed>
The tags, for `$app`.
pathHelpers()  : array<int, string>
The path helpers' names, each a tag's.
__construct()  : mixed
constant()  : mixed
path()  : string
The path helper `$name`'s path for `$path`, as the global helper gives it (`storage_path()` is `app()->storagePath()`).
run()  : mixed
Evaluates `$code`, one PHP expression, with `$app` in scope.

Constants

PATH_HELPERS

The path helpers, each a tag of the same name.

private mixed PATH_HELPERS = ['base_path', 'app_path', 'config_path', 'database_path', 'lang_path', 'public_path', 'resource_path', 'storage_path']

Methods

for()

The tags, for `$app`.

public static for(Application $app) : array<string, callable(mixed): mixed>
Parameters
$app : Application

the application whose paths the helpers give, and which !php code sees as $app

Return values
array<string, callable(mixed): mixed> —

tag name => tag, as Cooper's tags option takes them

pathHelpers()

The path helpers' names, each a tag's.

public static pathHelpers() : array<int, string>
Return values
array<int, string>

__construct()

private __construct() : mixed

constant()

private static constant(mixed $name) : mixed
Parameters
$name : mixed
Tags
throws
InvalidArgumentException

when $name is not a string naming a defined constant

path()

The path helper `$name`'s path for `$path`, as the global helper gives it (`storage_path()` is `app()->storagePath()`).

private static path(Application $app, string $name, mixed $path) : string
Parameters
$app : Application
$name : string
$path : mixed
Tags
throws
InvalidArgumentException

when $path is not a string

Return values
string

run()

Evaluates `$code`, one PHP expression, with `$app` in scope.

private static run(string $code, Application $app) : mixed

It runs in a static closure of its own, so the only variable it sees is $app -- not this class's, and not the loader's.

Parameters
$code : string
$app : Application
On this page

Search results