Download the PHP package tourze/twig without Composer

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

TWIG组件

关于Twig,如果读者还不太熟悉,可以参考下面链接

  1. Twig的在线文档(英文)
  2. Twig的PDF文档(英文)
  3. Twig的简明教程(中文)

如果你有发现更好的其他关于Twig的入门教程,欢迎你帮忙补充上去~

关于Twig的基础语法,这里就不赘述了。

安装

首先需要下载和安装composer,具体请查看官网的Download页面

在你的composer.json中增加:

"require": {
    "tourze/twig": "^1.0"
},

或直接执行

composer require tourze/twig:"^1.0"

新特性

途者框架的Twig组件,在Twig原生语法的基础上,增加一些扩展语法。下面详细说下这些新特性。

缓存

感谢asm89/twig-cache-extension,为我们提供了Twig的缓存解决方案。

一般情况下,如果要对Twig进行缓存处理,我们需要在Twig外部来进行处理,如:

if ( ! $result = getCache($fileName))
{
    $result = twigRender($fileName);
    setCache($fileName, $result);
}
return $result;

但对于Twig模板的设计者来说,有时候需要自己决定缓存一部分解析结果。 asm89/twig-cache-extension为我们的这种需求提供了解决办法:

{% cache 'v1/summary' 900 %}
    {# 这里存放一些耗时的、需要缓存的代码,输出或者读取其他文件也可以 #}
{% endcache %}

其中v1/summary是这段缓存的标志,900是缓存时间(单位:秒)。

你也可以嵌套使用:

{% cache 'v1' 900 %}
    {% for item in items %}
        {% cache 'v1' item %}
            {# ... #}
        {% endcache %}
    {% endfor %}
{% endcache %}

缓存标志那里还可以用表达式,用于设置特定的标志:

{% set version = 42 %}
{% cache 'hello_v' ~ version 900 %}
    Hello {{ name }}!
{% endcache %}

Markdown支持

我个人是个Markdown的重度用户,平时写笔记都不由自觉地使用了Markdown。

个人觉得,掌握Markdown这种标签语言(或其他类似的标签语言),可以有效提高IT从业者的文字书写效率。 Markdown让人能更专注于内容和排版,而暂时忽略样式,从而提高书写效率。

关于Markdown,更多说明可以参考:

  1. 献给写作者的 Markdown 新手指南
  2. Markdown 语法说明 (简体中文版)

得益于aptoma/twig-markdown,我们很方便就在组件中集成了Markdown语法。

在本组件中使用Markdown很简单,有两种方式可以选择:

  1. 使用过滤器

使用方法如:

{{ "# Heading Level 1"|markdown }}

假如你的Markdown文本存放在动态变量中,那么使用这种方法可以很方便。

  1. 使用标签

使用方法如:

{% markdown %}# Heading Level 1{% endmarkdown %}

具体使用哪种方法,应视具体情况

HTML助手方法

本组件封装了Nicholas Humfrey提供的njh/twig-html-helpers,为使用者提供了以下函数,用于方便地生成HTML标签:


All versions of twig with dependencies

PHP Build Version
Package Version
Requires tourze/base Version ^1.0
twig/twig Version ^1.21
twig/extensions Version ^1.3
doctrine/cache Version ^1.4
asm89/twig-cache-extension Version ^1.0
league/commonmark Version ~0.5
aptoma/twig-markdown Version ~1.1
tourze/twig-html-helpers 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 tourze/twig contains the following files

Loading the files please wait ....