This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Fabien Potencier 877603a9f3 merged branch fabpot/content-renderer-request (PR #6829)
This PR was merged into the master branch.

Commits
-------

23f5145 renamed proxy to router_proxy
e5135f6 [HttpKernel] renamed path to _path to avoid collision
3193a90 made the proxy path configurable
ad82893 removed the need for a proxy route for rendering strategies
b9f0e17 [HttpKernel] made the Request required when using rendering strategies

Discussion
----------

Content renderer simplification

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | symfony/symfony-docs#2179

Todo:

  - [x] submit a PR for documentation update

The first commit makes the Request required when dealing with rendering strategies (see the commit why this was a bad idea to make it optional in the first place).

The second commit removes the need for a proxy route and replaces it with the same system we have in the security component.

The third commit makes the proxy path configurable (default to `/_proxy`).

This PR has been triggered by a discussion on #6791.

---------------------------------------------------------------------------

by fabpot at 2013-01-22T09:49:37Z

My opinion:

  * The first commit should be merged.

  * For the second and third one, I don't have a strong opinion. One of the benefits that the content renderer and its strategies do not rely on the Routing component anymore.

---------------------------------------------------------------------------

by fabpot at 2013-01-22T15:22:47Z

Any comments? ping @Tobion @vicb

---------------------------------------------------------------------------

by Tobion at 2013-01-22T16:07:15Z

Shouldn't the class name be like `SubRequestRenderingStrategyInterface` because currently it does not say anything about what is rendered. `RenderingStrategyInterface` makes it look like it's for rendering a normal master request, i.e. templating.

---------------------------------------------------------------------------

by fabpot at 2013-01-22T16:19:26Z

@Tobion: This was actually the first name I had but I found it too long. It is indeed rendering a normal request, but only in the context of a master request.

---------------------------------------------------------------------------

by Tobion at 2013-01-22T16:23:25Z

I found the correct term for what this is about: http://en.wikipedia.org/wiki/Transclusion
So it should probably be like `Symfony/Component/HttpKernel/Transclusion/TransclusionInterface`
or `TransclusionStrategyInterface`.
So the term `rendering` is misleading as it does not really render the subrequest, but only prints a reference to the subrequest. The rendering is done by ESI processor or hinclude etc.

---------------------------------------------------------------------------

by fabpot at 2013-01-22T16:37:00Z

The `RenderingStrategyInterface` does render a request and returns a Response. One of the strategy consist of returning an ESI tag, but this is still a Response.

I don't like introducing the `Transclusion` word as (at least for me) it does not evoke anything.

---------------------------------------------------------------------------

by Tobion at 2013-01-22T16:46:10Z

Also `DefaultRenderingStrategy` is not saying anything. What is default? It should express that it directly includes the resource in the other (term `integrate` comes to my mind).

---------------------------------------------------------------------------

by kriswallsmith at 2013-01-22T17:23:21Z

How about `InlineRenderingStrategy`?

---------------------------------------------------------------------------

by vicb at 2013-01-22T17:25:17Z

@Tobion @kriswallsmith 👍

---------------------------------------------------------------------------

by kriswallsmith at 2013-01-22T17:26:17Z

Also, `SubRequestStrategyInterface` may be more apparent (`InlineSubRequestStrategy`, `EsiSubRequestStrategy`…)

---------------------------------------------------------------------------

by Tobion at 2013-01-22T18:10:19Z

`SubRequestStrategyInterface` is missing the verb somehow. A strategy for what? @kriswallsmith as an English native speaker, is transclusion also not convenient for you?

---------------------------------------------------------------------------

by fabpot at 2013-01-22T18:11:41Z

Thanks for all your suggestions, I appreciate them, but what about the whole approach? Do you agree that it is better than the current one? I'd like to avoid the bikeshedding if the approach is not better.

---------------------------------------------------------------------------

by kriswallsmith at 2013-01-22T18:22:47Z

👍 for removing the router dependency.

@Tobion perhaps request is the verb there?

---------------------------------------------------------------------------

by Tobion at 2013-01-22T19:51:20Z

I'm also fine with making it independent from the routing component because routing is about making routes configurable with placeholders etc. for nice URLs. But this is not needed for a proxy feature.

---------------------------------------------------------------------------

by kriswallsmith at 2013-01-22T20:13:48Z

@fabpot Do you anticipate ever wanting a sub request to be handled differently based on HTTP method? Just thinking of possible reasons to continue using the routing component here…

---------------------------------------------------------------------------

by fabpot at 2013-01-22T20:40:06Z

No, sub-requests only make sense for GET requests. In fact, we even enforce that in HttpContentRenderer.

---------------------------------------------------------------------------

by fabpot at 2013-01-23T06:51:54Z

I'm not going to discuss names further in the context of this PR as it has already been discussed in the initial PR that introduced these classes and because this PR does not change anything to the meaning of these classes. If you think the names can be better, feel free to open a ticket and discuss names there.

---------------------------------------------------------------------------

by vicb at 2013-01-23T07:48:36Z

If I understand correctly, both hsi and esi will generate path starting with "/_proxy", isn't it a problem wrt access_control ? should it be possible to configure a per strategy path ?

---------------------------------------------------------------------------

by fabpot at 2013-01-23T07:56:11Z

@vicb: Yes, all strategies use the `/_proxy` path when the developer uses a controller reference. But the router proxy takes care of securing the route, so there is no need to do it yourself.

---------------------------------------------------------------------------

by vicb at 2013-01-23T08:07:36Z

@fabpot that's smart, I've missed it.

Some questions though (they should be answered by UT I think - and might already have been, I have not checked)
- Isn't there a pb with urlencoding in the listener ?
- Would the listener work with fragments (`#...') ?

---------------------------------------------------------------------------

by vicb at 2013-01-23T08:31:37Z

Some more points:

- Should we validate that the router_proxy is enabled when esi are enabled (early failure ?)
- Should we be able to enable each strategy individually (ie no need to expose the signer when hsi are not used)

---------------------------------------------------------------------------

by fabpot at 2013-01-23T09:58:45Z

Enabling the router proxy when using ESI si not required. The router proxy is "only" required when you use the `controller` Twig function (or the equivalent in PHP -> `ControllerReference`). But we can probably throw an exception in the `ControllerReference` constructor if the proxy is not enabled.

Enabling each strategy individually is indeed a good idea (and that's more a general question as we could do the same for the translator loaders, or the service container loaders). Let's create another issue on this global topic.

---------------------------------------------------------------------------

by vicb at 2013-01-23T10:10:29Z

> But we can probably throw an exception in the ControllerReference constructor if the proxy is not enabled.

It should probably be in a wrapper class then ?

---------------------------------------------------------------------------

by fabpot at 2013-01-23T12:45:36Z

The listener does not need to work with fragments as URLs as they are never part of the generated URL.
2013-01-23 14:01:56 +01:00
src/Symfony renamed proxy to router_proxy 2013-01-23 13:57:53 +01:00
.editorconfig Add EditorConfig File 2012-06-16 14:08:15 +02:00
.gitignore ignore composer.phar 2012-04-20 14:10:06 +01:00
.travis.yml Merge branch '2.1' 2013-01-05 16:33:05 +01:00
autoload.php.dist [travis-ci] Zend Garbage Collection only for PHP5.4 2012-11-19 15:21:43 +01:00
CHANGELOG-2.0.md updated CHANGELOG for 2.0.22 2013-01-17 16:39:41 +01:00
CHANGELOG-2.1.md updated CHANGELOG for 2.1.7 2013-01-17 17:21:31 +01:00
composer.json [Monolog] Mark old non-PSR3 methods as deprecated 2013-01-09 10:19:50 +01:00
CONTRIBUTING.md Making it easier to grab the PR template. 2012-12-15 21:57:27 +00:00
CONTRIBUTORS.md update CONTRIBUTORS for 2.0.22 2013-01-17 16:40:10 +01:00
LICENSE updated license year 2013-01-04 17:59:43 +01:00
phpunit.xml.dist [travis-ci] Zend Garbage Collection only for PHP5.4 2012-11-19 15:21:43 +01:00
README.md Merge branch '2.0' into 2.1 2012-12-20 08:21:29 +01:00
UPGRADE-2.1.md Merge branch '2.1' 2012-11-29 11:32:45 +01:00
UPGRADE-2.2.md fixed markup 2013-01-19 08:50:02 +01:00
UPGRADE-3.0.md [Yaml] deprecated the possibility to pass a file name to Yaml::parse() 2013-01-17 15:01:21 +01:00

README

What is Symfony2?

Symfony2 is a PHP 5.3 full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP.

Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers.

Requirements

Symfony2 is only supported on PHP 5.3.3 and up.

Be warned that PHP versions before 5.3.8 are known to be buggy and might not work for you:

Installation

The best way to install Symfony2 is to download the Symfony Standard Edition available at http://symfony.com/download.

Documentation

The "Quick Tour" tutorial gives you a first feeling of the framework. If, like us, you think that Symfony2 can help speed up your development and take the quality of your work to the next level, read the official Symfony2 documentation.

Contributing

Symfony2 is an open source, community-driven project. If you'd like to contribute, please read the Contributing Code part of the documentation. If you're submitting a pull request, please follow the guidelines in the Submitting a Patch section and use Pull Request Template.

Running Symfony2 Tests

Information on how to run the Symfony2 test suite can be found in the Running Symfony2 Tests section.