@@ -4,53 +4,36 @@ Creating the Project
4
4
Installing Symfony
5
5
------------------
6
6
7
- In the past, Symfony projects were created with `Composer `_, the dependency manager
8
- for PHP applications. However, the current recommendation is to use the **Symfony
9
- Installer **, which has to be installed before creating your first project.
10
-
11
7
.. best-practice ::
12
8
13
- Use the Symfony Installer to create new Symfony-based projects.
9
+ Use the ` Symfony Skeleton `_ and ` Composer `_ to create new Symfony-based projects.
14
10
15
- Read the :doc: `/setup ` article learn how to install and use the Symfony
16
- Installer.
11
+ The **Symfony Skeleton ** is a minimal and empty Symfony project which you can
12
+ base your new projects on. Unlike past Symfony versions, this skeleton installs
13
+ the absolute bare minimum amount of dependencies to make a fully working Symfony
14
+ project. Read the :doc: `/setup ` article to learn more about installing Symfony.
17
15
18
16
.. _linux-and-mac-os-x-systems :
19
17
.. _windows-systems :
20
18
21
19
Creating the Blog Application
22
20
-----------------------------
23
21
24
- Now that everything is correctly set up, you can create a new project based on
25
- Symfony. In your command console, browse to a directory where you have permission
26
- to create files and execute the following commands:
22
+ In your command console, browse to a directory where you have permission to
23
+ create files and execute the following commands:
27
24
28
25
.. code-block :: terminal
29
26
30
27
$ cd projects/
31
- $ symfony new blog
32
-
33
- # Windows
34
- c:\> cd projects/
35
- c:\projects\> php symfony new blog
36
-
37
- .. note ::
38
-
39
- If the installer doesn't work for you or doesn't output anything, make sure
40
- that the `Phar extension `_ is installed and enabled on your computer.
28
+ $ composer create-project symfony/skeleton blog
41
29
42
30
This command creates a new directory called ``blog `` that contains a fresh new
43
- project based on the most recent stable Symfony version available. In addition,
44
- the installer checks if your system meets the technical requirements to execute
45
- Symfony applications. If not, you'll see the list of changes needed to meet those
46
- requirements.
31
+ project based on the most recent stable Symfony version available.
47
32
48
33
.. tip ::
49
34
50
- Symfony releases are digitally signed for security reasons. If you want to
51
- verify the integrity of your Symfony installation, take a look at the
52
- `public checksums repository `_ and follow `these steps `_ to verify the
53
- signatures.
35
+ The technical requirements to run Symfony are simple. If you want to check
36
+ if your system meets those requirements, read :doc: `/reference/requirements `.
54
37
55
38
Structuring the Application
56
39
---------------------------
@@ -61,47 +44,29 @@ number of files and directories generated automatically:
61
44
.. code-block :: text
62
45
63
46
blog/
64
- ├─ app/
65
- │ ├─ config/
66
- │ └─ Resources/
67
- ├─ bin
47
+ ├─ bin/
68
48
│ └─ console
49
+ ├─ config/
50
+ └─ public/
51
+ │ └─ index.php
69
52
├─ src/
70
- │ └─ AppBundle/
53
+ │ └─ Kernel.php
71
54
├─ var/
72
55
│ ├─ cache/
73
- │ ├─ logs/
74
- │ └─ sessions/
75
- ├─ tests/
76
- │ └─ AppBundle/
77
- ├─ vendor/
78
- └─ web/
56
+ │ └─ log/
57
+ └─ vendor/
79
58
80
59
This file and directory hierarchy is the convention proposed by Symfony to
81
- structure your applications. The recommended purpose of each directory is the
82
- following:
83
-
84
- * ``app/config/ ``, stores all the configuration defined for any environment;
85
- * ``app/Resources/ ``, stores all the templates and the translation files for the
86
- application;
87
- * ``src/AppBundle/ ``, stores the Symfony specific code (controllers and routes),
88
- your domain code (e.g. Doctrine classes) and all your business logic;
89
- * ``var/cache/ ``, stores all the cache files generated by the application;
90
- * ``var/log/ ``, stores all the log files generated by the application;
91
- * ``var/sessions/ ``, stores all the session files generated by the application;
92
- * ``tests/AppBundle/ ``, stores the automatic tests (e.g. Unit tests) of the
93
- application.
94
- * ``vendor/ ``, this is the directory where Composer installs the application's
95
- dependencies and you should never modify any of its contents;
96
- * ``web/ ``, stores all the front controller files and all the web assets, such
97
- as stylesheets, JavaScript files and images.
60
+ structure your applications. It's recommended to keep this structure because it's
61
+ easy to navigate and most directory names are self-explanatory, but you can
62
+ :doc: `override the location of any Symfony directory </configuration/override_dir_structure >`:
98
63
99
64
Application Bundles
100
65
~~~~~~~~~~~~~~~~~~~
101
66
102
67
When Symfony 2.0 was released, most developers naturally adopted the symfony
103
68
1.x way of dividing applications into logical modules. That's why many Symfony
104
- apps use bundles to divide their code into logical features: UserBundle,
69
+ apps used bundles to divide their code into logical features: UserBundle,
105
70
ProductBundle, InvoiceBundle, etc.
106
71
107
72
But a bundle is *meant * to be something that can be reused as a stand-alone
@@ -111,64 +76,11 @@ ProductBundle, then there's no advantage to having two separate bundles.
111
76
112
77
.. best-practice ::
113
78
114
- Create only one bundle called AppBundle for your application logic.
115
-
116
- Implementing a single AppBundle bundle in your projects will make your code
117
- more concise and easier to understand.
118
-
119
- .. note ::
120
-
121
- There is no need to prefix the AppBundle with your own vendor (e.g.
122
- AcmeAppBundle), because this application bundle is never going to be
123
- shared.
124
-
125
- .. note ::
126
-
127
- Another reason to create a new bundle is when you're overriding something
128
- in a vendor's bundle (e.g. a controller). See :doc: `/bundles/inheritance `.
129
-
130
- All in all, this is the typical directory structure of a Symfony application
131
- that follows these best practices:
132
-
133
- .. code-block :: text
134
-
135
- blog/
136
- ├─ app/
137
- │ ├─ config/
138
- │ └─ Resources/
139
- ├─ bin/
140
- │ └─ console
141
- ├─ src/
142
- │ └─ AppBundle/
143
- ├─ tests/
144
- │ └─ AppBundle/
145
- ├─ var/
146
- │ ├─ cache/
147
- │ ├─ logs/
148
- └─ sessions/
149
- ├─ vendor/
150
- └─ web/
151
- ├─ app.php
152
- └─ app_dev.php
153
-
154
- .. tip ::
155
-
156
- If your Symfony installation doesn't come with a pre-generated AppBundle,
157
- you can generate it by hand executing this command:
158
-
159
- .. code-block :: terminal
160
-
161
- $ php bin/console generate:bundle --namespace=AppBundle --dir=src --format=annotation --no-interaction
162
-
163
- Extending the Directory Structure
164
- ---------------------------------
79
+ Don't create any bundle to organize your application logic.
165
80
166
- If your project or infrastructure requires some changes to the default directory
167
- structure of Symfony, you can
168
- :doc: `override the location of the main directories </configuration/override_dir_structure >`:
169
- ``cache/ ``, ``logs/ `` and ``web/ ``.
81
+ Symfony applications can still use third-party bundles (installed in ``vendor/ ``)
82
+ to add features, but you should use PHP namespaces instead of bundles to organize
83
+ your own code.
170
84
85
+ .. _`Symfony Skeleton` : https://github.com/symfony/skeleton
171
86
.. _`Composer` : https://getcomposer.org/
172
- .. _`Phar extension` : http://php.net/manual/en/intro.phar.php
173
- .. _`public checksums repository` : https://github.com/sensiolabs/checksums
174
- .. _`these steps` : http://fabien.potencier.org/signing-project-releases.html
0 commit comments