Skip to content

Commit f681fa4

Browse files
committed
Merge branch '4.0'
* 4.0: Made two configuration sub guides flex-ready removing h1 but making JS more fool-proof Fix grammar Make use of %kernel.project_dir% parameter Update server configuration for Symfony 4 Change web directory with public directory Mention the handy `ignoreExtraKeys()` method add empty h1 tags to html template
2 parents 1b5a32a + a1901ff commit f681fa4

File tree

5 files changed

+29
-44
lines changed

5 files changed

+29
-44
lines changed

best_practices/creating-the-project.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Installing Symfony
88

99
Use Composer and Symfony Flex to create and manage Symfony applications.
1010

11-
`Composer`_ is the package manager used by modern PHP application to manage
11+
`Composer`_ is the package manager used by modern PHP applications to manage
1212
their dependencies. `Symfony Flex`_ is a Composer plugin designed to automate
1313
some of the most common tasks performed in Symfony applications. Using Flex is
1414
optional but recommended because it improves your productivity significantly.

components/config/definition.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ Before defining the children of an array node, you can provide options like:
219219
If called (with ``false``), keys with dashes are *not* normalized to underscores.
220220
It is recommended to use this with prototype nodes where the user will define
221221
a key-value map, to avoid an unnecessary transformation.
222+
``ignoreExtraKeys()``
223+
Allows extra config keys to be specified under an array without
224+
throwing an exception.
222225

223226
A basic prototyped array configuration can be defined as follows::
224227

configuration/override_dir_structure.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ define your own templates directory (or directories):
104104
# app/config/config.yml
105105
twig:
106106
# ...
107-
paths: ["%kernel.root_dir%/../templates"]
107+
paths: ["%kernel.project_dir%/templates"]
108108
109109
.. code-block:: xml
110110
@@ -119,7 +119,7 @@ define your own templates directory (or directories):
119119
http://symfony.com/schema/dic/twig/twig-1.0.xsd">
120120
121121
<twig:config>
122-
<twig:path>%kernel.root_dir%/../templates</twig:path>
122+
<twig:path>%kernel.project_dir%/templates</twig:path>
123123
</twig:config>
124124
125125
</container>
@@ -129,7 +129,7 @@ define your own templates directory (or directories):
129129
// app/config/config.php
130130
$container->loadFromExtension('twig', array(
131131
'paths' => array(
132-
'%kernel.root_dir%/../templates',
132+
'%kernel.project_dir%/templates',
133133
),
134134
));
135135
@@ -197,7 +197,7 @@ You also need to change the ``extra.symfony-web-dir`` option in the
197197
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">
198198
199199
<!-- ... -->
200-
<assetic:config read-from="%kernel.root_dir%/../../public_html" />
200+
<assetic:config read-from="%kernel.project_dir%/../public_html" />
201201
202202
</container>
203203

frontend/encore/simple-example.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Great! Use ``require()`` to import ``jquery`` and ``greet.js``:
144144
var greet = require('./greet');
145145
146146
$(document).ready(function() {
147-
$('h1').html(greet('john'));
147+
$('body').prepend('<h1>'+greet('john')+'</h1>');
148148
});
149149
150150
That's it! When you build your assets, jQuery and ``greet.js`` will automatically

setup/web_server_configuration.rst

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ When using Apache, you can configure PHP as an
1515
:ref:`PHP FPM <web-server-apache-fpm>`. FastCGI also is the preferred way
1616
to use PHP :ref:`with Nginx <web-server-nginx>`.
1717

18-
.. sidebar:: The Web Directory
18+
.. sidebar:: The public directory
1919

20-
The web directory is the home of all of your application's public and
20+
The public directory is the home of all of your application's public and
2121
static files, including images, stylesheets and JavaScript files. It is
22-
also where the front controllers (``index.php`` and ``index.php``) live.
22+
also where the front controller (``index.php``) lives.
2323

24-
The web directory serves as the document root when configuring your
24+
The public directory serves as the document root when configuring your
2525
web server. In the examples below, the ``public/`` directory will be the
2626
document root. This directory is ``/var/www/project/public/``.
2727

