|
1 | 1 | The Big Picture
|
2 | 2 | ===============
|
3 | 3 |
|
4 |
| -Start using Symfony2 in 10 minutes! This chapter will walk you through some |
5 |
| -of the most important concepts behind Symfony2 and explain how you can get |
6 |
| -started quickly by showing you a simple project in action. |
| 4 | +This chapter will teach you how to develop a simple Symfony2 project in 10 |
| 5 | +minutes! If you've used a web framework before, you should feel right at home |
| 6 | +with Symfony2. If not, welcome to a whole new way of developing web applications. |
7 | 7 |
|
8 |
| -If you've used a web framework before, you should feel right at home with |
9 |
| -Symfony2. If not, welcome to a whole new way of developing web applications! |
| 8 | +Installing Symfony2 |
| 9 | +------------------- |
10 | 10 |
|
11 |
| -.. tip:: |
12 |
| - |
13 |
| - Want to learn why and when you need to use a framework? Read the "`Symfony |
14 |
| - in 5 minutes`_" document. |
15 |
| - |
16 |
| -Downloading Symfony2 |
17 |
| --------------------- |
18 |
| - |
19 |
| -First, check that you have installed and configured a Web server (such as |
20 |
| -Apache) with PHP 5.3.3 or higher. |
21 |
| - |
22 |
| -.. tip:: |
23 |
| - |
24 |
| - If you have PHP 5.4, you could use the built-in web server to start trying |
25 |
| - things out. We'll tell you how to start the built-in web server |
26 |
| - :ref:`after downloading Symfony<quick-tour-big-picture-built-in-server>`. |
27 |
| - |
28 |
| -Ready? Start by downloading the "`Symfony2 Standard Edition`_": a Symfony |
29 |
| -:term:`distribution` that is preconfigured for the most common use cases and |
30 |
| -also contains some code that demonstrates how to use Symfony2 (get the archive |
31 |
| -with the *vendors* included to get started even faster). |
32 |
| - |
33 |
| -After unpacking the archive under your web server root directory (if you'll |
34 |
| -use the built-in PHP web server, you can unpack it anywhere), you should |
35 |
| -have a ``Symfony/`` directory that looks like this: |
| 11 | +First, check that the PHP version installed on your computer meets the Symfony2 |
| 12 | +requirements: 5.3.3 or higher. Then, open a command console and execute the |
| 13 | +following command to install the latest version of Symfony2 in the ``myproject/`` |
| 14 | +directory: |
36 | 15 |
|
37 |
| -.. code-block:: text |
| 16 | +.. code-block:: bash |
38 | 17 |
|
39 |
| - www/ <- your web root directory |
40 |
| - Symfony/ <- the unpacked archive |
41 |
| - app/ |
42 |
| - cache/ |
43 |
| - config/ |
44 |
| - logs/ |
45 |
| - Resources/ |
46 |
| - bin/ |
47 |
| - src/ |
48 |
| - Acme/ |
49 |
| - DemoBundle/ |
50 |
| - Controller/ |
51 |
| - Resources/ |
52 |
| - ... |
53 |
| - vendor/ |
54 |
| - symfony/ |
55 |
| - doctrine/ |
56 |
| - ... |
57 |
| - web/ |
58 |
| - app.php |
59 |
| - ... |
| 18 | + $ composer create-project symfony/framework-standard-edition myproject/ ~2.4 |
60 | 19 |
|
61 | 20 | .. note::
|
62 | 21 |
|
63 |
| - If you are familiar with `Composer`_, you can download Composer and then |
64 |
| - run the following command instead of downloading the archive (replacing |
65 |
| - ``2.3.0`` with the latest Symfony release like ``2.3.1``): |
| 22 | + `Composer <https://getcomposer.org/>` is the package manager used by modern |
| 23 | + PHP applications and the only recommended way to install Symfony2. To |
| 24 | + install Composer on your Linux or Mac system, execute the following commands: |
66 | 25 |
|
67 | 26 | .. code-block:: bash
|
68 | 27 |
|
69 |
| - $ php composer.phar create-project symfony/framework-standard-edition Symfony 2.3.0 |
70 |
| -
|
71 |
| -.. _`quick-tour-big-picture-built-in-server`: |
72 |
| - |
73 |
| -If you have PHP 5.4, you can use the built-in web server: |
74 |
| - |
75 |
| -.. code-block:: bash |
76 |
| -
|
77 |
| - # check your PHP CLI configuration |
78 |
| - $ php app/check.php |
79 |
| -
|
80 |
| - # run the built-in web server |
81 |
| - $ php app/console server:run |
82 |
| -
|
83 |
| -Then the URL to your application will be "http://localhost:8000/app_dev.php" |
84 |
| - |
85 |
| -The built-in server should be used only for development purpose, but it |
86 |
| -can help you to start your project quickly and easily. |
| 28 | + $ curl -sS https://getcomposer.org/installer | php |
| 29 | + $ sudo mv composer.phar /usr/local/bin/composer |
87 | 30 |
|
88 |
| -If you're using a traditional web server like Apache, your URL depends on |
89 |
| -your configuration. If you've unzipped Symfony under your web root into a |
90 |
| -``Symfony`` directory, then the URL to your application will be: |
91 |
| -"http://localhost/Symfony/web/app_dev.php". |
92 |
| - |
93 |
| -.. note:: |
| 31 | + To install Composer on a Windows system, download the executable installer |
| 32 | + from `getcomposer.org/download <http://getcomposer.org/download>`. |
94 | 33 |
|
95 |
| - Read more in our :doc:`/cookbook/configuration/web_server_configuration` |
96 |
| - section. |
| 34 | +Beware that the first time you install Symfony2, it may take a few minutes to |
| 35 | +download all its components. At the end of the installation process, the |
| 36 | +installer will ask you to provide some configuration options for the Symfony2 |
| 37 | +project. For this first project you can safely ignore this configuration by |
| 38 | +pressing the ``<Enter>`` key repeatedly. |
97 | 39 |
|
98 |
| -Checking the Configuration |
99 |
| --------------------------- |
100 |
| - |
101 |
| -Symfony2 comes with a visual server configuration tester to help avoid some |
102 |
| -headaches that come from Web server or PHP misconfiguration. Use the following |
103 |
| -URL to see the diagnostics for your machine: |
| 40 | +.. The following GIF is only useful if the user can "click" on it |
| 41 | +.. to activate the animation. Otherwise, it shouldn't be included |
| 42 | +.. because it's too long and it doesn't make sense to see it half-started. |
| 43 | +.. image:: /images/quick_tour/installing_symfony2.gif |
| 44 | + :align: center |
| 45 | + :alt: Installing Symfony2 on the command console |
104 | 46 |
|
105 |
| -.. code-block:: text |
| 47 | +Running Symfony2 |
| 48 | +---------------- |
106 | 49 |
|
107 |
| - http://localhost/config.php |
| 50 | +Before running Symfony2 for the first time, execute the following command to |
| 51 | +make sure that your system meets all the technical requirements: |
108 | 52 |
|
109 |
| -.. note:: |
| 53 | +.. code-block:: bash |
110 | 54 |
|
111 |
| - All of the example URLs assume you've setup your web server to point |
112 |
| - directly to the ``web/`` directory of your new project, which is different |
113 |
| - and a bit more advanced than the process shown above. So, the URL on your |
114 |
| - machine will vary - e.g. ``http://localhost:8000/config.php`` |
115 |
| - or ``http://localhost/Symfony/web/config.php``. See the |
116 |
| - :ref:`above section<quick-tour-big-picture-built-in-server>` for details |
117 |
| - on what your URL should be and use it below in all of the examples. |
| 55 | + $ cd myproject/ |
| 56 | + $ php app/check.php |
118 | 57 |
|
119 |
| -If there are any outstanding issues listed, correct them. You might also tweak |
120 |
| -your configuration by following any given recommendations. When everything is |
121 |
| -fine, click on "*Bypass configuration and go to the Welcome page*" to request |
122 |
| -your first "real" Symfony2 webpage: |
| 58 | +Fix any error reported by the command and then, use the PHP built-in web server |
| 59 | +to run Symfony: |
123 | 60 |
|
124 |
| -.. code-block:: text |
| 61 | +.. code-block:: bash |
125 | 62 |
|
126 |
| - http://localhost/app_dev.php/ |
| 63 | + $ php app/console server:run |
127 | 64 |
|
128 |
| -Symfony2 should welcome and congratulate you for your hard work so far! |
| 65 | +Open your browser and access to the ``http://localhost:8000/`` URL to see the |
| 66 | +Welcome page of Symfony2: |
129 | 67 |
|
130 |
| -.. image:: /images/quick_tour/welcome.png |
| 68 | +.. image:: /images/quick_tour/symfony2_welcome_page.png |
131 | 69 | :align: center
|
| 70 | + :alt: Symfony2 Welcome Page |
| 71 | + |
| 72 | +The built-in web server is available for PHP 5.4.0 or higher. If you have an |
| 73 | +older version of PHP or if you prefer a traditional web server such as Apache |
| 74 | +or Nginx, read the :doc:`/cookbook/configuration/web_server_configuration` |
| 75 | +article. |
132 | 76 |
|
133 | 77 | Understanding the Fundamentals
|
134 | 78 | ------------------------------
|
135 | 79 |
|
136 |
| -One of the main goals of a framework is to ensure `Separation of Concerns`_. |
137 |
| -This keeps your code organized and allows your application to evolve easily |
138 |
| -over time by avoiding the mixing of database calls, HTML tags, and business |
139 |
| -logic in the same script. To achieve this goal with Symfony, you'll first |
140 |
| -need to learn a few fundamental concepts and terms. |
141 |
| - |
142 |
| -.. tip:: |
143 |
| - |
144 |
| - Want proof that using a framework is better than mixing everything |
145 |
| - in the same script? Read the ":doc:`/book/from_flat_php_to_symfony2`" |
146 |
| - chapter of the book. |
| 80 | +One of the main goals of a framework is to keep your code organized and allow |
| 81 | +your application to evolve easily over time by avoiding the mixing of database |
| 82 | +calls, HTML tags, and business logic in the same script. To achieve this goal |
| 83 | +with Symfony, you'll first need to learn a few fundamental concepts and terms. |
147 | 84 |
|
148 |
| -The distribution comes with some sample code that you can use to learn more |
149 |
| -about the main Symfony2 concepts. Go to the following URL to be greeted by |
150 |
| -Symfony2 (replace *Fabien* with your first name): |
| 85 | +Symfony comes with some sample code that you can use to learn more about its |
| 86 | +main concepts. Go to the following URL to be greeted by Symfony2 (replace |
| 87 | +*Fabien* with your first name): |
151 | 88 |
|
152 | 89 | .. code-block:: text
|
153 | 90 |
|
154 |
| - http://localhost/app_dev.php/demo/hello/Fabien |
| 91 | + http://localhost:8000/app_dev.php/demo/hello/Fabien |
155 | 92 |
|
156 | 93 | .. image:: /images/quick_tour/hello_fabien.png
|
157 | 94 | :align: center
|
|
0 commit comments