Browse code

simplified the intro doc page

Fabien Potencier authored on 28/09/2013 08:25:36
Showing 3 changed files
... ...
@@ -15,4 +15,5 @@ Twig
15 15
     filters/index
16 16
     functions/index
17 17
     tests/index
18
+    installation
18 19
     deprecated
19 20
new file mode 100644
... ...
@@ -0,0 +1,118 @@
1
+Installation
2
+============
3
+
4
+You have multiple ways to install Twig.
5
+
6
+Installing the Twig PHP package
7
+-------------------------------
8
+
9
+Installing via Composer (recommended)
10
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11
+
12
+1. Install composer in your project:
13
+
14
+.. code-block:: bash
15
+
16
+    curl -s http://getcomposer.org/installer | php
17
+
18
+2. Create a ``composer.json`` file in your project root:
19
+
20
+.. code-block:: javascript
21
+
22
+    {
23
+        "require": {
24
+            "twig/twig": "1.*"
25
+        }
26
+    }
27
+
28
+3. Install via composer
29
+
30
+.. code-block:: bash
31
+
32
+    php composer.phar install
33
+
34
+.. note::
35
+    If you want to learn more about Composer, the ``composer.json`` file syntax
36
+    and its usage, you can read the `online documentation`_.
37
+
38
+Installing from the tarball release
39
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40
+
41
+1. Download the most recent tarball from the `download page`_
42
+2. Unpack the tarball
43
+3. Move the files somewhere in your project
44
+
45
+Installing the development version
46
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47
+
48
+1. Install Git
49
+2. ``git clone git://github.com/fabpot/Twig.git``
50
+
51
+Installing the PEAR package
52
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
53
+
54
+1. Install PEAR
55
+2. ``pear channel-discover pear.twig-project.org``
56
+3. ``pear install twig/Twig`` (or ``pear install twig/Twig-beta``)
57
+
58
+Installing the C extension
59
+--------------------------
60
+
61
+.. versionadded:: 1.4
62
+    The C extension was added in Twig 1.4.
63
+
64
+Twig comes with a C extension that enhances the performance of the Twig
65
+runtime engine.
66
+
67
+You can install it via PEAR:
68
+
69
+1. Install PEAR
70
+2. ``pear channel-discover pear.twig-project.org``
71
+3. ``pear install twig/CTwig`` (or ``pear install twig/CTwig-beta``)
72
+
73
+Or manually like any other PHP extension:
74
+
75
+.. code-block:: bash
76
+
77
+    $ cd ext/twig
78
+    $ phpize
79
+    $ ./configure
80
+    $ make
81
+    $ make install
82
+
83
+For Windows:
84
+
85
+1. Setup the build environment following the `PHP documentation`_
86
+2. Put twig C extension source code into ``C:\php-sdk\phpdev\vcXX\x86\php-source-directory\ext\twig``
87
+3. Use the ``configure --disable-all --enable-cli --enable-twig=shared`` command instead of step 14
88
+4. ``nmake``
89
+5. Copy the ``C:\php-sdk\phpdev\vcXX\x86\php-source-directory\Release_TS\php_twig.dll`` file to your PHP setup.
90
+
91
+.. tip::
92
+
93
+    For Windows ZendServer, TS is not enabled as mentionned in `Zend Server
94
+    FAQ`_.
95
+
96
+    You have to use `configure --disable-all --disable-zts --enable-cli
97
+    --enable-twig=shared` to be able to build the twig C extension for
98
+    ZendServer.
99
+
100
+    The built DLL will be available in
101
+    C:\php-sdk\phpdev\vcXX\x86\php-source-directory\Release
102
+
103
+Finally, enable the extension in your ``php.ini`` configuration file:
104
+
105
+.. code-block:: ini
106
+
107
+    extension=twig.so #For Unix systems
108
+    extension=php_twig.dll #For Windows systems
109
+
110
+And from now on, Twig will automatically compile your templates to take
111
+advantage of the C extension. Note that this extension does not replace the
112
+PHP code but only provides an optimized version of the
113
+``Twig_Template::getAttribute()`` method.
114
+
115
+.. _`download page`: https://github.com/fabpot/Twig/tags
116
+.. _`online documentation`: http://getcomposer.org/doc
117
+.. _`PHP documentation`: https://wiki.php.net/internals/windows/stepbystepbuild
118
+.. _`Zend Server FAQ`: http://www.zend.com/en/products/server/faq#faqD6
... ...
@@ -29,113 +29,17 @@ Twig needs at least **PHP 5.2.4** to run.
29 29
 Installation