@@ -42,8 +42,8 @@ The **minimum configuration** to get your application running under Apache is:
4242
ServerName domain.tld
4343
ServerAlias www.domain.tld
4444
45-
DocumentRoot /var/www/project/web
46-
<Directory /var/www/project/web>
45+
DocumentRoot /var/www/project/public
46+
<Directory /var/www/project/public>
4747
AllowOverride All
4848
Order Allow,Deny
4949
Allow from All
@@ -73,8 +73,8 @@ and increase web server performance:
7373
ServerName domain.tld
7474
ServerAlias www.domain.tld
7575
76-
DocumentRoot /var/www/project/web
77-
<Directory /var/www/project/web>
76+
DocumentRoot /var/www/project/public
77+
<Directory /var/www/project/public>
7878
AllowOverride None
7979
Order Allow,Deny
8080
Allow from All
@@ -123,7 +123,7 @@ Hence, you need to modify your ``Directory`` permission settings as follows:
123123

124124
.. code-block:: apache
125125
126-
<Directory /var/www/project/web>
126+
<Directory /var/www/project/public>
127127
Require all granted
128128
# ...
129129
</Directory>
@@ -193,8 +193,8 @@ use the ``SetHandler`` directive to pass requests for PHP files to PHP FPM:
193193
# regular expression must be changed accordingly:
194194
# ProxyPassMatch ^/path-to-app/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
195195
196-
DocumentRoot /var/www/project/web
197-
<Directory /var/www/project/web>
196+
DocumentRoot /var/www/project/public
197+
<Directory /var/www/project/public>
198198
# enable the .htaccess rewrites
199199
AllowOverride All
200200
Require all granted
@@ -228,8 +228,8 @@ should look something like this:
228228
Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
229229
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -host 127.0.0.1:9000 -pass-header Authorization
230230
231-
DocumentRoot /var/www/project/web
232-
<Directory /var/www/project/web>
231+
DocumentRoot /var/www/project/public
232+
<Directory /var/www/project/public>
233233
# enable the .htaccess rewrites
234234
AllowOverride All
235235
Order Allow,Deny
@@ -264,31 +264,14 @@ The **minimum configuration** to get your application running under Nginx is:
264264
265265
server {
266266
server_name domain.tld www.domain.tld;
267-
root /var/www/project/web;
267+
root /var/www/project/public;
268268
269269
location / {
270270
# try to serve file directly, fallback to index.php
271271
try_files $uri /index.php$is_args$args;
272272
}
273-
# DEV
274-
# This rule should only be placed on your development environment
275-
# In production, don't include this and don't deploy index.php or config.php
276-
location ~ ^/(app_dev|config)\.php(/|$) {
277-
fastcgi_pass unix:/var/run/php7.1-fpm.sock;
278-
fastcgi_split_path_info ^(.+\.php)(/.*)$;
279-
include fastcgi_params;
280-
# When you are using symlinks to link the document root to the
281-
# current version of your application, you should pass the real
282-
# application path instead of the path to the symlink to PHP
283-
# FPM.
284-
# Otherwise, PHP's OPcache may not properly detect changes to
285-
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
286-
# for more information).
287-
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
288-
fastcgi_param DOCUMENT_ROOT $realpath_root;
289-
}
290-
# PROD
291-
location ~ ^/app\.php(/|$) {
273+
274+
location ~ ^/index\.php(/|$) {
292275
fastcgi_pass unix:/var/run/php7.1-fpm.sock;
293276
fastcgi_split_path_info ^(.+\.php)(/.*)$;
294277
include fastcgi_params;
@@ -324,17 +307,16 @@ The **minimum configuration** to get your application running under Nginx is:
324307

325308
.. tip::
326309

327-
This executes **only** ``index.php``, ``index.php`` and ``config.php`` in
328-
the web directory. All other files ending in ".php" will be denied.
310+
This executes **only** ``index.php`` in the public directory. All other files
311+
ending in ".php" will be denied.
329312

330-
If you have other PHP files in your web directory that need to be executed,
313+
If you have other PHP files in your public directory that need to be executed,
331314
be sure to include them in the ``location`` block above.
332315

333316
.. caution::
334317

335318
After you deploy to production, make sure that you **cannot** access the ``index.php``
336-
or ``config.php`` scripts (i.e. ``http://example.com/index.php`` and ``http://example.com/config.php``).
337-
If you *can* access these, be sure to remove the ``DEV`` section from the above configuration.
319+
script (i.e. ``http://example.com/index.php``).
338320

339321
.. note::
340322

0 commit comments

Comments
 (0)