Download the PHP package buzzingpixel/php-template-engine without Composer

On this page you can find all versions of the php package buzzingpixel/php-template-engine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-template-engine

Just simple, basic, PHP templating.

Usage

Installation

Render a template

Get an instance of the TemplateEngine from the TemplateEngineFactory.

The only required item to set is the template path.

(note that pthml is just a convention. The TemplateEngine doesn't care what the extension is)

Variables are optional. If you have any to set, you can add them in one go:

…or you can add them one at a time:

And when you're ready, call render() on the TemplateEngine instance, and your template will be rendered and the content returned as a string. Here's a full example.

Templating

To get auto-completing in your IDE for your PHP templates, you can assert that $this is an instance of \BuzzingPixel\Templating\TemplateEngine. You can also assert any variables you're expecting in your template:

Template Inheritance, Extending, and Sections

Extending another template is fairly simple. Just run $this->extends('/path/to/some/template.phtml') somewhere in your template (I like to do it at the top). All rendered content in the template is assigned to a section named layoutContent.

As noted, by default, when extending, all content not placed in a section gets assigned to the layoutContent section. This is nice in that you don't have to do a lot of work if you just have one thing you're rendering and pushing up the stack. So a simple extension might look something like this:

/my-template.phtml:

/layout.phtml:

There is no limit on how deep you can go on extending. An extended template can, in turn, extend another template.

But you may also want to set other sections, say, a sidebar, for your extended template. That might look something like this:

/my-template.phtml:

/layout.phtml:

Partials

Reusability of code is a big concern, which is why partials are of interest. Partials work a little something like this:

/my-partial.phtml

/my-template.phtml:

Partials are a full instance of the TemplateEngine so they have every feature any other template does. They do NOT inherit the variable context of the calling template.

Escaping

The TemplateEngine has escaping helper methods which you should use whenever you have output from untrusted sources.


All versions of php-template-engine with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
laminas/laminas-escaper Version ^2.12
spatie/php-cloneable Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package buzzingpixel/php-template-engine contains the following files

Loading the files please wait ....