This PR was squashed before being merged into the master branch (closes #5312). Commits ------- e0c4d99 [HttpKernel] Additional HTTP exceptions Discussion ---------- [HttpKernel] Additional HTTP exceptions I wanted to continue using exceptions for many other types of HTTP 4xx and 5xx status codes, particularly because I like the notion that I can trap the exception based on the type, rather than inspecting HttpException to see what status code it contains. I've decided to contribute these back to the Symfony HttpKernel component, in case others find them useful. * Bug fix: no * Feature addition: yes * Backwards compatibility break: no * Symfony2 tests pass: yes * Fixes the following tickets: - * Todo: - * License of the code: MIT * Documentation PR: n/a This pull request provides the following new HttpKernel Exceptions: Exception | Applicable HTTP Status Code ---------------------------------- | --------------------------------------- BadRequestHttpException | `400 Bad Request` ConflictHttpException | `409 Conflict` GoneHttpException | `410 Gone` InternalServerErrorHttpException | `500 Internal Server Error` LengthRequiredHttpException | `411 Length Required` NotAcceptableHttpException | `406 Not Acceptable` PreconditionFailedHttpException | `412 Precondition Failed` PreconditionRequiredHttpException | `428 Precondition Required`† ServiceUnavailableHttpException | `503 Service Unavailable` TooManyRequestsHttpException | `429 Too Many Requests`† UnauthorizedHttpException | `401 Unauthorized` UnsupportedMediaTypeHttpException | `415 Unsupported Media Type` All the tests have been placed in the FlattenExceptionTest, since that's where the previous status code and method tests for HttpException exceptions are located, but I can move them to a more logical location, if needed. † These codes have been included from [RFC 6585, Additional HTTP Status Codes](http://tools.ietf.org/html/rfc6585). --------------------------------------------------------------------------- by stof at 2012-08-21T23:10:45Z I would remove the InternalServerError one, as you get a 500 for any non-http exception anyway --------------------------------------------------------------------------- by stof at 2012-08-21T23:11:34Z and please rebase your branch to get rid of the merge commit at the beginning of your PR --------------------------------------------------------------------------- by ramsey at 2012-10-03T20:22:59Z @stof Can you provide some pointers on how to get rid of the merge commit through a rebase? I generally avoid rebase, so doing this is fairly new to me. I realize that what created the commit was a non-fast-forward merge, so I just need to understand how to get it to apply merges cleanly without creating merge commits like that. Thanks! --------------------------------------------------------------------------- by alexandresalome at 2012-10-04T07:14:00Z @ramsey # suppose you are on branch-feature # given origin is the symfony repository git pull --rebase origin/master # equivalent to git fetch origin git rebase origin/master If you want to rebase your branch on 2.1: git pull --rebase origin/2.1 --------------------------------------------------------------------------- by stof at 2012-10-04T18:52:22Z @ramsey http://symfony.com/doc/current/contributing/code/patches.html#rework-your-patch for the documentation about the way to do it --------------------------------------------------------------------------- by stof at 2012-10-13T20:44:26Z @ramsey ping --------------------------------------------------------------------------- by fabpot at 2012-10-29T09:47:36Z I'm going to finish this PR, but #5862 should be merged first. --------------------------------------------------------------------------- by ramsey at 2012-10-29T15:36:31Z Sorry I've been sitting on this for so long. I haven't had time to figure out how to get rid of the merge commit, as @stof requested. That's the only outstanding issue here, as far as I know. --------------------------------------------------------------------------- by fabpot at 2012-10-29T15:47:54Z I can see another issue. For some HTTP codes, you can/should/must add some headers or some content (like for the 406 status code). Don't worry about the merge commit or the rebasing, I will take care of that myself when merging the PR. --------------------------------------------------------------------------- by ramsey at 2012-10-29T16:05:04Z I don't know what header is required for the 406 status code. RFC 2616 doesn't specify one. It does say "the response should include an entity containing a list of available entity characteristics and locations." In other exceptions, such as UnauthorizedHttpException, TooManyRequestsHttpException, and ServiceUnavailableException, I did provide the required headers. On Monday, October 29, 2012 at 10:48 AM, Fabien Potencier wrote: > I can see another issue. For some HTTP codes, you can/should/must add some headers or some content (like for the 406 status code). > Don't worry about the merge commit or the rebasing, I will take care of that myself when merging the PR. > > — > Reply to this email directly or view it on GitHub (https://github.com/symfony/symfony/pull/5312#issuecomment-9871877). > > > |
||
---|---|---|
src/Symfony | ||
.editorconfig | ||
.gitignore | ||
.travis.yml | ||
autoload.php.dist | ||
CHANGELOG-2.0.md | ||
CHANGELOG-2.1.md | ||
composer.json | ||
CONTRIBUTING.md | ||
CONTRIBUTORS.md | ||
LICENSE | ||
phpunit.xml.dist | ||
README.md | ||
UPGRADE-2.1.md |
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:
-
before PHP 5.3.4, if you get "Notice: Trying to get property of non-object", you've hit a known PHP bug (see https://bugs.php.net/bug.php?id=52083 and https://bugs.php.net/bug.php?id=50027);
-
before PHP 5.3.8, if you get an error involving annotations, you've hit a known PHP bug (see https://bugs.php.net/bug.php?id=55156).
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.
Running Symfony2 Tests
Information on how to run the Symfony2 test suite can be found in the Running Symfony2 Tests section.