From: Fabien Potencier Date: Sat, 28 Sep 2013 08:50:34 +0000 (+0200) Subject: tweaked intro chapter X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=dd1ead2323e0575102774566cd3ab7e5e78cccdb;p=web%2Fkonrad%2Ftwig.git tweaked intro chapter --- 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();