Download the PHP package fyre/view without Composer
On this page you can find all versions of the php package fyre/view. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package view
FyreView
FyreView is a free, open-source template rendering library for PHP.
Table Of Contents
- Installation
- Views
- Layouts
- Cells
- Elements
- Blocks
- Templates
- Cell Registry
- Helper Registry
- Helpers
- CSP
- Form
- Format
- Url
Installation
Using Composer
In PHP:
Views
$request
is a ServerRequest.
Get Data
Get the view data.
Get Layout
Get the layout.
Get Request
Get the ServerRequest.
Load Helper
Load a Helper.
$name
is a string representing the helper name.$options
is an array containing helper options.
Render
Render a template.
$file
is a string representing the template file.
Templates files must end in the extension .php
, and must exist in one of the defined paths.
Set Data
Set view data.
$data
is an array containing data to pass to the template.
Set Layout
Set the layout.
$layout
is a string representing the layout file.
Layout files must end in the extension .php
, and must exist in a "layouts" folder in one of the defined paths.
Layouts
You can use layouts when rendering views by placing a default.php
file in a layouts folder of one of the defined paths. You can create multiple layouts, and specify the layout to use with the setLayout
method above.
The rendered content is passed to the layout file via the content
method of $this
. Any other defined data is also passed to the layout.
Cells
Custom cells can be created by extending \Fyre\View\Cell
, and suffixing the class name with "Cell".
Cell
Render a Cell.
$cell
is a string, and can either represent the cell name (implementing adisplay
method) or in the format of "Cell::method".$args
is an array of arguments that will be passed to the cell method, and will default to [].
Elements
Element
Render an element.
$file
is a string representing the element file.$data
is an array containing data to pass to the element, and will default to [].
Element files must end in the extension .php
, and must exist in an "elements" folder in one of the defined paths.
Blocks
Append
Append content to a block.
$name
is a string representing the block name.
Any output until the block is ended will be appended to the block.
Assign
Assign content to a block.
$name
is a string representing the block name.$content
is a string representing the content.
End
End a block.
Fetch
Fetch a block.
$name
is a string representing the block name.$default
is a string representing the default value, and will default to "".
Prepend
Prepend content to a block.
$name
is a string representing the block name.
Any output until the block is ended will be prepended to the block.
Reset
Reset content of a block.
$name
is a string representing the block name.
Start
$name
is a string representing the block name.
Start content for a block.
Templates
Layouts, templates and elements are loaded by searching available paths.
Add Path
Add a path for loading templates.
$path
is a string representing the path.
Get Paths
Get the paths.
Locate
Find a file in paths.
$file
is a string representing the file name.$folder
is a string representing the folder name, and will default to "".
Normalize
Normalize a template file name.
$string
is a string representing the file name.
Remove Path
$path
is a string representing the path.
Cell Registry
Add Namespace
Add a namespace for automatically loading cells.
$namespace
is a string representing the namespace.
Clear
Clear all namespaces and cells.
Find
Find a cell class.
$name
is a string representing the cell name.
Get Namespaces
Get the namespaces.
Has Namespace
Check if a namespace exists.
$namespace
is a string representing the namespace.
Load
Load a cell.
$name
is a string representing the cell name.$view
is a View.$options
is an array containing cell options.
Remove Namespace
Remove a namespace.
$namespace
is a string representing the namespace.
Helper Registry
Add Namespace
Add a namespace for automatically loading helpers.
$namespace
is a string representing the namespace.
Clear
Clear all namespaces and helpers.
Find
Find a helper class.
$name
is a string representing the helper name.
Get Namespaces
Get the namespaces.
Has Namespace
Check if a namespace exists.
$namespace
is a string representing the namespace.
Load
Load a helper.
$name
is a string representing the helper name.$view
is a View.$options
is an array containing helper options.
Remove Namespace
Remove a namespace.
$namespace
is a string representing the namespace.
Helpers
Helpers can be used inside of templates or elements using the class name as a property of $this
.
Alternatively, you can load a helper with configuration options using the loadHelper
method of the View.
Custom helpers can be created by extending \Fyre\View\Helper
, suffixing the class name with "Helper", and ensuring the __construct
method accepts View as the argument.
Get Config
Get the configuration options.
Get View
Get the View.
CSP
The CSP helper allows an easy way to generate nonces, and automatically add them to your CSP policies.
Script Nonce
Generate a script nonce.
Style Nonce
Generate a style nonce.
Form
Button
Render a button element.
$content
is a string representing the button content.$options
is an array of options for rendering the button.
By default, the button content will be HTML escaped. To disable this, set the escape
value to false in the options
array.
All other options
will be created as attributes on the button element.
Close
Render a form close tag.
Fieldset Close
Render a fieldset close tag.
Fieldset Open
Render a fieldset open tag.
$options
is an array of options for rendering the fieldset.
All options
will be created as attributes on the fieldset element.
Input
Render an input element.
$key
is a string representing the field key, using dot notation.$options
is an array of options for rendering the label.
All options
will be created as attributes on the input element.
- The default
id
andname
attributes will be converted from the field key. - The input
type
and other default attributes will be determined from the TableSchema and Model Validation. - The default value will be retrieved from the ServerRequest
$_POST
data or form context.- If the form was opened in an Entity context, the Entity and the TableSchema will also be used.
- Select options can be specified using the
options
key. - Checkboxes and radio inputs can be marked as checked by setting the
checked
option to true. - Multiple select menus will (by default) render a hidden field with an empty value. This can be disabled by setting the
hiddenField
option to false. - Checkboxes will (by default) render a hidden field with the value "0". This can be disabled by setting the
hiddenField
option to false.
You can also use the following helper methods to generate specific input type fields.
Label
Render a label element.
$key
is a string representing the field key.$options
is an array of options for rendering the label.
The label text will be retrieved from the Lang using the Field.{field_name}
key or converted from the field name. You can also set custom label text by setting the text
option.
By default, the label content will be HTML escaped. To disable this, set the escape
value to false in the options
array.
All other options
will be created as attributes on the label element. The default for
attribute will be converted from the field key.
Legend
Render a legend element.
$content
is a string representing the legend content.$options
is an array of options for rendering the legend.
By default, the legend content will be HTML escaped. To disable this, set the escape
value to false in the options
array.
All other options
will be created as attributes on the legend element.
Open
Render a form open tag.
$item
is an Entity or other (supported) object representing the form context, and will default to null$options
is an array of options for rendering the form.
All options
will be created as attributes on the form element.
Open Multipart
Render a multipart form open tag.
$item
is an array or object representing the form context, and will default to null$options
is an array of options for rendering the form.
All options
will be created as attributes on the form element.
Format
The format helper provides a convenient wrapper for Formatter methods.
Url
The URL helper provides methods for generating Router links.
Link
Generate an anchor link for a destination.
$content
is a string representing the link content.$options
is an array containing options.escape
is a boolean indicating whether to escape the link content, and will default to true.fullBase
is a boolean indicating whether to use the full base URI, and will default to false.
Path
Generate a url for a relative path.
$path
is a string representing the file path.$options
is an array containing options.fullBase
is a boolean indicating whether to use the full base URI, and will default to false.
To
Generate a url for a named route.
$name
is a string representing the route alias.$arguments
is an array containing the route arguments.?
is an array containing route query parameters.#
is a string representing the fragment component of the URI.
$options
is an array containing options.fullBase
is a boolean indicating whether to use the full base URI, and will default to false.
All versions of view with dependencies
fyre/csrf Version ^3.0
fyre/formatter Version ^3.0
fyre/formbuilder Version ^2.0
fyre/htmlhelper Version ^2.0
fyre/lang Version ^3.0
fyre/orm Version ^8.0
fyre/path Version ^2.0
fyre/router Version ^6.0