Download the PHP package gajus/brick without Composer
On this page you can find all versions of the php package gajus/brick. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package brick
Short Description PHP template system that's fast, easy to use and easy to extend.
License BSD-3-Clause
Homepage https://github.com/gajus/brick
Informations about the package brick
Brick
PHP template system that's fast, easy to use and easy to extend.
- Plain PHP, no new syntax to learn.
- Framework-agnostic, will work with any project.
About Brick
Brick is not a template engine that would lex/parse template as a string (think Twig).
Some of you might remember Chad Minick's article "Simple PHP Template Engine" (2009; Has it been that long?). I have been using a variation of an abstraction following the principles outlined in Chad's article for a long time. Brick is the final of the gang. I am happy with the API, I am happy with the inheritance rules, scope definition; it is perfect!
I am using Brick in several freelance projects and I am making it open to others. I am looking for people who share the same mindset about what template processing in PHP should be. Contributors and critique is welcome.
– http://www.reddit.com/r/PHP/comments/2nduuc/brick/
Features
- Handles not found template files
- Protects from directory traversal attacks (at the template inclusion level)
- Isolates template execution scope
The following examples together with the included unit tests will set you going. Please raise an issue if you feel that there are bits that need to be clarified.
Overview
System
System
class is responsible for template resolution and scope management.
Public methods:
- setDirectory
- getDirectory
- setGlobals
- getGlobals
- setTemplateExtension
- getTemplateExtension
- view
- template
Subsystem
Subsystem
class is responsible for template resolution and scope management.
Views that are built using an instance of System
will be using Subsystem
to produce inner views. This restricts a template access to controlling the globals and other sensitive variables.
Public methods:
Template
Template
class is responsible for isolating template execution scope, extracting scope variables and capturing the output buffer.
Public methods:
Getting Started
Producing a View
Template file must have a ".php" extension. When referring to templates, do not include the file extension. You can change the name of the extension:
View Scope
$system
an instance ofSubsystem
.$globals
variables shared across all views produced by the same instance ofSystem
.- Variables assigned to the view at the time of producing the view.
Assigning Variables
Scope variables are extracted to the execution context of the template, i.e. template can access them as regular variables.
Scope variables are assigned at the time of producing a view.
Globals
Views produced using the same instance of the System
have access to a $globals
variables.