Download the PHP package averay/tokenised-strings without Composer

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

Tokenised Strings

A lightweight system for rendering tokens in templated strings using a familiar syntax inspired by Jinja or Twig.

Motivation

The library aims to provide a more flexible substitute for PHP’s str_replace function.

Manual string concatenation does not allow templating, and simple str_replace substitutions offer limited functionality and require repetition. Meanwhile, a full templating engine such as Twig provides a lot of power at the cost of significantly increased complexity.

This library aims to fill a middle ground between the two options, allowing templates to be defined with a standard syntax and rendered throughout a system without needing to manage a full templating engine. The library is intended for rendering short tokens defined separately from where they are rendered, such as strings stored in configuration files or a database.

Syntax

The default configuration delimits tokens using double curly braces (e.g. {{ token_name }}). Nested values can be accessed using periods (e.g. {{ parent.child }}. Modifiers a.k.a. filters can be applied using pipes (e.g. {{ value | modifier }}) and multiple can be applied. All whitespace between components is optional. The syntax is completely customisable (see below).

No in-template logic such as assignments, conditions, or loops are supported (i.e. any functionality Twig’s {% ... %} tags provide), nor are comments.

Usage

The primary class provides a method for rendering templated strings, and two additional helper methods for rendering URLs and HTML:

A custom value formatter can be provided, which will be applied to each value when rendered in the template:

Global parameters can be defined, which will be available in all templates:

Global modifiers can also be defined, which will be available in all templates:

To define a custom syntax, the underlying Parser and Renderer classes can be used directly. In the following example, the custom syntax [% value->property >> modifier %] is used:

A system may wish to move the configuration out to a global utility function, to allow rendering templates from anywhere in the same way str_replace would be used:


All versions of tokenised-strings with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
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 averay/tokenised-strings contains the following files

Loading the files please wait ....