Download the PHP package jascha030/twig-service without Composer

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

Twig Service

Simple set of two interfaces and one basic implementation of a service class for usage with Twig.

Getting Started

Requirements

Installation

Usage

The package contents consist of one simple service class implementing, an interface, which extends one extra interface that implements the features that are independent from twig/twig.

TwigServiceInterface

The main interface is the Jascha030\Twig\TwigServiceInterface, which requires a class to implement three methods.

Methods

getEnvironment

Get the TwigEnvironment.

TwigServiceInterface::getEnvironment(): \Twig\Environment

Inherited methods

The methods below are inherited from Jascha030\Twig\Templater\TemplaterInterface.

This is done to open future possibility to replace your Twig-specific implementation with another templating method, without having to refactor your codebase, for example, by using a DIC.

For this reason, using container bindings bound to the TemplaterInterface instead of the TwigServiceInterface. For the same reason it is recommended to let other classes depend on the TemplaterInterface. For dependent classes, the fact that the service uses a Twig\Environment instance to render the output, should not be relevant.

renderString

Render a template and return output as string.

TemplaterInterface::renderString(string $template, array $context = []): string

render

Render and output a template.

TemplaterInterface::render(string $template, array $context = []): void

Default Implementation

This package also provides class as most-basic implementation of the TwigServiceInterface , Jascha030\Twig\TwigService.php. This class implements all three methods with the addition of a constructor requiring the Twig\Environment.

Below is a simple example of constructing the service with an Environment using the FilesystemLoader:

Development

Clone this repo, and run composer install inside the repo.

Code-style

A code-style is provided in the form of a php-cs-fixer configuration in .php-cs-fixer.dist.php. For easy execution, use the provided Composer script command.

If you have php-cs-fixer installed globally, pass it to the --config argument of the fix command.

Unit-testing

A configuration for phpunit is provided in phpunit.xml.

For easy execution, use the provided Composer script command.

If you have phpunit installed globally, and want to use that, pass the config in the --config argument.

Motivation

My personal preference is to wrap the \Twig\Environment class in a service class, which I was repeatedly writing again, while it's a very simple class.

So (finally) I added them to a simple package, complete with unit-tests.

License

This composer package is an open-sourced software licensed under the MIT License

Note: to find the right license for your project use GitHub's https://choosealicense.com/, or read up on any other information, regarding Licensing your project in their docs' page on licensing.


All versions of twig-service with dependencies

PHP Build Version
Package Version
Requires php Version ^8
container-interop/service-provider Version ^0.4.0
twig/twig Version ^3.3
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 jascha030/twig-service contains the following files

Loading the files please wait ....