From 229dd4f39639ddc8a6b51e9c478f3f0cb05a71a0 Mon Sep 17 00:00:00 2001 From: Sebastian Goettschkes Date: Fri, 30 Nov 2012 20:26:00 +0100 Subject: [PATCH 1/2] Changing description of symfony installation to composer --- book/from_flat_php_to_symfony2.rst | 47 +++++++++++++----------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/book/from_flat_php_to_symfony2.rst b/book/from_flat_php_to_symfony2.rst index 677ab92ad38..da100862d5d 100644 --- a/book/from_flat_php_to_symfony2.rst +++ b/book/from_flat_php_to_symfony2.rst @@ -420,34 +420,29 @@ Why should you have to reinvent solutions to all these routine problems? Add a Touch of Symfony2 ~~~~~~~~~~~~~~~~~~~~~~~ -Symfony2 to the rescue. Before actually using Symfony2, you need to make -sure PHP knows how to find the Symfony2 classes. This is accomplished via -an autoloader that Symfony provides. An autoloader is a tool that makes it -possible to start using PHP classes without explicitly including the file -containing the class. +Symfony2 to the rescue. Before actually using Symfony2, you need to download +it. This can be done by using composer, which takes care of downloading the +correct version and all it's dependencies and provides an autoloader. An +autoloader is a tool that makes it possible to start using PHP classes +without explicitly including the file containing the class. -First, `download Symfony`_ and place it into a ``vendor/symfony/symfony/`` directory. -Next, create an ``app/bootstrap.php`` file. Use it to ``require`` the two -files in the application and to configure the autoloader: +In your root directory, create a ``composer.json`` file with the following +content: -.. code-block:: html+php - - registerNamespaces(array( - 'Symfony' => __DIR__.'/../vendor/symfony/symfony/src', - )); - - $loader->register(); - -This tells the autoloader where the ``Symfony`` classes are. With this, you -can start using Symfony classes without using the ``require`` statement for -the files that contain them. + { + "require": { + "symfony/symfony": "2.1.*" + }, + "autoload": { + "files": ["model.php","controller.php"] + } + } + +After installing your dependencies, composer has generated ``vendor/autoload.php``, +which takes care to include all files from the symfony framework as well as +the files mentioned in the autoload section of your composer.json. Core to Symfony's philosophy is the idea that an application's main job is to interpret each request and return a response. To this end, Symfony2 provides @@ -460,7 +455,7 @@ the HTTP response being returned. Use them to improve the blog: Date: Sun, 2 Dec 2012 12:49:41 +0100 Subject: [PATCH 2/2] Bugfixing a few typos; Adding install command for composer --- book/from_flat_php_to_symfony2.rst | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/book/from_flat_php_to_symfony2.rst b/book/from_flat_php_to_symfony2.rst index da100862d5d..a72a4570a75 100644 --- a/book/from_flat_php_to_symfony2.rst +++ b/book/from_flat_php_to_symfony2.rst @@ -421,8 +421,8 @@ Add a Touch of Symfony2 ~~~~~~~~~~~~~~~~~~~~~~~ Symfony2 to the rescue. Before actually using Symfony2, you need to download -it. This can be done by using composer, which takes care of downloading the -correct version and all it's dependencies and provides an autoloader. An +it. This can be done by using Composer, which takes care of downloading the +correct version and all its dependencies and provides an autoloader. An autoloader is a tool that makes it possible to start using PHP classes without explicitly including the file containing the class. @@ -440,9 +440,16 @@ content: } } -After installing your dependencies, composer has generated ``vendor/autoload.php``, -which takes care to include all files from the symfony framework as well as -the files mentioned in the autoload section of your composer.json. +Next, `download Composer`_ and then run the following command, which will download Symfony +into a vendor/ directory: + +.. code-block:: bash + + $ php composer.phar install + +Beside downloading your dependencies, Composer generates a ``vendor/autoload.php`` file, +which takes care of autoloading for all the files in the Symfony Framework as well as +the files mentioned in the autoload section of your `composer.json`. Core to Symfony's philosophy is the idea that an application's main job is to interpret each request and return a response. To this end, Symfony2 provides @@ -735,7 +742,7 @@ Learn more from the Cookbook * :doc:`/cookbook/controller/service` .. _`Doctrine`: http://www.doctrine-project.org -.. _`download Symfony`: http://symfony.com/download +.. _`download Composer`: http://getcomposer.org/download/ .. _`Routing`: https://github.com/symfony/Routing .. _`Templating`: https://github.com/symfony/Templating .. _`KnpBundles.com`: http://knpbundles.com/