Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Commit 82de393

Browse files
committed
Merge branch '2.2'
* 2.2: (28 commits) added missing license and type in composer.json (refs #527) updated VENDORS for 2.2.1 Add commented framework.validation.cache = apc to prod config added loader variable typehint for easier manipulation in IDEs updated VENDORS for 2.1.9 add info about changed htaccess file made the startpage work when mod_rewrite is not available Refactoring isMethod, bind and Flash removed useless "use" statement redirect /app.php to prevent duplicate content updated VENDORS for 2.2.0 enabled the HTTP method override by default to be more BC (closes sensio/SensioGeneratorBundle#165) Revert "merged branch Tobion/patch-2 (PR #497)" Fragments typo updated VENDORS for 2.2.0-RC3 updated VENDORS for 2.1.8 Update composer.json added info about changed .htaccess removed QSA flag that is not needed redirect /app.php to prevent duplicate content ... Conflicts: composer.json composer.lock src/Acme/DemoBundle/Controller/DemoController.php
2 parents a7a2046 + b66df19 commit 82de393

File tree

11 files changed

+75
-22
lines changed

11 files changed

+75
-22
lines changed

UPGRADE-2.2.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
UPGRADE FROM 2.1 to 2.2
22
=======================
33

4-
* The ``_internal`` route is not used any more. It should then be removed from
5-
both your routing and security configurations. A ``router_proxy`` key has
4+
* The [`web/.htaccess`](https://github.com/symfony/symfony-standard/blob/2.2/web/.htaccess)
5+
file has been enhanced substantially to prevent duplicate content with and
6+
without `/app.php` in the URI. It also improves functionality when using
7+
Apache aliases or when mod_rewrite is not available. So you might want to
8+
update your `.htaccess` file as well.
9+
10+
* The ``_internal`` route is not used any more. It should then be removed
11+
from both your routing and security configurations. A ``fragments`` key has
612
been added to the framework configuration and must be specified when ESI or
713
Hinclude are in use. No security configuration is required for this path as
8-
by default ESI access is only permitted for trusted hosts and Hinclude access
9-
uses an URL signing mechanism.
14+
by default ESI access is only permitted for trusted hosts and Hinclude
15+
access uses an URL signing mechanism.
1016

1117
```
1218
framework:
1319
# ...
14-
router_proxy: { path: /_proxy }
20+
fragments: { path: /_proxy }
1521
```
1622

1723
Functional Tests

app/autoload.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<?php
22

33
use Doctrine\Common\Annotations\AnnotationRegistry;
4+
use Composer\Autoload\ClassLoader;
45

6+
/**
7+
* @var $loader ClassLoader
8+
*/
59
$loader = require __DIR__.'/../vendor/autoload.php';
610

711
// intl

app/config/config.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ framework:
99
router:
1010
resource: "%kernel.root_dir%/config/routing.yml"
1111
strict_requirements: %kernel.debug%
12-
form: true
13-
csrf_protection: true
12+
form: ~
13+
csrf_protection: ~
1414
validation: { enable_annotations: true }
15-
templating: { engines: ['twig'] } #assets_version: SomeVersionScheme
15+
templating:
16+
engines: ['twig']
17+
#assets_version: SomeVersionScheme
1618
default_locale: "%locale%"
1719
trusted_proxies: ~
1820
session: ~
19-
#router_proxy: { path: /_proxy }
21+
fragments: ~
2022

2123
# Twig Configuration
2224
twig:

app/config/config_prod.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ imports:
88
framework:
99
router:
1010
strict_requirements: null
11+
#validation:
12+
# cache: apc
1113

1214
#doctrine:
1315
# orm:

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"name": "symfony/framework-standard-edition",
3+
"license": "MIT",
4+
"type": "project",
35
"description": "The \"Symfony Standard Edition\" distribution",
46
"autoload": {
57
"psr-0": { "": "src/" }
@@ -36,13 +38,12 @@
3638
"config": {
3739
"bin-dir": "bin"
3840
},
39-
"minimum-stability": "dev",
41+
"minimum-stability": "alpha",
4042
"extra": {
4143
"symfony-app-dir": "app",
4244
"symfony-web-dir": "web",
4345
"branch-alias": {
4446
"dev-master": "2.3-dev"
4547
}
46-
},
47-
"type": "project"
48+
}
4849
}

src/Acme/DemoBundle/Controller/DemoController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public function contactAction()
3939
$form = $this->get('form.factory')->create(new ContactType());
4040

4141
$request = $this->get('request');
42-
if ('POST' == $request->getMethod()) {
42+
if ($request->isMethod('POST')) {
4343
$form->bind($request);
4444
if ($form->isValid()) {
4545
$mailer = $this->get('mailer');
4646
// .. setup a message and send it
4747
// http://symfony.com/doc/current/cookbook/email.html
4848

49-
$this->get('session')->setFlash('notice', 'Message sent!');
49+
$this->get('session')->getFlashBag()->set('notice', 'Message sent!');
5050

5151
return new RedirectResponse($this->generateUrl('_demo'));
5252
}

src/Acme/DemoBundle/EventListener/ControllerListener.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Acme\DemoBundle\EventListener;
44

5-
use Symfony\Component\EventDispatcher\Event;
65
use Symfony\Component\HttpKernel\HttpKernelInterface;
76
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
87
use Acme\DemoBundle\Twig\Extension\DemoExtension;

src/Acme/DemoBundle/Twig/Extension/DemoExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
namespace Acme\DemoBundle\Twig\Extension;
44

5-
use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader;
65
use CG\Core\ClassUtils;
76

87
class DemoExtension extends \Twig_Extension
98
{
109
protected $loader;
1110
protected $controller;
1211

13-
public function __construct(FilesystemLoader $loader)
12+
public function __construct(\Twig_LoaderInterface $loader)
1413
{
1514
$this->loader = $loader;
1615
}

web/.htaccess

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,48 @@
1+
# Use the front controller as index file. It serves as fallback solution when
2+
# every other rewrite/redirect fails (e.g. in an aliased environment without
3+
# mod_rewrite). Additionally, this reduces the matching process for the
4+
# startpage (path "/") because otherwise Apache will apply the rewritting rules
5+
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
6+
DirectoryIndex app.php
7+
18
<IfModule mod_rewrite.c>
29
RewriteEngine On
310

4-
#<IfModule mod_vhost_alias.c>
5-
# RewriteBase /
6-
#</IfModule>
11+
# Redirect to URI without front controller to prevent duplicate content
12+
# (with and without `/app.php`). Only do this redirect on the initial
13+
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an
14+
# endless redirect loop (request -> rewrite to front controller ->
15+
# redirect -> request -> ...).
16+
# So in case you get a "too many redirects" error or you always get redirected
17+
# to the startpage because your Apache does not expose the REDIRECT_STATUS
18+
# environment variable, you have 2 choices:
19+
# - disable this feature by commenting the following 2 lines or
20+
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
21+
# following RewriteCond (best solution)
22+
RewriteCond %{ENV:REDIRECT_STATUS} ^$
23+
RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
24+
25+
# If the requested filename exists, simply serve it.
26+
# We only want to let Apache serve files and not directories.
27+
RewriteCond %{REQUEST_FILENAME} -f
28+
RewriteRule .? - [L]
29+
30+
# The following rewrites all other queries to the front controller. The
31+
# condition ensures that if you are using Apache aliases to do mass virtual
32+
# hosting, the base path will be prepended to allow proper resolution of the
33+
# app.php file; it will work in non-aliased environments as well, providing
34+
# a safe, one-size fits all solution.
35+
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
36+
RewriteRule ^(.*) - [E=BASE:%1]
37+
RewriteRule .? %{ENV:BASE}app.php [L]
38+
</IfModule>
739

8-
RewriteCond %{REQUEST_FILENAME} !-f
9-
RewriteRule ^(.*)$ app.php [QSA,L]
40+
<IfModule !mod_rewrite.c>
41+
<IfModule mod_alias.c>
42+
# When mod_rewrite is not available, we instruct a temporary redirect of
43+
# the startpage to the front controller explicitly so that the website
44+
# and the generated links can still be used.
45+
RedirectMatch 302 ^/$ /app.php/
46+
# RedirectTemp cannot be used instead
47+
</IfModule>
1048
</IfModule>

web/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
$kernel = new AppKernel('prod', false);
2020
$kernel->loadClassCache();
2121
//$kernel = new AppCache($kernel);
22+
Request::enableHttpMethodParameterOverride();
2223
$request = Request::createFromGlobals();
2324
$response = $kernel->handle($request);
2425
$response->send();

web/app_dev.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
$kernel = new AppKernel('dev', true);
2323
$kernel->loadClassCache();
24+
Request::enableHttpMethodParameterOverride();
2425
$request = Request::createFromGlobals();
2526
$response = $kernel->handle($request);
2627
$response->send();

0 commit comments

Comments
 (0)