From dd1ead2323e0575102774566cd3ab7e5e78cccdb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Sep 2013 10:50:34 +0200 Subject: [PATCH] tweaked intro chapter --- doc/intro.rst | 25 ++++++++----------------- 1 files changed, 8 insertions(+), 17 deletions(-) diff --git a/doc/intro.rst b/doc/intro.rst index 8c49e20..9f0cdf0 100644 --- a/doc/intro.rst +++ b/doc/intro.rst @@ -46,26 +46,10 @@ Basic API Usage This section gives you a brief introduction to the PHP API for Twig. -The first step to use Twig is to register its autoloader:: - - require_once '/path/to/lib/Twig/Autoloader.php'; - Twig_Autoloader::register(); - -Replace the ``/path/to/lib/`` path with the path you used for Twig -installation. - -If you have installed Twig via Composer you can take advantage of Composer's -autoload mechanism by replacing the previous snippet for:: +.. code-block:: php require_once '/path/to/vendor/autoload.php'; -.. note:: - - Twig follows the PEAR convention names for its classes, which means you - can easily integrate Twig classes loading in your own autoloader. - -.. code-block:: php - $loader = new Twig_Loader_String(); $twig = new Twig_Environment($loader); @@ -86,3 +70,10 @@ filesystem loader:: )); echo $twig->render('index.html', array('name' => 'Fabien')); + +.. tip:: + + If you are not using Composer, use the Twig built-in autoloader:: + + require_once '/path/to/lib/Twig/Autoloader.php'; + Twig_Autoloader::register(); -- 1.7.2.5