30 30
 ------------
31 31
 
32
-You have multiple ways to install Twig.
33
-
34
-Installing via Composer (recommended)
35
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36
-
37
-1. Install composer in your project:
38
-
39
-.. code-block:: bash
40
-
41
-    curl -s http://getcomposer.org/installer | php
42
-
43
-2. Create a ``composer.json`` file in your project root:
44
-
45
-.. code-block:: javascript
46
-
47
-    {
48
-        "require": {
49
-            "twig/twig": "1.*"
50
-        }
51
-    }
52
-
53
-3. Install via composer
32
+The recommended way to install Twig is via Composer:
54 33
 
55 34
 .. code-block:: bash
56 35
 
57
-    php composer.phar install
36
+    composer require twig/twig:1.*
58 37
 
59 38
 .. note::
60
-    If you want to learn more about Composer, the ``composer.json`` file syntax
61
-    and its usage, you can read the `online documentation`_.
62
-
63
-Installing from the tarball release
64
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65
-
66
-1. Download the most recent tarball from the `download page`_
67
-2. Unpack the tarball
68
-3. Move the files somewhere in your project
69
-
70
-Installing the development version
71
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72
-
73
-1. Install Git
74
-2. ``git clone git://github.com/fabpot/Twig.git``
75
-
76
-Installing the PEAR package
77
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
78
-
79
-1. Install PEAR
80
-2. ``pear channel-discover pear.twig-project.org``
81
-3. ``pear install twig/Twig`` (or ``pear install twig/Twig-beta``)
82
-
83
-Installing the C extension
84
-~~~~~~~~~~~~~~~~~~~~~~~~~~
85
-
86
-.. versionadded:: 1.4
87
-    The C extension was added in Twig 1.4.
88 39
 
89
-Twig comes with a C extension that enhances the performance of the Twig
90
-runtime engine.
91
-
92
-You can install it via PEAR:
93
-
94
-1. Install PEAR
95
-2. ``pear channel-discover pear.twig-project.org``
96
-3. ``pear install twig/CTwig`` (or ``pear install twig/CTwig-beta``)
97
-
98
-Or manually like any other PHP extension:
99
-
100
-.. code-block:: bash
101
-
102
-    $ cd ext/twig
103
-    $ phpize
104
-    $ ./configure
105
-    $ make
106
-    $ make install
107
-
108
-For Windows:
109
-
110
-1. Setup the build environment following the `PHP documentation`_
111
-2. Put twig C extension source code into ``C:\php-sdk\phpdev\vcXX\x86\php-source-directory\ext\twig``
112
-3. Use the ``configure --disable-all --enable-cli --enable-twig=shared`` command instead of step 14
113
-4. ``nmake``
114
-5. Copy the ``C:\php-sdk\phpdev\vcXX\x86\php-source-directory\Release_TS\php_twig.dll`` file to your PHP setup.
115
-
116
-.. tip::
117
-
118
-    For Windows ZendServer, TS is not enabled as mentionned in `Zend Server
119
-    FAQ`_.
120
-
121
-    You have to use `configure --disable-all --disable-zts --enable-cli
122
-    --enable-twig=shared` to be able to build the twig C extension for
123
-    ZendServer.
124
-
125
-    The built DLL will be available in
126
-    C:\php-sdk\phpdev\vcXX\x86\php-source-directory\Release
127
-
128
-Finally, enable the extension in your ``php.ini`` configuration file:
129
-
130
-.. code-block:: ini
131
-
132
-    extension=twig.so #For Unix systems
133
-    extension=php_twig.dll #For Windows systems
134
-
135
-And from now on, Twig will automatically compile your templates to take
136
-advantage of the C extension. Note that this extension does not replace the
137
-PHP code but only provides an optimized version of the
138
-``Twig_Template::getAttribute()`` method.
40
+    To learn more about the other installation methods, read the
41
+    :doc:`installation<installation>` chapter; it also explains how to install
42
+    the Twig C extension.
139 43
 
140 44
 Basic API Usage
141 45
 ---------------
... ...
@@ -182,8 +86,3 @@ filesystem loader::
182 86
     ));
183 87
 
184 88
     echo $twig->render('index.html', array('name' => 'Fabien'));
185
-
186
-.. _`download page`: https://github.com/fabpot/Twig/tags
187
-.. _`online documentation`: http://getcomposer.org/doc
188
-.. _`PHP documentation`: https://wiki.php.net/internals/windows/stepbystepbuild
189
-.. _`Zend Server FAQ`: http://www.zend.com/en/products/server/faq#faqD6