Download the PHP package camspiers/silverstripe-twig without Composer

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

Twig templates for SilverStripe 3.1

Overview

SilverStripe Twig enables the use of the Twig templating engine in SilverStripe 3.1.

If you are not familiar with Twig, check out the docs.

Installation

Composer

Create or edit a composer.json file in the root of your SilverStripe project, and make sure the following is present.

After completing this step, navigate in Terminal or similar to the SilverStripe root directory and run composer install or composer update depending on whether or not you have composer already in use.

Getting started

What to name and where to put your templates

Create a folder called twig in your current theme. This is where twig will look for your templates. By default Twig expects your templates to be named with the .twig extension, but can be easily configured to look for others (see twig.extensions).

The way SilverStripe twig decides which template to use is the same way SilverStripe selects .ss templates.

It builds a ranked list of candidate templates based on the class name of the current controller or dataRecord and the action being called. Using the template list it selects the first template that it finds.

For example, for page of PageType Page. If there is a Page.twig template in the twig folder it will use that.

How to enable twig

Twig rendering is enabled by extending the functionality of your SilverStripe controller. This can be done in two ways depending on what version of PHP you have.

PHP 5.3

If you want to use twig for all controllers that extend Page_Controller, set up is as follows:

Page.php

If you want to use twig in a Controller, set up is as follows:

MyController.php

PHP 5.4

The PHP 5.3 classes above are actually auto-generated from a trait. To use the trait add a use statement in your controller as follows:

or:

Accessing your Controller in twig

By default twig makes your controller (and therefore your dataRecord) available in your template by the variable c.

Practical usage example

Achieving similar functionality to SilverStripe's $Layout variable is easy with twig.

Twig has the concepts of extends and blocks which enable flexible template reuse.

Page.twig

layouts/layout.twig

Configuration

SilverStripe Twig uses a dependency injection container (an extension of Pimple) to allow configuration and DI for all objects used.

Options

An example:

mysite/_config.php

Any service provided by SilverStripe Twig can be accessed by instantiating the Container.

See Pimple for more information.

Using Twig and Haml together

SilverStripe twig supports the use of haml through the SilverStripe haml module.

Install the SilverStripe haml module and you are ready to go.

You can now name your files .haml (though you don't have to).

Usage

To get Twig to process your file as Haml add:

To the top of any template you want to be processed as haml.

Example:

Contributing

Code guidelines

This project follows the standards defined in:


License

SilverStripe Twig is released under the MIT license


All versions of silverstripe-twig with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
composer/installers Version ~1.0
twig/twig Version ~1.12
pimple/pimple 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 camspiers/silverstripe-twig contains the following files

Loading the files please wait ....