4 You have multiple ways to install Twig.
6 Installing the Twig PHP package
7 -------------------------------
9 Installing via Composer (recommended)
10 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 Install `Composer`_ and run the following command to get the latest version:
16 composer require twig/twig:~1.0
18 Installing from the tarball release
19 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21 1. Download the most recent tarball from the `download page`_
22 2. Verify the integrity of the tarball http://fabien.potencier.org/article/73/signing-project-releases
24 4. Move the files somewhere in your project
26 Installing the development version
27 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31 git clone git://github.com/twigphp/Twig.git
33 Installing the PEAR package
34 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
38 Using PEAR for installing Twig is deprecated and Twig 1.15.1 was the last
39 version published on the PEAR channel; use Composer instead.
43 pear channel-discover pear.twig-project.org
44 pear install twig/Twig
46 Installing the C extension
47 --------------------------
50 The C extension was added in Twig 1.4.
54 The C extension is **optional** but it brings some nice performance
55 improvements. Note that the extension is not a replacement for the PHP
56 code; it only implements a small part of the PHP code to improve the
57 performance at runtime; you must still install the regular PHP code.
59 Twig comes with a C extension that enhances the performance of the Twig
60 runtime engine; install it like any other PHP extensions:
72 You can also install the C extension via PEAR (note that this method is
73 deprecated and newer versions of Twig are not available on the PEAR
78 pear channel-discover pear.twig-project.org
79 pear install twig/CTwig
83 1. Setup the build environment following the `PHP documentation`_
84 2. Put Twig's C extension source code into ``C:\php-sdk\phpdev\vcXX\x86\php-source-directory\ext\twig``
85 3. Use the ``configure --disable-all --enable-cli --enable-twig=shared`` command instead of step 14
87 5. Copy the ``C:\php-sdk\phpdev\vcXX\x86\php-source-directory\Release_TS\php_twig.dll`` file to your PHP setup.
91 For Windows ZendServer, ZTS is not enabled as mentioned in `Zend Server
94 You have to use ``configure --disable-all --disable-zts --enable-cli
95 --enable-twig=shared`` to be able to build the twig C extension for
98 The built DLL will be available in
99 ``C:\\php-sdk\\phpdev\\vcXX\\x86\\php-source-directory\\Release``
101 Finally, enable the extension in your ``php.ini`` configuration file:
105 extension=twig.so #For Unix systems
106 extension=php_twig.dll #For Windows systems
108 And from now on, Twig will automatically compile your templates to take
109 advantage of the C extension. Note that this extension does not replace the
110 PHP code but only provides an optimized version of the
111 ``Twig_Template::getAttribute()`` method.
113 .. _`download page`: https://github.com/twigphp/Twig/tags
114 .. _`Composer`: https://getcomposer.org/download/
115 .. _`PHP documentation`: https://wiki.php.net/internals/windows/stepbystepbuild
116 .. _`Zend Server FAQ`: http://www.zend.com/en/products/server/faq#faqD6