Download the PHP package esi/simple_tpl without Composer

On this page you can find all versions of the php package esi/simple_tpl. 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 simple_tpl

Simple Template Engine - Text based template parser.

Build Status Code Coverage Scrutinizer Code Quality Continuous Integration Type Coverage Psalm Level Latest Stable Version Development Version Downloads per Month

Simple Template Engine is a small, simple text-based template parsing engine that works on text replacement.

[!IMPORTANT] The master branch currently holds the work-in-progress version 3.x, which is a break from the backward compatibility promise. This will be resolved once 3.0.0 is released. Since 3.x is under development, it is not recommended to use in a production environment. The public API, implementations, etc., can (and will likely) change.


Installation

Compatible with PHP >= 8.2 and can be installed with Composer.

Usage

Storage

There are two storage implementations available: Storage\FilesystemStorage and Storage\DatabaseStorage. Both storage implementations implement the Storage\StorageInterface interface, with only one defined method: loadTemplate().

NOTE: If you wish to have a system for editing/saving, deleting or updating the templates themselves, you would need to implement this on your own. This library only searches for templates that have already been created, by name, then parses them with a key => value associative array of variables.

Filesystem Storage

The FilesystemStorage implementation allows you to use regular files for your templates. Your template files are expected to end with the .tpl extension. I plan to allow the ability to use different extensions later.

  1. Create a FilesystemStorage instance with the path/directory to where your templates are located.
  2. Pass this instance to the Template class when creating it.

Let's say you had a template called example_template.tpl within the ./templates/ directory.

Template file:

PHP to parse the template:

When calling display() or parse(), you only need to provide the file name without extension. For example, if your template file is mytemplate.tpl, you would call either of these methods with mytemplate.

Database Storage

The DatabaseStorage implementation allows you to use a database for your templates.

  1. Create a PDO instance with your database details to create a connection.
  2. Create a DatabaseStorageConfig with your template tables tableName, nameField, and contentField.
  3. Create a DatabaseStorage instance and pass the PDO and DatabaseStorageConfig instances to it.
  4. Pass the DatabaseStorage instance to the Template class when creating it.

Let's say the content of the example_template is the same as in the filesystem example, and your database table structure is:

Then your code would look something like:

Caching

If you would like to utilize caching for templates, you will need to provide the library a PSR-6 cache implementation. You can view a list of packages that provide this implementation on Packagist.

Whether you use FilesystemStorage or DatabaseStorage, you can use caching for either by passing an object that implements \Psr\Cache\CacheItemPoolInterface.

For example:

About

Requirements

Credits

Contributing

See CONTRIBUTING for more information.

Bugs and feature requests are tracked on GitHub.

Contributor Covenant Code of Conduct

See CODE_OF_CONDUCT.md

Backward Compatibility Promise

See backward-compatibility.md for more information on Backwards Compatibility.

Changelog

See the CHANGELOG for more information on what has changed recently.

License

Simple Template Engine's license depends on the version you are using:

See the LICENSE for more information on the license that applies to this project.

Security

See SECURITY for more information on the security disclosure process.


All versions of simple_tpl with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1 <8.5
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 esi/simple_tpl contains the following files

Loading the files please wait ....