Download the PHP package susina/twig-extensions without Composer

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

Susina Twig Extensions

License Maintainability Test Coverage

Susina Twig Extensions is a set of extensions for Twig template engine. It contains some useful functions, tests and filters missing in the original library.

Installation

Firstly, install the package via Composer:

Then add the extension you want to Twig Engine. Suppose you want to load VariablesExtension:

Symfony Framework

If you are working with Symfony, after installing the library with composer, register the extensions you want as services and tag them as twig.extension:

VariablesExtension

VariablesExtension contains some tests and functions useful for manipulating variables.

Tests

When you register this extension you can use the following type tests:

and you can use them in your templates:

Functions

get_type

get_type function returns the variable type:

var_export

var_export function is a wrapper for PHP var_export and it behaves in the same way. It can be useful if you want to generate some valid php code from a variable.

Filters

bool_to_string

bool_to_string filter returns the string 'true' if the variable filtered can be evaluated as true, otherwise it returns the string false:

it returns The "boolVariable" is true.

You can customize the true/false strings by passing two variables to the filter: the first one represents the true value, the second one the false value, i.e.:

it returns The "boolVariable" is yes.

StringExtension

Filters

quote

You can apply quote filter to a string, if you want to surround it with quotes:

it returns the quoted string 'Donald Duck'.

By default, the filter applies single quotes ' but you can pass any character you want, as the argument of the filter:

then it returns "Donald Duck".

to_kb

to_kb filter transform a number from bytes to kilobytes:

it returns: The file size is 2 Kb.

By default, this filter uses the English decimal and thousands separator: . for decimal and , form thousands. You can change this behavior by passing different separators:

it returns:

to_mb

to_mb filter transform a number from bytes to megabytes. The behavior is the same as to_kb.

Gravatar Extension

Gravatar extension contain a filter to retrieve the Gravatar image from a given email. gravatar filter returns the uri for the avatar so that you can easily use it in your html:

You can also pass some options to the filter, i.e.:

For a full options description, please see https://en.gravatar.com/site/implement/images/.

Issues

We manage issues and feature requests via Github repository issues.

Contributing

Feel free to fork and submit pull requests: all contributions are welcome!

This library includes some useful composer scripts for developers:

Before submitting a pull request, please run composer check and fix all errors.

License

This library is released under Apache 2.0 license.


All versions of twig-extensions with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
twig/twig Version ^3.0
symfony/options-resolver Version >=5.4
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 susina/twig-extensions contains the following files

Loading the files please wait ....